The best thing to do is to rely on the Yocto Project documentation, starting with the Yocto Project Quick Start Guide.
Introducing the Yocto Preject Development Environment
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).
Downloading the Packages
- Download the Yocto Project tools by grabbing the
tarfile for the latest release, Poky 7.0 “Denzil”, from the Yocto Project website download page, or from the command line as shown:
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
Build the Packages
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