Edoardo Barbieri
on 25 April 2022
Embedded Linux project: Yocto or Ubuntu Core? [Part I]
Welcome to this mini blog series on Yocto vs Ubuntu Core for your embedded Linux project.
Throughout this series, we will diligently assess the key considerations when choosing the OS of an embedded Linux system. We will also analyse the pros and cons of the most widely-adopted Linux-based distributions for embedded devices. Finally, we will offer a critical stance on how developers can focus on their value-add software and get to market fast.
Here you are in Part I, right at the journey beginning. We will start with the basics and offer a quick intro to Yocto. We will mention some foundational considerations for adopting Yocto for your embedded Linux project and quickly skim through its inner constituents: recipes, layers, and BSPs.
If you are already familiar with Yocto and do not wish to refresh your memory, jump to Part II. In the second blog post of this four-part series, we will review Ubuntu Core for your embedded Linux project. We will discuss what’s behind Ubuntu for embedded devices, the role played by snaps, and introduce the App Store.
Part I and Part II will set the stage and provide the necessary context to appreciate the direct comparison between Yocto and Ubuntu Core in the concluding chapters of this mini-series. We advise you to go through them in order, in that they will provide you with the building blocs to have an informed opinion when comparing the two solutions later on.
“Embedded Linux: make or buy?” will be the theme of the third chapter of the series. Part III will discuss the buy vs build or commercial vs roll-your-own debate that will inform the final assessment. In Part III, we will examine the requirements left unattended by community contributions. We will also evaluate how embedded Linux vendors aim to fill those gaps by offering commercial support.
Part IV is the concluding chapter of the series. The final assessment will thoroughly compare Yocto and Ubuntu Core in a 1:1 review across several dimensions. We will directly contrast them on the most pressing challenges facing any developer working on an embedded Linux project: board bring-up, maintenance, updates, security, and many more.
With so much to cover, let’s dive straight into Part I.
Embedded Linux project
Despite appearing in multiple shapes and forms, embedded Linux systems are widespread across virtually every technology segment. From being open-source to scalability, developer support, and tooling, myriad reasons justify why Linux is the perfect candidate for your embedded appliance. Before diving deep into Yocto and Ubuntu Core, let’s align expectations around what constitutes an embedded Linux project. We will define an embedded Linux device as a resource-constrained hardware and software system whose software runs on top of the Linux kernel to perform a dedicated function.
Whether or not an embedded device grants the usage of Linux is a valid concern, as a full-blown OS may be too bloated for some basic embedded projects. Embedded developers need to assess the right time to run Linux, an RTOS, and when it is best to rely on custom bare metal and not use an OS for their embedded project. Intuitively, a more complex OS requires more expensive hardware to run on, and the latter consumes more power. If an embedded application demands a device to run for a decade on the same battery, Linux may not be the most suitable option. For instance, handheld devices may not run Linux due to their limited battery life, and similar considerations hold for embedded systems with stringent real-time requirements. On the other hand, modern embedded devices requiring advanced connectivity and driver support are better off running Linux.
Overall, developers need to pay close attention to cost, power efficiency and application requirements when working on an embedded Linux project.
Yocto for your embedded Linux project
So let us assume you have chosen Linux for your embedded project. You will likely consider Yocto as a potential candidate in that it is among the most well-known solutions. The Yocto Project is a popular open-source collaboration initiative that helps developers create a custom Linux distribution for their embedded applications.
Among the go-to platforms in the industry and benefiting from broad silicon vendors’ support, Yocto outputs a root filesystem image, a kernel, a bootloader, and a compatible toolchain for the target device.
To get the developers up and running, Yocto provides blueprint root filesystem images for typical Linux OS stacks, as per the screen capture below. For instance, core-image-minimal-initramfs.bb is the most basic configuration allowing a device to boot with a Linux kernel comprising a RAM-based filesystem, whereas core-image-full-cmdline.bb adds CLI tools (e.g. bash, acl, attr, grep, sed and tar) to the initial root filesystem.
Developers can then create their custom distro by extending the provided images.
Recipes for your embedded Linux project
Yocto is extensively configurable and provides developers with control over every stage of compiling and building the target. The concept of recipes, i.e. metadata files specifying how to build a particular software package, helps clarify how Yocto achieves this flexibility. By defining builds in recipes, Yocto keeps configuration information in logically-grouped stanzas. The screen capture below offers a snapshot of part of a recipe’s standard layout.
The initial descriptive metadata provides generic information about the recipe and where the software package it builds is hosted. After the licensing (LICENSE and LIC_FILES_CHKSUM) and package manager (SECTION) sections, recipes describe the build dependencies in the DEPENDS metadata section, including the corresponding package names (PN) and versions (PV). Also shown below is where Yocto will download the source code and patches (SRC_URI).
Not shown above are the remaining metadata sections, whereby recipes describe how to create the packaged software bundle after the build and provide the runtime dependencies.
Layers and BSPs for your embedded Linux project
Yocto provides a high degree of configurability to the end-users also via layers, community-maintained recipe collections to support new boards, architectures, and application stacks.
Yocto configurations can efficiently scale as the layers dictate a strict separation between the build core, the board support package (BSP), and custom changes. Indeed, Yocto provides BSPs as metadata layers tailored to a specific embedded board with edits to the underlying layers to support the target hardware. Whereas this is great for adoption and several silicon vendors have BSPs based on Yocto, their maintenance is often painful because of the added packages and modifications to the underlying layers. As Yocto ties each BSP version to the layers it depends on, developers must update the BSP whenever an underlying layer changes, e.g. when dropping support for a particular kernel version or after a new release.
A generic BSP layer layout resembles the one captured in the screenshot below on the left, with the README file in the top-level directory describing the BSP and the target hardware. The recipes subdirectories are specific to the BSP and the supported hardware. For instance, recipes-kernel hosts configuration files about the Linux kernel, whereas recipes-graphics includes configuration recipes for display support and specific graphics requirements.
The layer configuration file layer.conf and its dependencies live in the /conf subdirectory of the BSP layer. Also under /conf are the machine configuration files, as shown in the second screen capture below. By describing the architecture and hardware features, the machine definition helps distinguish a BSP layer from a regular layer.
Final considerations for your embedded Linux project
From the quick recap above, Yocto is versatile for a wide range of embedded systems. It also benefits from industry-wide support by embedded Linux software and commercial chip vendors of ARM, MIPS, PowerPC and X86 architectures.
Not only does the Yocto Project include several blueprints for typical Linux OS stacks, but developers can also craft embedded distributions from scratch. Recipes, layers and BSPs are a powerful combination for those who wish to control every stage of compiling and building a custom distribution for their embedded Linux project from upstream source code.
By providing extreme flexibility, Yocto invariably exposes a spectacular amount of complexity to the end-user. Developers often face a particularly steep learning curve before mastering the build process in Yocto and being able to generate a working image.
However, embedded Linux development doesn’t have to be so complicated. Jump to Part II to find out how Ubuntu Core provides developers what a do-it-yourself Linux distro cannot give them: a faster time to market, and tested and trusted security and update strategies.
Further reading for your embedded Linux project
Want to go back to the basics? Find out what is embedded Linux.
Why is Linux the OS of choice for embedded systems? Check out the official guide to Linux for embedded applications in whitepaper or webinar form.
Interested in a hearing a detailed comparison of Yocto and Ubuntu Core? Watch the latest webinar on-demand here or download our Yocto vs Ubuntu Core CTO’s comparison guide.
Do you have a question, feedback, or news worth sharing? Join the conversation on IoT Discourse to discuss everything related to the Internet of Things and tightly connected, embedded devices.
Yocto Project and all related marks and logos are trademarks of The Linux Foundation. This presentation is not, in any way, endorsed by the Yocto Project or The Linux Foundation.