Last month I introduced the Yocto Project here on Linux.com with the catchy title Getting Started with Embedded Linux and the Yocto Project. But despite the title, there was very little in that post that described just how to get started. I’m here today to rectify that situation.
The best thing to do is to rely on the Yocto Project documentation, starting with the Yocto Project Quick Start Guide. What follows below is a quick distillation of the information in the Quick Start Guide, but it is highly recommended to read the whole document before beginning. Of course, this is only the tip of the iceberg for embedded Linux development.
Use a Linux desktop system as a host. The Yocto Project works best with a major desktop distro like OpenSUSE, Fedora, CentOS, or Ubuntu, but (theoretically) can be made to work with any Linux system. Make sure to install all the necessary packages from the distro’s repository – see the Quick Start Guide for a list (scroll down to The Packages).
wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.2/poky-denzil-7.0.tar.bz2; tar xvjf poky-denzil-7.0.tar.bz2
Alternatively, you can use the following command to get the same release using
git -b denzil git://git.yoctoproject.org/poky.git
In either case, you end up with the Yocto Project build tools, in the form of an instance of the Poky build system. Poky is a reference system for the Yocto Project – it is a working example of the Yocto Project in action.
Create a build directory and set up your working environment correctly with a single command:
source poky/oe-init-build-env build
This command sets environment variables, creates and populates a working directory called
buildas a subdirectory of your current working directory, and makes this new location your working directory. You are all set to build now… almost.
Set up the main build configuration file
conf/local.conffor your build. This is easier than it sounds. Simply edit that file and look for the following configuration lines to change or uncomment. Set threads to 2x the number of cores in your host system – for a quad-core host, for example, this number would be 8. This will greatly speed up your build by taking advantage of all available processor cores.
BB_NUMBER_THREADS = "threads"
PARALLEL_MAKE = "-j threads"
MACHINE ?= "qemux86"
MACHINEsetting specifies a familiar 32-bit Intel architecture with a twist – it is set up automatically to use the QEMU hardware emulator to run your new image without requiring any hardware. Other supported values for this setting are shown in
qemuarmas well as a number of hardware architectures.
Build your distro. Note: this can take a while, as BitBake needs to download all the packages it needs for this build, even though we are just using the minimal system. Depending on the speed of your network connection, this can take between 1.5 and 4 hours. Subsequent builds only take about an hour.
Time to see the results! Boot your new image in a QEMU emulator. After the bootloader messages go past, log in using
root, no password needed.
And that’s it! You have just built and run your embedded Linux distribution. Next month we’ll talk about variations on this process, particularly using the Hob graphical interface. (For those who want to read ahead, type
hob in your build directory.) To see even more of this process in action, check out this video: Getting Started with the Yocto Project – New Developer Screencast Tutorial.
About the author: Jeff “Jefro” Osier-Mixon has been wandering the halls of Linux conferences and embedded and open source software companies for… well, a long time. He works for Intel Corporation and serves as community manager for the Yocto Project. This is the second article in a new monthly series from the Yocto Project on Linux.com.