* [http://prpplague.github.io/Energia/ Primary Blog] for work on the project

* [http://prpplague.github.io/Energia/ Primary Blog] for work on the project

Line 5:

Line 7:

* [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 />

−

+

A Getting Started guide on compiling and executing "Arduino code" on embedded Linux boards.

−

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 =

+

Unlike the "standard" way of developing for the Arduino boards, we only have the [https://github.com/prpplague/Userspace-Arduino libraries] ready at the moment (The IDE is still under development). In short, you'll have to use your own editor for writing code.

+

<br />Currently there are 2 methods to compile and execute Arduino code on the BeagleBone Black.

+

# [[#native | Native compilation]]

+

# [[#cross | Cross compilation]]

−

== Cloning ==

+

==<span id="native">Native Compilation</span>==

+

You won't have to install any toolchain.

+

<p> Connect to your BeagleBone Black using ssh. Make sure that you have internet access on your BBB.</p>

+

===Clone repo===

+

* Clone the repo from the GitHub project page

+

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

+

+

=== Running a demo ===

+

Running Blink LED program:

+

<pre>

+

cd Userspace-Arduino/arduino-makefile/examples/BlinkUserspace

+

make

+

</pre>

+

* A binary BlinkUserspace.elf should be created in a directory build-userspace

+

cd build-userspace

+

./BlinkUserspace.elf

+

* You will now see USR LED 1 blinking at one second intervals. Press Ctrl-C to break from the loop.

+

+

==<span id="cross">Cross Compilation</span>==

+

===Install toolchain===

+

*You will need the Angstrom cross compilation toolchain for the BeagleBone Black.

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

+

* If you want to avoid a password prompt, you can set up the ssh keys for the Beaglebone Black:

−

cd Userspace-Arduino/arduino-makefile/examples/HelloWorldUserspace

+

cd ~/.ssh

−

* To make, while in the above directory:

+

ssh-keygen -t dsa #set a password or you can leave it blank

−

make

+

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

−

* A binary HelloWorldUserspace.elf should be created in a directory build-userspace

+

ssh root@192.168.7.2 # login and enter password once

−

* Copy the binary to the Beaglebone Black and execute!

+

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

+

<br />

−

== Using send - exec ==

+

= Examples =

−

* Get https://github.com/anujdeshpande/send_exec

+

Each of these examples have their own detailed wiki pages:

−

* Follow the readme. The stuff is pretty self explanatory

+

−

= Boards Supported =

+

* [[Userspace_Arduino:BlinkUserspace|BlinkUserspace]]

+

* [[Userspace Arduino:BlinkWithoutDelay|Blink Without Delay]]

+

* [[Userspace Arduino:AnalogReadSerial|AnalogReadSerial]]

+

= Boards Supported =

+

<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

* 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

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

Getting Started

Unlike the "standard" way of developing for the Arduino boards, we only have the libraries ready at the moment (The IDE is still under development). In short, you'll have to use your own editor for writing code.
Currently there are 2 methods to compile and execute Arduino code on the BeagleBone Black.

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