Now you can compile sketches on the Yun!

I put together a toolchain (based on gcc 4.3.2) that will compile sketches on the OpenWrt side of the Yun. You can then use the existing tools (merge-sketch-with-bootloader and run-avrdude) to upload them to the Leonardo side.

This is available at YunAvrToolchain, instructions are in the README

I tested this with the Blink, YunSerialTerminal and Bridge examples in the Arduino IDE and these work fine.

Enjoy!

Good job! :slight_smile:

How much time is needed to compile the blink example?

It takes around 45 seconds to build blink.

Since Sudar's system uses make logic it only builds libraries if they have changed, the next time you build it takes about 3 or 4 seconds.

Here are some test results showing start and finish times for various examples:

Blink -
First Build
Fri Nov 21 06:01:23 CST 2014
Fri Nov 21 06:02:03 CST 2014
Next Build
Fri Nov 21 06:02:04 CST 2014
Fri Nov 21 06:02:07 CST 2014

YunSerialTerminal -
First Build
Fri Nov 21 05:53:32 CST 2014
Fri Nov 21 05:54:13 CST 2014
Next Build
Fri Nov 21 05:54:13 CST 2014
Fri Nov 21 05:54:17 CST 2014

Bridge-
First Build
Fri Nov 21 06:02:56 CST 2014
Fri Nov 21 06:04:03 CST 2014
Next Build
Fri Nov 21 06:04:03 CST 2014
Fri Nov 21 06:04:10 CST 2014

Process-
First Build
Fri Nov 21 06:06:35 CST 2014
Fri Nov 21 06:07:39 CST 2014
Next Build
Fri Nov 21 06:07:39 CST 2014
Fri Nov 21 06:07:45 CST 2014

The test on Process revealed a bug in the Makefile, I will be updating the github repository soon.

The problem occurs when a library includes another library. In this case Process includes Bridge, using this as the Makefile solves it:

BOARD_TAG    = yun
ARDUINO_DIR = /usr/local/arduino-1.5.8
AVR_TOOLS_DIR = /usr/local/YunAvrToolchain-master
ARDUINO_LIBS= Bridge
include /usr/local/Arduino-Makefile-master/Arduino.mk

Nice, thanks for sharing it.

The github repository now has the updated Makefile that should compile any sketch that works in the IDE. It also has scripts that automate setting up a new sketch and uploading.

Now you can:

newSketch Blink
cp /usr/local/arduino-1.5.8/examples/01.Basics/Blink/Blink.ino /root/sketchbook/Blink/
upload Blink