Difference between revisions of "Userspace Arduino"
|Line 260:||Line 260:|
Revision as of 11:45, 19 July 2013
This page documents research on creating a userspace executable using the wiring and Processing language used with Arduino.
- 1 Getting Started
- 2 Boards Supported
- 3 Transfer Options
- 4 Action List and Issues
The examples have been tested to work on production images later than 2013.06.20. You will need a 4 GB (or greater) microSD card for flashing the Beaglebone Black, a process which may take well over 45 minutes. It is documented on the CircuitCo wiki. If you are unsure which image is currently loaded on the Beaglebone Black, check it at http://www.crashcourse.ca/wiki/index.php/Examining_your_BBB_install_version.
~$ wget http://www.angstrom-distribution.org/toolchains/angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain.tar.bz2 ~$ sudo tar -C / -xzf angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain.tar.bz2 ~$ export PATH=/usr/local/angstrom/arm/bin:$PATH ~$ export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
Links to 64 and 32 bit versions of Angstrom toolchain.
- Clone the repo from https://github.com/prpplague/Userspace-Arduino
Running a demo
Running Blink LED program:
cd Userspace-Arduino/arduino-makefile/examples/BlinkUserspace make
- A binary BlinkUserspace.elf should be created in a directory build-userspace
- send-exec is an upload and execute script, which is integrated with the Arduino-Userspace repository. It uses the scp protocol to copy binaries to the Beaglebone Black over USB/ethernet and execute it. You can find it in the utility folder.
- To use it, simply do
- You will now see USR LED 1 blinking at one second intervals. Press Ctrl-C to break from the loop.
- Check out some of the examples in /path/to/Userscape-Arduino/Arduino-Makefile/examples.
Setup SSH keys (optional)
- If you want to avoid a password prompt, you can set up the ssh keys for the Beaglebone Black:
cd ~/.ssh ssh-keygen -t dsa #set a password or you can leave it blank ssh-copy-id -i ~/.ssh/id_dsa.pub root@$192.168.7.2 # replace id_dsa.pub by your public key file if some other name is given ssh email@example.com # login and enter password once
Here after, you won't be prompted for a password from this machine
Initial development is being done with the Beaglebone Black and the Bacon Cape
- if you have your Beaglebone Black loaded with a firmware image older that 07.11.2013, you will need copy the Bacon Cape dtbo file on to your beaglebone black
~# scp ~/Downloads/BB-BONE-BACONE-00A0.dtbo firstname.lastname@example.org:/lib/firmware/BB-BONE-BACONE-00A0.dtbo
|Arduino Pin||BBB Header Pin||Function||Alternate Function|
|14||USR LED 0||LED|
|15||USR LED 1||LED|
|16||USR LED 2||LED|
|17||USR LED 3||LED|
- Initial support started
- Need Lure accessory board for testing
- support planned
- will use RPi_Gertboard for initial development
- GNU Netcat networking tool http://netcat.sourceforge.net/
- Can create a connection using nc -w 1 192.168.7.2 1114 < new.zip on the server (in this case the machine running the Energia IDE), and nc -lp 1114 > n.zip on the Beaglebone. 1114 is a random port number which has to be the same on client as well as server side.
- Some issue with sending .bin files directly. Mostly it was with how the file ends, not sure. So need to zip the file.
- Requires no authentication
- A script will be needed to listen on a particular port on the BBB for any incoming connections which will receive, unzip and execute the code.
- Needs ssh and sftp installed
- Need to configure keys initially. Works without user authentication after that
- Code to upload and execute binary here : https://github.com/anujdeshpande/send_exec
Emulating the Arduino bootloader
- The Arduino Bootloader uses a protocol similar to STK500v1 (over UART, though)
- One way to program (copy) the binaries would be to emulate the protocol on the bone over USB gadget and use AVRDude on the IDE side
- However this would be cumbersome, since the protocol was designed to write bytes to flash memory, not copy files.
- Energia uses mspdebug to flash the MSP430 using a serialized version of JTAG called Spy-Bi-Wire (SBW).
- File transfer protocols over serial like XMODEM and ZMODEM could be explored for an easier and more compatible option to Upload the binaries.
- Install the lrzsz package on both the host (PC) and the client (Beaglebone):
apt-get install lrzsz
- Connect the Beaglebone via USB and determine the port (for e.g. /dev/ttyUSB1). Once the OS is booted up, start the transfer:
sz -vv -b filename.bin < /dev/ttyUSB1 > /dev/ttyUSB1
- Send executable over port 80
- On BBB, listen for any uploads and execute them
Action List and Issues
- The Arduino 1.5 IDE has better support for arbitrary architectures than the Energia fork of Arduino. This could help since the architecture specific stuff has been moved to config files. Further investigation is needed. Should the Userspace implementation forked directly out of the Arduino IDE or should the current implementation continue?
- For development beyond the GSOC period, an option to get this upstream needs to be considered.
- The BBB needs a separate FTDI cable for serial ports. However, a /dev/ttyACM port is available over USB. It can be used for uploading via the normal bootloader way. After the upload, it can be used for serial read/write to the host (PC).
- A single protocol to tackle uploading via USB and ethernet and may not be feasible. Networking over USB is pretty unreliable and tough for newbies to get working. For ethernet upload, several of the above options can be considered. For USB, a simple bootloader emulator will do.