Embedded Linux Development in 6 Easy Steps


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.

Yocto LogoThe 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.

  1. 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).

  2. Download the Yocto Project tools by grabbing the gzip-ed tar file for the latest release, Poky 7.0 “Denzil”, from the Yocto Project website download page, or from the command line as shown:

    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:

    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.

  3. 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 build as a subdirectory of your current working directory, and makes this new location your working directory. You are all set to build now… almost.

  4. Set up the main build configuration file conf/local.conf for 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"

    The MACHINE setting 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 conf/local.conf, including qemuarm as well as a number of hardware architectures.

  5. 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.

    bitbake core-image-minimal

  6. 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.

    runqemu qemux86

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.