Aaron Ardiri
[Valid RSS] RSS/XML feed
198 entries available (show all)


Internet of Things (IoT)

RIoT Secure AB


Small device, hidden power - this is one of my favourite Arduino devices so far.

As part of my research into IoT security feasibility I got my hands on an Arduino Yún, an official Arduino device that not only comes with a 16Mhz Atmel ATmega32u4 CPU but an accompanying 400Mhz Atheros AR9331 running a Linux variant known as Linino (based on OpenWRT). I was interested to know if this extra CPU could be utilized for more intensive tasks that the low powered Atmel couldn't handle - here is how I got it working.

The first step was to identify exactly how to execute tasks on the Linux CPU and exchange information back and forth - the Arduino team have created a mini library called YunBridgeLibrary which effectively uses a proprietary protocol sending commands and data back and forth over a secondary Serial interface (HardwareSerial) on the Atmel CPU.

The examples show how to interact with standard Linux shell commands and services - but what about running your own applications to do complex tasks? For that we would need to compile C/C++ code into native MIPS binaries - using a cross-compiler or, if we can find it, a pre-compiled gcc to use directly on the device (much less work for sure!)

I came across sniff.org.uk's post on how they figured out how to build gcc directly for the Yún - and viola, they even provide a pre-compiled version for anyone to use (160Mb download). Unfortunately, the default file system on SD cards is FAT32 - which if you try to extract the tarball to you will find quickly that it wont support symbolic links = roadblock.

I used Paragon ExtFS for MacOSX to format my SD card to the traditional "ext3" file system - extracted the tarball then inserted it into the Yún; viola, it mounted without any complaints. Alternatively you could also use the tutorial ExpandingYunDiskSpace to do the same and then copy the tarball to the device and extract directly.

  • # copy gccYun.tar.gz to the Arduino Yún
    $ scp gccYun.tar.gz root@ 
    # ssh to the Arduino Yún
    $ ssh -l root
    $ cd /mnt/sda2
    $ tar xzvf gccYun.tar.gz 
    $ ln -s /mnt/sda2/gcc /gcc
    # setup the path 
    $ export PATH=/gcc/bin:$PATH
    # try to start gcc
    $ gcc
    error: no input files

The default password for the Arduino Uún is "arduino" - it is possible (and recommended to change it) but once you have extracted the gcc tarball to where ever your compatible file system is (/mnt/sda1 or /mnt/sda2 - depending on which method you used), set up your path and you should be able to compile your first C program directly on the device itself. The SD card is only required for compilation - you can simply move the compiled programs to the root directory once created (or, put them in their own directory).

Now your native application is compiled - it is time to code an arduino sketch and run it.

  • #include <Process.h>
    void setup()
      while (!Serial) delay(250);
      // run the program
      Process proc.begin("/my_program");
      // show the results 
      while (proc.available()>0) 
        char c = proc.read();
      // close the process
    void loop()

This will effectively execute the command /my_program 123 456 on the device and echo the results of the process on the Serial connection (from the arduino IDE) - of course, you would customize this to your own needs and put the data returned into a format you could utilize and process. With the limited SRAM available on the Atmel side of the device - you may want to consider writing files to the /tmp directory if you need to pass large amounts of data; it will be faster and much more memory efficient.

To give you an idea of performance, the Yún is almost exactly the same as the UNO or Leonardo - it just has this extra CPU. In my RSA 1024 speed comparisons, the difference was staggering - 12682ms verses 707ms for the same C code; this includes the 200-300ms overhead that the bridge library has as well.

So, what do you plan to do with your Arduino Yún now you know how to use that extra CPU?


advertisement (self plug):
need assistance in an IoT project? contact us for a free consultation.


Long live Assembly - cannot beat it for performance.
IoT security - feasibility in micro controllers

All content provided on this blog is for informational purposes only.
All comments are generated by users and moderated for inappropriateness periodically.
The owner will not be liable for any losses, injuries, or damages from the display or use of this information.