Yocto with Nitrogen6X: 5 steps only!

The Nitrogen6X platform is a development system based on Freescale’s i.MX6 processor (ARM-Cortex A-9). It provides many interesting features and connection options packed into the same board which includes a Quad-Core ARM® Cortex A9 processor at 1GHz and 1GBytes of 64-bit wide DDR3 at 532MHz.

The Yocto Project is an open source collaboration project that provides templates, tools and methods to help you create custom Linux-based systems for embedded products regardless of the hardware architecture. It was founded in 2010 as a collaboration among many hardware manufacturers, open-source operating systems vendors, and electronics companies to bring some order to the chaos of embedded Linux development. It is hosted by the Linux Foundation as an open source project providing a vendor neutral collaboration environment, and encouraging community contributions in line with the best practices of the open source development model.

The Yocto build system is a powerful framework for cross-compilation which provides tools and data to drive the build process: from source code to the generation of images to be run on the target platform. The huge recipe set is up to date and it is maintained by the members of Yocto community and vendors which provide commercial support for it.

O.S. Systems provides support for the Freescale’s community driven BSP. We’re contributing to this open-source project to help to bring rock-solid tools and software components to embedded customers using Freescale processors. The Freescale Community BSP supports, currently, 19 boards of different SoC types (i.MX23, i.MX28, i.MX31, i.MX35, i.MX51, i.MX53, i.MX6S, i.MX6SL, i.MX6Di.MX6DL and i.MX6Q) which includes the Nitrogen6X among the supported boards with its full set of features, including WIFI and Bluetooth support and accelerated GPU and VPU.

The whole process of going from source code to a final image to be run on the target platform involves a lot of steps. For example: fetching source code from the original locations, resolving dependencies among packages, extracting source archives, cross-compiling source code, deploying binaries, generating system packages etc. Each of those tasks has its own complications, which are nicely handled by Yocto.

So, enough of theory. Let’s practice! :-)

Step 1: Get the code

To start building software, we need some development tools. The Yocto project provides a handy list that we can use. You can see it at their documentation, click here.

Once all the required tools have been installed, we can proceed to install repo, a neat tool initially developed to help the development of Android. repo is a standalone Python script and it allows us to manage multiple git repositories.

The above commands download the “platform” repository, which contains a XML file that links all the repositories that will be managed by repo.

Once this has complete, we will have the following directory structure in the fsl-community-bsp directory:

README: contains some information about Freescale’s Community Yocto BSP (Board Support Packages).

setup-environment: is a shell script that performs some basic sanity checks and configures the environment to run bitbake, the tool that actually drives the build process by consuming recipes.

sources: directory with Yocto’s source code.

Step 2: Setup the build system

At this point we have everything we need to start the build process. So we can just run:

Environment setup

1

$ MACHINE=nitrogen6x source ./setup-environment build

One of the environment variables used by bitbake is MACHINE, which indicates the target machine we will be building for, so we set it to nitrogen6x. This instructs the build system about the machine we want to build for.

Note that we have “sourced” setup-environment instead of creating a new subshell for it. This part is important because setup-environment sets variables that must be available in the current environment, so that bitbake can use them. The first argument to setup-environment is the build directory. Bitbake will use that directory to store all the temporary files generated during the build process (source files, object files, binary packages etc).

Step 3: Build an image

Yocto provides some standard images by default, which are very useful for daily and development use. The most commonly used are:

core-image-minimal: A very small image usually used for kernel and bootloader development, board bring-up and basic testing of hardware

core-image-base: Console image providing support for most hardware of the board, not including a graphical interface. Among the supported features are audio, Bluetooth and WIFI

core-image-x11: Similar to core-image-base but providing a terminal emulator on a graphical environment. This allows easily testing the X11 system without a full desktop environment

core-image-sato: Desktop environment for more generic use and test

The Freescale Community BSP provides two additional images for demonstration and testing purposes, which are:

If you look at the content of the fsl-community-bsp again, after running bitbake, you will notice that a new directory was created: downloads. That’s the directory where the downloaded source code archives are stored, so that they can be reused if you run bitbake again.

The build process is intensive in terms of CPU and disk usage. Its first run will probably take a couple of hours on a modern multicore machine. Next runs will be faster, since bitbake creates a cache of packages that it builds.

Step 4: Install the built image

After bitbake is finished, we will have our cross-compiled system files in build/tmp/deploy/images. Basically, we have files for the boot loader, system kernel, kernel modules and “rootfs” (the target system’s root filesystem).

For example, after building the fsl-image-gui image, the following files (some are actually symbolic links) in build/tmp/deploy/images are generated:

u-boot.imx: Boot loader

fsl-image-gui-nitrogen6x.sdcard: Partitions and filesystem

uImage-nitrogen6x.bin: Kernel

modules--3.0.35-r36.12-nitrogen6x-20xxxxxxxxxxxx.tgz: Kernel modules

All you need to get your system image running is fsl-image-gui-nitrogen6x.sdcard. You can just write it the an SD card using dd from the build directory, for example:

The <SD device> is something like sdb, sdc etc (check the dmesg output to see how Linux named the device for your SD card).

Step 5: Boot

Once you write the system image to the SD card, it is just a matter of connecting it to the board’s SD slot and turn the board on. You’ll get the system we built from scratch running on your Nitrogen6X board.

As demonstrated by this small tutorial, Yocto is very easy to use and it is able to reduce the complexities of building a full operating system from scratch. O.S. Systems has been working to make the Freescale’s community driven BSP easier to use, a good base for products and a pleasant environment for contributors. O.S. Systems has been working with Freescale and “community” boards, and can help you to achieve the same for your products. It can design a specific BSP with personalized applications for your own needs. If you want more information, please contact us.