Difference between revisions of "Userspace Arduino"

From eLinux.org
Jump to: navigation, search
(Getting Started)
(Cleaning up some formatting.)
Line 5: Line 5:
 
* [http://anujdeshpande.wordpress.com/  Anuj Deshpande's Blog] about his work on the project
 
* [http://anujdeshpande.wordpress.com/  Anuj Deshpande's Blog] about his work on the project
 
</div>
 
</div>
<br>
+
<br />
 
+
This page documents research on creating a userspace executable using the wiring and Processing language used with Arduino.
this page is to document some research on creating a userspace executable using the wiring and processing language used with Arduino.
+
<br />
 
+
 
= Getting Started =
 
= Getting Started =
<br>
+
<br />
 
== Cloning ==
 
== Cloning ==
 
* Clone the repo from https://github.com/prpplague/Userspace-Arduino
 
* Clone the repo from https://github.com/prpplague/Userspace-Arduino
 
  git clone https://github.com/prpplague/Userspace-Arduino.git
 
  git clone https://github.com/prpplague/Userspace-Arduino.git
<br>
+
<br />
 
+
 
== Toolchain ==  
 
== Toolchain ==  
<br>
+
<br />
==== BeagleBone Black ====
+
=== BeagleBone Black ===
 
<pre>
 
<pre>
 
~$ wget http://www.angstrom-distribution.org/toolchains/angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain.tar.bz2
 
~$ wget http://www.angstrom-distribution.org/toolchains/angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain.tar.bz2
Line 25: Line 23:
 
~$ export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
 
~$ export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
 
</pre>  
 
</pre>  
<br>
+
<br />
 
* [http://www.angstrom-distribution.org/toolchains/angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain.tar.bz2 x86_64-linux-armv7a-linux-gnueabi-toolchain]
 
* [http://www.angstrom-distribution.org/toolchains/angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain.tar.bz2 x86_64-linux-armv7a-linux-gnueabi-toolchain]
 
* [http://www.angstrom-distribution.org/toolchains/angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain.tar.bz2 i686-linux-armv7a-linux-gnueabi-toolchain]
 
* [http://www.angstrom-distribution.org/toolchains/angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain.tar.bz2 i686-linux-armv7a-linux-gnueabi-toolchain]
<br>
+
<br />
 
+
=== MinnowBoard ===
==== MinnowBoard ====
+
 
* todo
 
* todo
<br>
+
<br />
==== Raspberry Pi ====
+
=== Raspberry Pi ===
 
* todo
 
* todo
<br>
+
<br />
 
+
 
== Running a demo ==
 
== Running a demo ==
 
* Check out some of the examples in /path/to/Userscape-Arduino/Arduino-Makefile/examples. Currently only [http://github.com/prpplague/Userspace-Arduino/blob/master/arduino-makefile/examples/HelloWorldUserspace/HelloWorldUserspace.ino HelloWorldUserspace], [http://github.com/prpplague/Userspace-Arduino/blob/master/arduino-makefile/examples/BlinkUserspace/BlinkUserspace.ino BlinkUserspace] and [http://github.com/prpplague/Userspace-Arduino/blob/master/arduino-makefile/examples/BaconDemo/BaconDemo.ino BaconDemo] work.
 
* Check out some of the examples in /path/to/Userscape-Arduino/Arduino-Makefile/examples. Currently only [http://github.com/prpplague/Userspace-Arduino/blob/master/arduino-makefile/examples/HelloWorldUserspace/HelloWorldUserspace.ino HelloWorldUserspace], [http://github.com/prpplague/Userspace-Arduino/blob/master/arduino-makefile/examples/BlinkUserspace/BlinkUserspace.ino BlinkUserspace] and [http://github.com/prpplague/Userspace-Arduino/blob/master/arduino-makefile/examples/BaconDemo/BaconDemo.ino BaconDemo] work.
Line 44: Line 40:
 
* A binary HelloWorldUserspace.elf should be created in a directory build-userspace
 
* A binary HelloWorldUserspace.elf should be created in a directory build-userspace
 
* Copy the binary to the Beaglebone Black and execute!
 
* Copy the binary to the Beaglebone Black and execute!
<br>
+
<br />
 
== Using send_exec ==
 
== Using send_exec ==
 
* [https://github.com/prpplague/Userspace-Arduino/blob/master/utility/send_exec.sh send-exec] is a nice little upload and execute script, which has now been integrated with the Arduino-Userspace repository. It uses the scp protocol to copy binaries to the Beaglebone Black over USB ethernet and ssh to execute it.
 
* [https://github.com/prpplague/Userspace-Arduino/blob/master/utility/send_exec.sh send-exec] is a nice little upload and execute script, which has now been integrated with the Arduino-Userspace repository. It uses the scp protocol to copy binaries to the Beaglebone Black over USB ethernet and ssh to execute it.
Line 55: Line 51:
 
  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-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 root@192.168.7.2 # login and enter password once
 
  ssh root@192.168.7.2 # login and enter password once
 
 
Here after, you won't be prompted for a password from this machine
 
Here after, you won't be prompted for a password from this machine
 
+
<br />
<br>
+
 
+
 
= Boards Supported =
 
= Boards Supported =
<br>
+
<br />
 
== Beaglebone Black ==
 
== Beaglebone Black ==
 
Initial development is being done with the Beaglebone Black and the [[Bacon_Cape]]
 
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 [[media:BB-BONE-BACONE-00A0.dtbo|Bacon Cape dtbo file]] on to your beaglebone black
 
* if you have your beaglebone black loaded with a firmware image older that 07.11.2013, you will need copy the [[media:BB-BONE-BACONE-00A0.dtbo|Bacon Cape dtbo file]] on to your beaglebone black
 
<pre>
 
<pre>
Line 202: Line 194:
 
|
 
|
 
|}
 
|}
<br>
+
<br />
 
+
 
== MinnowBoard ==
 
== MinnowBoard ==
 
* Initial support started
 
* Initial support started
 
* Need Lure accessory board for testing
 
* Need Lure accessory board for testing
<br>
+
<br />
 
== Raspberry Pi ==
 
== Raspberry Pi ==
 
* support planned
 
* support planned
 
* will use [[RPi_Gertboard]] for initial development
 
* will use [[RPi_Gertboard]] for initial development
<br>
+
<br />
 
= Transfer Options =
 
= Transfer Options =
<br>
+
<br />
 
== Netcat ==
 
== Netcat ==
 
* GNU Netcat networking tool http://netcat.sourceforge.net/
 
* GNU Netcat networking tool http://netcat.sourceforge.net/
Line 220: Line 211:
 
* Requires no authentication
 
* 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.
 
* 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.
<br>
+
<br />
 
== ssh/sftp ==
 
== ssh/sftp ==
 
* Needs ssh and sftp installed
 
* Needs ssh and sftp installed
Line 228: Line 219:
 
** Create Sketchbook folder
 
** Create Sketchbook folder
 
** Fetch output if any, display it in the serial monitor
 
** Fetch output if any, display it in the serial monitor
<br>
+
<br />
 
== Emulating the Arduino bootloader  ==
 
== Emulating the Arduino bootloader  ==
 
* The Arduino Bootloader uses a protocol similar to STK500v1 (over UART, though)
 
* The Arduino Bootloader uses a protocol similar to STK500v1 (over UART, though)
Line 239: Line 230:
 
* Connect the Beaglebone via USB and determine the port (for e.g. /dev/ttyUSB1). Once the OS is booted up, start the transfer:
 
* 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
 
  sz -vv -b filename.bin < /dev/ttyUSB1 > /dev/ttyUSB1
<br>
+
<br />
 
== HTTP post ==
 
== HTTP post ==
 
* Send executable over port 80
 
* Send executable over port 80
 
* On BBB, listen for any uploads and execute them
 
* On BBB, listen for any uploads and execute them
<br>
+
<br />
 
= Action List and Issues  =
 
= 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?
 
* 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?
Line 249: Line 240:
 
* 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).
 
* 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.
 
* 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.
<br><br>
+
<br />
 +
<br />
 
[[Category:Arduino]]
 
[[Category:Arduino]]
 
[[Category: RaspberryPi]]
 
[[Category: RaspberryPi]]
 
[[Category: MinnowBoard]]
 
[[Category: MinnowBoard]]
 
[[Category: BeagleBoard]]
 
[[Category: BeagleBoard]]

Revision as of 03:47, 16 July 2013

Development Blogs for the Userspace Arduino project:


This page documents research on creating a userspace executable using the wiring and Processing language used with Arduino.

Getting Started


Cloning

git clone https://github.com/prpplague/Userspace-Arduino.git


Toolchain


BeagleBone Black

~$ 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-



MinnowBoard

  • todo


Raspberry Pi

  • todo


Running a demo

cd Userspace-Arduino/arduino-makefile/examples/HelloWorldUserspace
  • To make, while in the above directory:
make
  • A binary HelloWorldUserspace.elf should be created in a directory build-userspace
  • Copy the binary to the Beaglebone Black and execute!


Using send_exec

  • send-exec is a nice little upload and execute script, which has now been integrated with the Arduino-Userspace repository. It uses the scp protocol to copy binaries to the Beaglebone Black over USB ethernet and ssh to execute it.
  • To use it, simply do a
make upload 

in the same directory where the makefile is located for the respective examples.

  • 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 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 root@192.168.7.2 # login and enter password once

Here after, you won't be prompted for a password from this machine

Boards Supported


Beaglebone Black

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 root@192.168.7.2:/lib/firmware/BB-BONE-BACONE-00A0.dtbo
Arduino Pin BBB Header Pin Function Alternate Function
0 P9_11 UART (RXD)
1 P9_13 UART (TXD)
2 P9_15 GPIO
3 P9_14 PWM
4 P9_12 GPIO
5 P9_16 PWM
6 P9_42 PWM
7 P8_19 GPIO PWM
8 P9_19 I2C (SCL)
9 P9_20 I2C (SDA)
10 P9_17 GPIO SPI_CS0
11 P9_18 GPIO SPI_MOSI
12 P9_21 SPI_MISO
13 P9_22 GPIO SCK
14 USR LED 0 LED
15 USR LED 1 LED
16 USR LED 2 LED
17 USR LED 3 LED
18 P9_33 AIN4
19 P9_35 AIN6
20 P9_36 AIN5
21 P9_37 AIN2
22 P9_38 AIN3
23 P9_39 AIN0
24 P9_40 AIN1


MinnowBoard

  • Initial support started
  • Need Lure accessory board for testing


Raspberry Pi


Transfer Options


Netcat

  • 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.


ssh/sftp

  • 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
  • To do :
    • Create Sketchbook folder
    • Fetch output if any, display it in the serial monitor


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


HTTP post

  • 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.