Thursday 15 September 2016

Yocto for Intel Compute Sticks



Most 'end-users' of 'consumer' products like the Intel Compute Stick who want to either use or at least try a Linux OS will often pick Ubuntu. However given the limited hardware configurations of affordable mini PCs, performance may not be optimal with resource hungry distributions. In the world of embedded systems rather than use a 'proprietary' Linux distribution typically the operating systems are developed from Linux build systems like Yocto, OpenEmbedded, Buildroot and OpenWrt etc.

Unfortunately trying a Yocto Linux build on an Intel Compute Stick is not necessarily that straight forward. It is probably too daunting for most owners to build an initial image just to see what Yocto is all about and most images available for download don't include key drivers or simple installation instructions.

So I've created a Yocto ISO with documentation specifically for Intel Compute Sticks to provide a very basic Linux operating system with wifi and audio support together with the capability to install some additional packages including the Chromium browser.

The ISO can be used either as a LiveUSB or to install Yocto. As the standard installation is to overwrite the entire storage device (i.e. no support for dual booting) I also provide a script to install to pre-existing partitions. The rationale being that you can temporarily replace a current Linux installation (for example Ubuntu) with Yocto and then replace it with the previous Linux installation without affecting any other installed operating systems like Windows etc. As booting the ISO directly on Baytrail models is extremely slow (once booted it works fine) I also provided a script to directly install to the device rather than try to use the LiveUSB approach. Finally I provide some templates to build a repository to allow updates (package installation) from another PC acting as a web server. I also provide the packages which can be installed from the web server or directly if preferred.

Let's get started.

First download my Yocto ISO 'core-image-sato-ics.iso'.

To use as a LiveUSB write the ISO to a USB using the 'dd' command. You can also use the LiveUSB to install from the GRUB boot menu or you can install using one of my installation scripts. For the later option download either 'make-install-mmcblk0.sh' or 'make-install-partition.sh' and copy this to a USB along with the Yocto ISO 'core-image-sato-ics.iso'. On a different USB download and write one of my latest Ubuntu ISOs for the Intel Compute Stick using the 'dd' command and boot your Intel Compute Stick using the Ubuntu LiveUSB. Once booted insert the other USB with the Yocto ISO and install script and change directory to where these files are. If you are installing to existing partitions use the 'lsblk' command or similar to confirm which partitions should be used in the installation. Alternatively you can make new partitions specifically for the Yocto installation. The script assumes that three partitions are available: one each for boot, the root file system and swap. Edit the script to ensure the correct partitions will be used (or modify the script as required). Then run the installation script as root/sudo and reboot your Intel Compute Stick to run Yocto.

Next create a web server on another Linux PC. It is really simple and easy to do. Chose a name for your Yocto repository web server (e.g. 'archive.linuxium.com.au'). Download my documentation/script to create the web server 'make-repository-server.sh' and replace all the occurances of the string '<repo.website.name>' with the name you chose. Now download the compressed Yocto repository 'yocto.7z'. If you are happy to 'rcp' this file to your Yocto repository web server you need to edit 'make-repository-server.sh' and update '<user@ip-address>' as appropriate or you can just delete these lines if you want to manually copy the file over after the next step. Now you can either manually run the commands in the file 'make-repository-server.sh' or run the file as a script and in both cases do so as root/sudo.


The next step is to set up wifi on Yocto. This is probably the hardest step as it involves configuring wifi from the command line and it will depend on your individual environment. If initially you don't feel confident enough to attempt this or in the worst case can't get it working then using a USB ethernet dongle is a quick and simple work around. Whilst there is a lot of information on the web on configuring wifi to help I've included some example files and a script to show how to set up a WPA2 wifi connection with a static address on a hidden network because this is probably the hardest to configure. Download onto a USB the following '_etc_network_interfaces'; '_etc_wpa_supplicant.conf' and 'start_wifi.sh' files. Edit  '_etc_network_interfaces' and for a static address update the IP address details or for a dynamic address change 'static' to 'dhcp' and delete the remaining lines. Copy the file to '/etc/network/interfaces' as root/sudo on your Intel Compute Stick running Yocto. Next run the command 'wpa_passphrase' to get your wifi network pre-shared key (psk). Update the file '_etc_wpa_supplicant.conf' with your wifi name and your psk and change the rest of the parameters according to your wifi network requirements (hint: google 'set up wpa_supplicant' with 'wep' or 'wpa' if you get stuck). Once finished copy the file to '/etc/wpa_supplicant.conf' as root/sudo. Finally run the script 'start_wifi.sh' on your Intel Compute Stick running Yocto. Hopefully this will start your wifi connection.

Once wifi is working (or ethernet if you cheated!) you can now set up access to your Yocto repository web server. As root/sudo edit the file '/etc/hosts' and add a line at the top with the IP address of your Yocto repository web server and its name (e.g. 'archive.linuxium.com.au') similar to how 'localhost' is defined. Now download the  file '_etc_apt_sources.list' and replace all the occurances of the string '<repo.website.name>' with the name of your Yocto repository web server. Then copy the file to '/etc/apt/sources.list' as root/sudo.


Having set up wifi (or ethernet) and your Yocto repository web server you can now update your packages and install new ones. I've built Yocto to use the Debian package manager so it is familiar for existing Ubuntu users. First update your sources as root/sudo with the usual 'apt-get update'. If you want to install Chromium simply enter 'apt-get install chromium'. You can also use 'apt-cache search' to see what other packages are available.

The performance of Chromium is very good on the basic 'Ubuntu' Intel Compute Stick (STCK1A8LFC) and allows you to watch 1080p YouTube.


Hopefully my ISO appeals as a primer for Yocto and similar building tools and encourages some to experiment further.

Acknowledgements: Yocto Project, OpenEmbedded, Emutex, O.S. Systems, Pierre-Louis Bossart and Bastien Nocera.

1 comment:

Sateesh said...

Hi

I am interested in building yocto image from scratch. Is there a repo I can get access to, perhaps?
thnx

Post a Comment

All comments now moderated so that spam can be deleted.