Recently, I had a customer who needed an embedded Linux distribution running on an Advantech PCM-9371 single board computer (SBC). The PCM-9371 contains a low voltage Celeron or Pentium III processor. This article describes why the Openembedded build system was chosen and a few tips for running Openembedded on a x86 system.
The hard way!
There are many ways to put Linux on a x86 embedded system. There are hundreds of distributions out there and the temptation is always to do something “quick” and just try to trim down one of the standard distributions. Other shortcuts are often taken, such as compiling your application on a workstation that is running a different distribution and different versions of the libraries used in the embedded systems. This approach can work, but there are many possible pitfalls:
- Several years down the road, it will be difficult to compile applications for your target system as the libraries on the target system are very dated compared to tools and libraries used in standard desktop distributions. What this means is you will need to keep a “golden” compile machine around for the life of your project — not fun! I went through an experience like this on a previous version of this same project where it took us a week to set up a build machine to compile applications using a very old version of Debian.
- It is difficult to gather GPL sources used to build the distribution you are using. You are required to supply GPL source code upon request to customers who purchase your product.
- To build applications correctly, you really need a build machine that is running the same distribution as the target, unless you set up a cross-compilation or scratchbox environment.
- Most distributions are quite large and have difficulty fitting on CF card.
- Most distributions are difficult to customize in a clean, systematic way.
OpenEmbedded
Considering the disadvantages of using an standard x86 distribution for this project, I chose to use OpenEmbedded (OE). The OpenEmbedded project (http://openembedded.org ) is a full featured build system for building embedded Linux distributions. The development is done on a Linux workstation of your choice and the entire distribution is cross-compiled to the architecture of your choice. The entire build process is automated, including building the toolchain and an image that can be installed on the target embedded system. Some of the features of OpenEmbedded are:
- Over 3000 packages that can be built. About anything you would ever need for an embedded system.
- Support for a wide variety of target architectures. ARM and x86 processors are well supported.
- Build system is very self contained. This means you can do the builds on a variety of different host machines. Many of the tools OE needs are built by OE, so there is very little dependence on host tools besides a few basics such as Python, make, and other standard tools. This also means it is much easier to pull the build system out of the archives in several years, load it on a current machine, and do a build.
- All source code used in the build is downloaded, so GPL compliance is easy.
- and the list goes on …
Build and Installation
Setting up an OE build is beyond the scope of this article, but it basically involves selecting a machine and distribution. In this case, I chose the x86 machine and the generic OE distribution. Several hours later, I had an image in the form of a tar.gz file that I decompressed to a Compact Flash (CF) card. After installing grub on the CF card, I had a booting Linux distribution that included all the basics (like ssh, ipkg package manager, shell, standard file utilities, etc) in less than 4MB of disk space.
Adding GTK+ and Xwindows
This system required support for GTK+ and Xwindows. To add this involved running the following commands: bitbake xserver-kdrive and bitbake gtk+. The OE build system then automatically downloaded and compiled the need packages. The image size is now around 20MB — still fits very easily on a CF card.
Getting X running
There are several options for running X on a x86 system. In this case, I chose the quickest way so that my customer could get started with application integration as quickly as possible. Linux and Xwindows support the standard VESA Framebuffer mode. Then can be enabled by selecting the CONFIG_FB_VESA kernel config option. The kdrive version of X can then be started by running Xvesa. In the future, we may move to an accelerated X driver if needed.
Summary
We now have Linux running off of a CF card with full X/GTK+ support and the customer can proceed with integration, testing and application development. Getting to this point took about 1 day of development as we did not encounter any major problems — much less time than it took to resurrect an old build environment used in previous versions of the project. Future work will involve integrating applications into the OE build system, and customizing the distribution as needed. Openembedded has proved to be a very valuable tool for getting embedded Linux systems running quickly and maintaining them in a controlled way.