The Sniff compiler can be run on Mac, x86 Linux and Raspberry Pi, and (obviously) if you compile your programs on a Mac, they can run on a Mac. However the compiler can also TARGET Arduino. The two main systems used for development are compiling on Mac to run on Arduino, and compiling on Pi to run on Pi. However until now there's been one "gotcha"...
About 18months ago the Arduino developers released the Arduino 1.5 Beta software. Sniff requires this version as it includes support for Due and Yun, and quite simply its going to replace the 1.0 version, so why support the old version? All would be fine, except that its still in beta, and the Raspberry Pi team are still bundling the old 1.0 release. There's no easy way to run the 1.5 release on Pi, which means while Sniff runs great on the Pi (and you can control the GPIO), you couldn't program an Arduino in Sniff on a Pi.
Ideally Arduino would just announce that 1.5 is not "released", Raspberry Pi would bundle it into Raspian, and we'd be ready to go, but in the mean time there's a hack... The Arduino software consists of three parts:
- The IDE
- The Compiler Toolchain
- The Arduino/Wiring Source Code/Headers
The trick is that for Sniff we don't care about the IDE, we have a perfectly good set of compilers which came with the 1.0 release and run on Pi, and a bunch of Arduino code, which runs on the Arduino, so which is the same on all platforms, so doesn't need changed for the Pi.
To get this working, first install the standard Pi IDE with:
sudo apt-get install arduino
You've probably done this already. This puts everything in the folder "/usr/share/arduino".
Now we've got our toolchain, you need to download the PC or Mac version of the latest 1.5 IDE, and unpack it. Somewhere inside that you'll find a folder which looks a lot like the one you have. The bit we're interested in is in a sub-folder called "hardware".
In /usr/share/arduino/hardware you already have is another folder called "arduino" (along with a tools folder you shouldn't touch). Rename that arduino folder to arduino1.1 (in case we need it again), and then copy the corresponding hardware/arduino folder from the new 1.5 release to /usr/share/arduino/hardware/arduino1.5. Finally link the new 1.5 folder to the name arduinio:
cd /usr/share/arduino/hardware
ln -s arduino1.5 arduino
This will almost certainly break the Arduino IDE, so if you need to use the IDE again, link the arduino folder back to arduino1.1. However with the link changed to 1.5 you can compile Sniff programs against the Arduino 1.5 library using on a Pi!!!!
This is now integrated into the 0.7 release of Sniff, so you can now just use that to compile for Arduino on Pi. You still need the AVR toolchain installed, but now you don't need a specific version of the Arduino IDE.
ReplyDelete