Difference between revisions of "Userspace Arduino"

From eLinux.org
Jump to: navigation, search
(Added Beaglebone pin map)
Line 1: Line 1:
<div style="margin:0; margin-top:10px; margin-right:10px; border:1px solid #dfdfdf; padding:0 1em 1em 1em; background-color:#ffffcc; align:right; ">
'''Development Blogs for the Userspace Arduino project:'''
* [http://prpplague.github.io/Energia/ Primary Blog] for work on the project
* [http://meanbot.wordpress.com/ Parav Nagarsheth's Blog] about his work on the project
* [http://anujdeshpande.wordpress.com/  Anuj Deshpande's Blog] about his work on the project
this page is to document some 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.

Revision as of 08:20, 10 July 2013

Development Blogs for the Userspace Arduino project:

this page is to document some research on creating a userspace executable using the wiring and processing language used with Arduino.

Getting Started


git clone https://github.com/prpplague/Energia.git
  • Checkout branch userspace from origin/userspace
cd Energia && git checkout -b userspace origin/userspace
  • Warning: The repo is HUGE (> 1.5GB). If you want a smaller version of the code, you might want to wait a little.

Getting the makefile

git clone https://github.com/meanbot/Arduino-Makefile.git
  • Have a look at example code HelloWorldUserspace
cd /path/to/Arduino-Makefile/examples/HelloWorldUserspace
  • To make, while in the ^^ above directory:
  • A binary HelloWorldUserspace.elf should be created in build-userspace
  • Copy the binary to the Beaglebone Black and execute!

Using send - exec

Beaglebone Black to Arduino Pin Map

Arduino Pin BBB Header Pin 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 PWM
8 P9_19 I2C

Transfer Options


  • GNU Netcat networking tool http://netcat.sourceforge.net/
  • Can create a connection using nc -w 1 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
  • 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.