草榴社区

Have Linux Your Way with the Yocto Project

By: Allen Watson, Sr. Product Marketing Manager, ARC Processors, 草榴社区

Introduction

If you have used Ubuntu or Red Hat Linux (RHEL) operating systems on your desktop, you may think of ‘Linux’ as a full-featured operating system akin to Microsoft Windows or Mac OS. Ubuntu and RHEL are examples of a Linux distribution. ‘Linux’ is the kernel software that provides system services, and additional software is needed to make it into the specific distribution that you know and love. In the embedded world where ARC Processors exist, a Linux distribution must be scaled down because of the constrained system resources, such as memory and storage, that are common in many systems-on-chips (SoCs).

Figure 1 - A simplified view of the Linux Operating System

Figure 1 - A simplified view of the Linux Operating System

What is a Linux Distribution?

For a desktop or server Linux distribution, there are five main components:

  • Bootloader
  • Linux kernel image
  • System libraries
  • User applications
  • Toolchain

The bootloader is the first software to run in a system. It gets the system ready to load and execute the kernel. The Linux kernel performs further initialization and includes the device drivers for the hardware. It provides services such as device and memory management. The system libraries contain much of the functionality of the operating system and allow applications and utilities access to the kernel services. User applications are the programs such as a web browser or email applications that we use to perform everyday tasks. The toolchain executes on the target system and is used to build applications and other software, as needed.

In the case of an embedded Linux distribution, there is usually a separate toolchain and build system. These components often execute on a workstation with a different processor from the target processor. The toolchain performs cross-compilation of the software to the target processor.

On the target:

  • Bootloader
  • Linux kernel image
  • System libraries
  • User applications

On the development workstation:

  • Toolchain
  • Build system/scripts

Why You Need a Build System

A build system is key to managing the process of configuring the embedded Linux distribution to meet not just the functional requirements of the embedded system, but also to meet the system constraints of the SoC. Building a Linux distribution involves downloading and building many different software packages from many different sources. Each of these packages may have dependencies on many other packages and the process can become very complex, very quickly. A build system will help you do the following:

  • Resolve the dependencies
  • Get the sources
  • Configure the packages
  • Build, install, and package the result

The build system can also be automated so that you can run nightly builds. 

Build Systems for Embedded Linux

There are three popular build systems for Linux and they all support building a distribution for DesignWare? ARC? processors.

Buildroot

Buildroot can easily configure an embedded Linux distribution. It uses well-known Linux tools and infrastructure such as Makefiles to build a toolchain, filesystem, kernel image, and bootloader. Building a basic system may take just a few minutes.

The main features of Buildroot are:

  • 1800+ packages
  • GUI configuration
  • Small memory footprint on target
  • Supports ARC AXS10x, ARC HSDK, ARC HS Virtualizer Development Kit (VDK), and ARC nSIM Instruction Set Simulator

In many cases, using Buildroot is a good approach. It is relatively straightforward to use with a good selection of packages to choose from. A GUI is used to pick the packages you want and configure the kernel itself. One feature missing is dynamic package management. Buildroot builds a static system that you cannot add to later. In some systems, there may be a requirement to add new software later to change or add functionality. However, in many embedded cases, the system remains fixed and this dynamic feature may not be important.

Once you have installed Buildroot and configured your Linux distribution, you can use the command below to build a Linux distribution for the ARC AXS101 Software Development Platform:

make snps_archs38_axs103_defconfig && make


OpenWrt

OpenWrt is an example of an application-specific build system targeted at WiFi routers. Distributions are available for many well-known commercial routers available in stores. There is also support for ARC Development Systems including the ARC HS Development Kit.

The main features of OpenWrt are:

  • Offers the most powerful and flexible distribution for wireless routers
  • Dynamic package management via opkg (.ipk)
  • Contains 1000+ source packages that are readily available
  • Builds a Software Development Kit (SDK)
  • Supports ARC HSDK boards as WiFi access-point

This system adds flexibility by having dynamic package management, allowing new packages to be added after the original build. However, as stated earlier, the distribution is targeted at WiFi router applications and may not meet the needs of your embedded application.

Here is an example of a command used to build for ARC:

make menuconfig && make

Select ARC HS38 after the ‘make menuconfig’ command runs.


Yocto Project

The Yocto Project is an open source project hosted by the Linux Foundation. It provides templates, tools, and methods to create custom Linux-based systems. Many of the well-known Linux distributions from companies, such as Wind River Systems, are based on Yocto.

The main features of the Yocto Project are:

  • Hosted by the Linux Foundation
  • Use by many mainstream embedded Linux providers
  • Thousands of packages available through layers
  • Supports dynamic package management (.rpm, .deb, .ipk)

This build system is very flexible and easily customizable. The key to the customization capability is its layer model. Each layer contains a related set of instructions (known as recipes) that provides specific functionality. Separating these instructions into different layers allows for reuse of the layers by you and other users. For example, one layer could be a Board Support Package (BSP) layer. This contains information on the hardware. It may be possible to take a distribution and use it on different hardware by specifying a different BSP layer.

However, there is a downside to all this customization potential. The configuration must be done manually through scripts and the learning curve can be steep. But Yocto is the most comprehensive and flexible build system available, and is worth the time and effort to learn how to take advantage of it.


Which Build System is right for me?

The build system you use depends on your level of experience with Linux and how much customization you need. Table 1 below provides you with a cheat sheet:

Figure 2 - A cheat sheet to help choose your build system for Linux

Table 1 - A cheat sheet to help choose your build system for Linux

If you want to get started with Linux on ARC immediately, we provide pre-built Linux images for our development systems. In that case, you do not have to use a build system to get going. All our open source software can be accessed from the web site. Go to the Embedded Linux Project section.

Conclusion

For embedded systems, it is necessary to scale down an embedded Linux distribution to meet the project’s functional requirements to be able to fit within the constraints of the embedded system. There are multiple build systems that can do this and Yocto is a great choice if you need access to a large number of packages and want the level of customization it provides. You also have the choice to use a simpler build system, such as Buildroot, which may fit your needs in a simpler way.

Resources to help you get started

  • Documentation on how to use Buildroot is available .
  • More information on OpenWrt is available .
  • The Yocto Project has a Getting Started Guide .
  • To use Yocto with ARC processors, you can start .