Sunday, October 12, 2014

Arduino IDE 1.5.8 on Banana Pi

I use Arch Linux on Banana Pi. In my previous post, I used a workaround to compile Arduino code on an x86_64 platform and then copy the *.hex file to upload to Arduino from Banana Pi. While i7-4770 is very fast, it's also very power hungry. I dug a little bit and managed to get Arduino IDE 1.5.8 running on my Banana Pi.

If you want to install Arduino 1.0.5-1, Arch Assualt Repo has an almost working version. To make it work, you'll need to install java-rxtx, and replace /usr/share/arduino/lib/ with a symlink to /usr/lib/ , and also RXTXcomm.jar -> /usr/share/java/rxtx/RXTXcomm.jar

Now, this is how I got version 1.5.8 working (thanks to this post for a pointer):

Use the following PKGBULID (modified from its AUR for x86 and x86_64) to build and install a package:

# Maintainer: Lauri Hakko # Contributor: PyroPeter # Contributor: darkapex pkgname=arduino-beta epoch=1 pkgver=1.5.8 pkgrel=1 pkgdesc="Arduino SDK Beta release" arch=('armv7h') url="" options=(!strip) license=('GPL') depends=('avr-libc' 'libusb-compat' 'java-runtime') install="arduino.install" conflicts=('arduino' 'arduino-toolchain') provides=('arduino') source=("${pkgver//_/-}-linux32.tgz" 'arduino' 'arduino.png' 'arduino.desktop') md5sums=('289b1e3ad64f29db3ed13b06880dce40' '5e385c8cba80ca1b4227b162e4cad5cd' '9e36d33891d5e68d38ec55d1494499a5' 'eebc4d6495864bea99ad057af801afb9') package() { cd "$srcdir/arduino-${pkgver//_/-}" # arduino excutable should accept arguments sed -i 's/^java .*$/\0 "$*"/' arduino mkdir -p "$pkgdir"/usr/{bin,share/{doc,applications,pixmaps}} # copy the whole SDK to /usr/share/arduino/ cp -r . "$pkgdir/usr/share/arduino" # at least support the FHS a little bit: install -m755 "$srcdir/arduino" "$pkgdir/usr/bin/arduino" ln -s /usr/share/arduino/reference "$pkgdir/usr/share/doc/arduino" # desktop icon install -m644 "$srcdir/arduino.desktop" "$pkgdir/usr/share/applications/" install -m644 "$srcdir/arduino.png" "$pkgdir/usr/share/pixmaps/" }

This version won't run because /usr/share/arduino/hardware/tools/* are compiled for x86. We need those files compiled for Arm7. Let's remove /usr/share/arduino/hardware/tools now.

Download a pre-compiled version 1.5.4 by UDOO folks (big thanks for their efforts!). Go to their download page, click on Driver & Tools, and click on Arduino IDE for UDOO. Unpack the archive. We only need arduino/hardware/tools . Move it to /usr/share/arduino/hardware/tools

Since 1.5.8 above expects avr tools in /usr/share/arduino/hardware/tools/avr, and Arch installs it separately, so we need to make another two symlinks.

$ ln -s /usr/bin /usr/share/arduino/hardware/tools/avr/
$ ln -s /etc /usr/share/arduino/hardware/tools/avr/

There's one more file we need to replace: arduino/lib/ . I just installed astyle from and do a symlink -> /usr/lib/

That's it.

Friday, October 10, 2014

Control Arduino IDE 1.5.8 with command line

My workbench for Arduino development does not have enough space for a high power PC so I use lower power Arm devices (Raspberry Pi, Banana Pi, and Yun Shield) instead. However, Arduino IDE 1.5.x is not well supported yet (Raspbery Pi has a working version but not the other two, which I prefer. UPDATE: I figured it out.), and several Makefile solutions are still buggy against 1.5.x's libraries.

My temporary solution is to outsource the compiling to the more powerful machine (my i7-4770 running Arch 64 finishes compilation almost instantly, as opposed to 40 seconds on Raspberry Pi), and grab the compiled *.hex file back to these Arm devices to upload to Arduino via the USB serial connection.

As of October 4, 2014, Arduino IDE 1.5.8 has a buggy command line parameter passing, so I cannot compile the code remotely without doing a remote X session, and I want to avoid having to run an X server on these Arm devices (although Banana Pi actually runs X quite well). Therefore, I use the following hack to trigger the compiling via the command line.

$ DISPLAY=:0 xdotool search --name "Arduino 1.5.8" windowactivate --sync windowfocus mousemove --window %1 10 30 click 1

xdotool searches for a window whose title contains "Arduino 1.5.8", activates the virtual desktop it's on, focuses on the window, moves the mouse cursor to coordinates (10,30) relative to the application window (where the "Verify/Compile" button is) and then clickes on it to trigger the compilation.

For some reason sending ctrl+r doesn't work for me. If anyone knows why, I'd love to know.

$ # this doesn't work
$ DISPLAY=:0 xdotool search --name "Arduino 1.5.8" windowactivate --sync windowfocus key ctrl+r