As soon as I got my hands on the YUN I found the selection of packages lacks many interesting pieces of software that could help building interesting appliances. I think Arduino people selected those packages that would easily fit in the minimal 64MB flash.
So first of all I formatted a 4GB mini-sd as ext3 and plugged it in to the mini, it was recognized as /dev/sda1, so I quickly added an /opt folder and mounted in there instead. Now I have plenty of space to add my custom packages, and some "secure" disk space just in case I have to wipe my YUN loosing all flash content.
Resetting the YUN flash is done by holding the reset button for 30 seconds. Holding it for 5 just resets the WiFi config.
Then I spent some time to collect all the information needed to setup our own buildroot for the YUN, here you can find a few tips to do it yourself.
As I'm on a Mac, it is wise to use a VirtualBox machine (save you lots of headaches), with the latest Debian stable distribution.
What's a buildroot
The Arduino YUN is based on a Linux distribution called OpenWRT, which is mostly used to mess with wireless and network routers, liberating them from a proprietary firmware and adding many interesting features.
In order to build such firmware, you need to build a cross-compiling toolchain first, a Linux kernel, and the core programs needed by any Linux systems.
For making it easier OpenWRT people, did set up a Buildroot, or a set of scripts and makefiles which do just this in a confortable way, also using ipkg, a clone of Debian's dpkg to easily install packages when the system is setup. The system is based off OpenEmbedded which I was using long time ago to hack Sharp Zaurus.
Arduino made a good choice to base their new Arduino YUN off OpenWRT, as it has a huge following and is quite nice build environment to work with.
A nice intro on OpenWRT build root is available on this forum post.
Getting the source
First of all you should clone the Arduino YUN buildroot sources, available from github.
git clone https://github.com/arduino/linino.git linino
This will checkout the OpenWRT buildroot with specific Arduino YUN modifications
Prerequisites
In order to successfully compile the builroot you'll need a few packages installed: for Debian Stable you can easily get them by running as root (or with sudo)
apt-get install subversion build-essential git-core libncurses5-dev zlib1g-dev gawk asciidoc \
bash bc binutils bzip2 fastjar flex g++ gcc util-linux zlib1g-dev libncurses5-dev \
libssl-dev perl-modules python2.6-dev rsync ruby sdcc unzip wget gettext xsltproc \
zlib1g-dev libxml-parser-perl
I've included a few you might already have installed, just in case someone had removed them, it won't hurt anyway to put them on the command line.
Disk usage and Network connection
You should make sure that you have enough disk space before starting the build process. It won't be nice to leave it building and find out the process stopped since you did run out of space, please consider at least 10GB to be safe.
Also make sure to have a decent internet connection on, since the buildroot system will need to fetch lots of data from the network.
Configuring the kernel
Once you're done with prerequisites go on to configure the kernel:
cd linino/trunk
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
If all the steps above have been done correctly you will be presented with a familiar menu, similar to the standard Linux kernel build. Go on and select the kernel modules, and packages you want to build.
Once you exit you can compare with diff the generated config with the one available on the Arduino YUN package repository, this should be located at http://download.linino.org/dogstick/all-in-one/latest/build-config.txt.
EDIT: If you want to keep the same config and packages getting built by Yun developers, also do:
./scripts/feeds uninstall -a
rm -rf feeds
./scripts/feeds update -a
./scripts/feeds install -a
rm -f .config
git checkout .config
make oldconfig
Build it
Now you can just run make to start the build process, get a cup of coffee, or several considering it needs to fetch many packages i.e. the Linux kernel and build lots of stuff.
make V=s
Please note that using the V=s param switches on verbose output. If you like you can add -j4 or -j8 depending on how many cores you configured on your machine or VM to speed things up a little.
At the end of the process you should have images ready to be uploaded via TFTP (I'm currently investigating how), and a complete cross-compiling toolchain to test out new packages, and eventually package and contribute them to the offical repository.
Have fun!
Troubleshooting
If the build stops for some reason please check
- you have enough free disk space
- you have installed all the prerequisites
- you are using the correct config, when in doubt copy over the one downloaded from the dogstick site
Changelog
UPDATED 2013-09-16: I added instructions got from the Arduino forums allowing to keep the original Arduino make config
Comments !