Computing stuff tied to the physical world

Uploading (just about) anywhere

With Raspberry Pi’s and Odroids becoming so common these days, it’s quite convenient to use them for all sorts of physical computing projects as well. One way to do so, is to treat them as a regular (albeit very low-end) laptop or desktop computer, and then compile and upload right on these little boards. You’ll need an “arm-non-eabi” toolchain, but it’s doable.

But that’s a bit of a sluggish option and not terribly convenient unless you also want to edit and develop with all the source files maintained on the Raspberry Pi / Odroid.

Here’s a different approach, now possible with the new “uploader” utility:

  • edit and compile the code locally, on your laptop / desktop machine of choice
  • install a network-to-serial-port bridge on the Raspberry Pi or Odroid
  • upload over the network

To make this work, we need to install and configure a small utility on the remote Linux board, called ser2net. It’s a server which listens to incoming requests and then connects to one of the pre-configured serial ports for you.

Here is how to install ser2net, this should work on most Debian-/Ubuntu-like systems:

sudo apt-get install ser2net

That’s it, ser2net is now running in the background. It’s configured via a text file called /etc/ser2net.conf – we just need to set it up properly for our purposes:

  • as root, open an editor to make some changes to the file
  • if you’re not familiar with “vi”, you could use: sudo nano /etc/ser2net.conf

The change we need to make is to add a line at the bottom, with the following setting:

4000:telnet:600:/dev/ttyUSB0:115200 remctl

Change as needed if your FTDI interface is not connected as /dev/ttyUSB0.

Save, then tell the (running!) ser2net server that the configuration has changed, using:

sudo /etc/init.d/ser2net reload

That’s it. The Raspberry Pi / Odroid is now ready to handle remote upload requests. Don’t forget to plug in your FTDI interface and the µC board for the LPC8xx chip you’re using.

One more thing: make a note of the IP address of the RPi/OC. We’ll need it in the next step.

Back to the laptop – we can now try to reach our “remote” board:

$ uploader -t 192.168.1.52:4000
found: 8100 - LPC810: 4 KB flash, 1 KB RAM, DIP8
hwuid: 4E60031002841BAE525BD751071900F5
$

Note the extra “-t” flag to specify the “telnet” protocol – this is needed to be able to control the DTR and RTS pins on the remote end. Note also that instead of a “/dev/tty…” device, we’re now specifying a network address, including the port number set in “ser2net.conf”.

Now let’s try an upload:

$ uploader -t 192.168.1.52:4000 firmware.bin 
found: 8100 - LPC810: 4 KB flash, 1 KB RAM, DIP8
hwuid: 4E60031002841BAE525BD751071900F5
flash: 05C0 done, 1464 bytes
$

Yippie – it works just like a local USB port. It even works with the serial and idle settings:

$ uploader -s -i 1 -t 192.168.1.52:4000 firmware.bin 
found: 8100 - LPC810: 4 KB flash, 1 KB RAM, DIP8
hwuid: 4E60031002841BAE525BD751071900F5
flash: 05C0 done, 1464 bytes
entering terminal mode, press <ESC> to quit:

DEV_ID = 00008100
GPREG0 = 00000033
GPREG1 = 00000000
GPREG2 = 00000000
GPREG3 = 00000000

idle timeout
$

The only difference is the extra “-t” option and the <addr>:<port> network address.

With this telnet-based mechanism, there is no longer a need to stay logged into the remote Linux box all the time. We can simply upload and debug as if the µC were attached locally.

Do keep in mind that telnet is an insecure channel – you should only use this on your local network, behind your firewall (use a VPN or SSH tunnelling if you need secure access).

[Back to article index]