91³Ô¹ÏÍø

Using Build root to Build an Embedded Linux System for DesignWare ARC Processors

By Mischa Jonker, R&D engineer, 91³Ô¹ÏÍø

Introduction

As more embedded applications start to add features such as connectivity (home thermostats, smart grid technology), audio/video playback, Bluetooth (car radios, A/V receivers), software development costs can rise rapidly.

Linux is an attractive option for embedded systems, providing users with a wide range of ¡°out-of-the-box¡± capabilities; however some distinct challenges have kept it from being used in deeply embedded applications. Aside from the size and cost of Linux-capable processor cores, configuring and building all the components that are required for a complete system can be a difficult task requiring deep knowledge on subjects such as cross-compilation.

Buildroot is an open source project that simplifies this process by automating most of the required steps for you, and in combination with an affordable DesignWare? ARC? core, it can help you reduce development costs and save time when developing your Linux-based embedded applications.

Components of an Embedded Linux System

Typically, embedded Linux systems require the following components:

  • Boot loader, such as U-boot
  • Linux kernel
  • Userland packages that reside on a root file system, for example:
    • BusyBox (Linux command line utilities)
    • Qt (graphical user interface framework)
    • GStreamer (media playback framework)

Figure 1: Typical start-up sequence of embedded Linux systems 

To build these components, you will also need a cross compiler (toolchain).

The boot loader, the Linux kernel, the packages required to build the toolchain and the userland packages are usually located on a plethora of websites or software configuration management repositories. The first step of gathering the required source code for your embedded Linux system alone can take days.

To further complicate things, every use case requires the toolchain as well as all the components to be configured in a specific way . This is especially true in order to achieve optimal system performance.

How Buildroot Simplifies These Steps

Buildroot is a set of Makefiles that automates the building process of your embedded Linux system. It will do the following tasks for you, among others:

  • Download the source code for every package, including Linux kernel and toolchain
  • Apply target-specific patches if required
  • Enable fine-grained configuration of toolchain
    • Allows you to disable features that may not be required, such as large file support, or foreign language support
    • Gives you the opportunity to tune the C libraries for your specific DesignWare ARC processor configuration
  • Resolve dependencies for packages that you need
    • Including the multiple passes required when compiling the compiler
  • Combines all userland packages into a root file system image

Building a Minimal Root File System

To get started, you will need a Linux system with a few packages preinstalled, such as make, git and gcc. For a full list of mandatory packages, please refer to the Buildroot user manual [1].

To download Buildroot with the latest changes for DesignWare ARC Processors, type the following command in a Linux terminal:

$ git clone git://github.com/foss-for-synopsys-dwc-arc-processors/buildroot.git

To configure Buildroot for DesignWare ARC processors, type the following commands:

$ cd buildroot

$ make menuconfig

Figure 2: The menuconfig configuration interface of Buildroot 

You can easily navigate the menuconfig interface, shown in Figure 2, by using the arrow keys, and . The Buildroot system defaults to the i386 target architecture. To create a root file system for the DesignWare ARC family of processors, select the ¡°Target Architecture (i386)¡± submenu, which will bring up the dialog box shown in Figure 3: 

Figure 3: The Target Architecture dialog

Select the desired ARC architecture. This simple step provides Buildroot enough information to get a working root file system with basic Linux command line tools (such as ls, cat, and vi) installed.

Since Buildroot automatically resolves the dependencies, it knows that it needs to build a cross compiler, the C library for ARC little-endian and busybox, which is the package containing the basic Linux command line tools.

To get your embedded Linux root file system you simply need to save the configuration, exit from the menuconfig interface and start the build process with the following command:

$ make

The build takes a few minutes to complete, after which you will have a new directory called output with the following contents:

/build

- The build takes place here and includes unpacked and patched source files

/host

- The host dependencies are installed here

/images

- The file system image(s) are installed here

/staging

- The header files and libraries required for building ARC packages are installed here

/stamps

- This is used for administration purposes to keep track of which tasks are completed

/target

- This is where the target file system and build results for ARC are installed.

/toolchain

- The cross compiler and libraries, including intermediate steps are installed here

Note that while target does contain all the build results (i.e. packages compiled for ARC), it is not your final root file system because a real root file system also includes device nodes. Device nodes can only be generated by the super user (i.e. root). In the images directory, you will find a packaged version of your actual root file system, with device nodes.

Adding Packages, Including Your Own

Most applications will need additional packages inside the root file system. For instance, Qt can be used for building graphical user interfaces (GUIs). This package is added through the menuconfig interface:

$ make menuconfig

Select the options ¡°Package Selection for the target¡± and ¡°Graphic libraries and applications (graphic/text)¡± to get the following screen:

Figure 4: Using the Graphics libraries and applications dialog box to build a GUI

As you can see, it is impossible to select the Qt option right now because the Buildroot menuconfig interface shows that Qt requires a toolchain with C++ support enabled. To enable C++ support, go back to the top level of the menuconfig interface and select ¡°Toolchain.¡±In the Toolchain dialog box, select ¡°Enable C++ support,¡± as shown in Figure 5:

Figure 5: Enabling C++ support in the Toolchain dialog box

After enabling C++ support, it will be possible to select Qt:

Figure 6: Selecting Qt for rich graphics

Before starting the build, exit from the menuconfig interface and save the configuration. Because the configuration of the toolchain itself has been changed (by adding C++ support), it is necessary to ensure that the toolchain will be rebuilt. The easiest way to do that is to start the build from scratch:

$ make clean

$ make

Adding your own files and applications

There are various ways to customize the resulting file system; for instance, you can:

  • Overlay the root file system with your own set of files
  • Let Buildroot execute custom scripts before and/or after creating file system images
  • Add your own packages by modifying Buildroot¡¯s Makefiles

In the menuconfig interface, the first two options can be found in the ¡°System configuration¡± menu:

Figure 7: Using the System configuration dialog box to add your own files

To get your own set of files in your file system, just enter the directory where they are located, and they will be integrated in the file system after issuing another ¡®make¡¯. The Buildroot user manual [1] contains instructions to add your own packages to Buildroot.

Conclusion

DesignWare ARC processors are highly configurable and affordable, making them a good choice to take your embedded application to the next level. As Buildroot automates the configuration and build process of almost every aspect, you will have your embedded Linux system up and running in no time. The combination of Buildroot and DesignWare ARC processors significantly reduce the entry barriers for adding embedded Linux to your application.

The DesignWare ARC processor architecture has been supported in Buildroot since April 2013, and is available upstream [2]. The latest ARC-specific changes can be obtained through the Synopsys GitHub site [3].

References

[1] "The Buildroot user manual," [Online]. Available:

[2] "Buildroot git repository," [Online]. Available:

[3] "Open Source Software for Synopsys's DesignWare ARC Processors," [Online]. Available: