Build a custom Linux for your Rasp Pi with Yocto

Creating a New Image

If you want to add the lm-hello program to an image, you need an image recipe. The image recipe is another variant of a BitBake recipe, but it differs significantly. In this case, the image recipe will be named lm-image-minimal.bb, and it must reside below the meta-lm layer in the subdirectory recipes-lm/images:

cd Path/to/poky/meta-lm
mkdir -p recipes-lm/images
vim recipes-lm/images/lm-image-minimal.bb

The contents of the file are shown in Listing 5. The recipe includes the core-image-minimal.bb recipe used earlier in this article. It then inserts another DESCRIPTION before adding the lm-hello package to the IMAGE_INSTALL variable, causing the package to end up in the image.

Listing 5

lm-image-minimal.bb

 

Appending the package to IMAGE_INSTALL highlights one of Yocto's special aspects. With most other tools, the obvious approach would be to append the lm-hello variable to the IMAGE_INSTALL variable with an operator like += or = ... + lm-hello. But this would just confuse bitbake. Instead, you will need a second variable with the _append suffix, whose contents are added to the previous variable value.

After building, the resulting image is then called core-image-minimal-raspberrypi3.rpi-sdimg.

Conclusions

This article introduced you to Yocto, a tool for building custom distributions. Yocto offers far more freedom and control than would be possible with a pre-built distribution. Having said this, these additional features do come at a price of significantly more complexity and overhead.

The Author

Johan Thelin works as a system architect. Over the past 15 years, he has developed embedded systems for various industries including medical laboratories, home automation, security, and automotive. He also wrote a book on the QT basics, as well as one on QML. In his spare time, he organizes the FOSS-North Conference, which takes place annually in Gothenburg, Sweden.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Professor Knopper's Lab – Yocto Knoppix

    The professor sets the stage for Knoppix on an SD card that runs on the Raspberry Pi.

  • Yocto

    The Yocto project gives you all the tools you'll need to build a custom Linux for IoT device.

  • Baking Bits
  • Yocto Project and OpenEmbedded Community Join Forces

    “This kind of massive collaboration is exactly what makes Linux the driving force behind today’s new technology innovations.” said Jim Zemlin, executive director at The Linux Foundation.

  • Gnublin

    Embedded Linux doesn’t have to be rocket science, which the Gnublin board clearly shows. If you want to learn how to read sensors, flip switches, and switch LEDs on ARM Linux, this tiny machine is perfect for your research.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News