Building an Embedded Linux System with Buildroot

This article intends to walk through the building process of a toolchain and root filesystem for embedded Linux based on buildroot tool.

” Buildroot is a set of Makefiles and patches that makes it easy generate a cross-compilation toolchain and root filesystem for your target Linux system using the uClibc C library. Buildroot is useful mainly for people working with small or embedded systems. Embedded systems often use processors that are not the regular x86 processors everyone is used to using on their PC. It can be PowerPC processors, MIPS processors, ARM processors, etc. And to be extra safe, you do not need to be root to build or run buildroot.”

For conciseness, I’ll not discuss in this article the process of manually building a root filesystem neither how to choose the right filesystem for your purpose. These and many other questions related to how to build an entire embedded Linux System will be answered in another article I’m preparing to this purpose. Syndicate this blog that you will be notified whenever new articles are published. So, let’s concentrate on how to build an Embedded Linux System with Buildroot.

Building the Toolchain

I wanted to work with uClibc, which is about 40% the size of the standard glibc. Therefore, I used the tool release by buildroot.org. This tool builds not only the toolchain but the entire file system as well. You can choose between different kinds of file systems, such as: cramfs, cloop, ext2, jffs2 and squashfs.

Steps for Building of the Toolchain and Root Filesystem

First of all, download buildroot snapshot from here. Once the download finishes, follow these steps:

  1. Change directory to where you downloaded the buildroot tarball, for instance:cd downloads
  2. Uncompress the tarball into a directory of your choice. Just remember that after compilation, you cannot move the buildroot directory to another place different of the full path of the original compilation, i. e., if you compile buildroot under ~/downloads/buildroot. Later, you will break the toolchain if you move the buildroot directory to /usr/local/buildroot. Therefore, before starting, decide where you want to put your toolchain. In my case, I put the buildroot directory under /opt/buildroot:tar -xjvf buildroot-snapshot.tar.bz2 -C /opt (you must have read/write access rights in the directory you want to install buildroot)
  3. Change directory to the new buildroot directory:cd /opt/buildroot
  4. Now, we will start the set up of the toolchain and file system:make menuconfigYou will see a screen like that:

    Buildroot Configuration

  5. The Setup tool is similar to that you’ll find in Linux kernel. The first option on the Buildroot Configuration tool is Target Architecture, i. e., the platform that you’ll work on. The default choice is i386. I’m working on PowerPC platform. Therefore, that was my choice. The other options are: alpha, arm, armeb, cris, i386, m68k, mips, mipsel, nios2, powerpc, superh, sparc, x86_64. Choose one that matches your architecture.
  6. Next step is to set up the build options.

    Build Options

    Usually, you don’t need to change anything here. However, if you have a SMP machine you might choose the option “Number of jobs to run simultaneously” to match the number of processors you have.

  7. The next step is the set up of the toolchain. Pay close attention. This is the most important step because everything else depends on a proper
    toolchain build. So, choose the option carefully. Things you have to keep in mind are the kernel header, binutils version, compiler version and uClibc C library.
    Here are my choices for the current project I’m working on a PowerPC AMC-440EP processor.
    Kernel Headers (Linux 2.6.19.2 kernel headers)
    uClibc C library Version (daily snapshot)
    Binutils Version (binutils 2.17.50.0.7)
    GCC compiler Version (gcc 4.1.1)
    [*] Build/install c++ compiler and libstdc++?

    Toolchain Options

  8. The next step is the “Package Selection for Target”. It’s meaning is what programs do you want in your root filesystem. The programs in this section are subdivided by categories as you can see in the following image:

    Package Selection

    Obviously, the your choices of packages should be ruled by your needs and the size of storage you have on your embedded system.

  9. Now, we are almost at the end of our configuration. In this step, we will choose which filesystem type we want our root filesystem to be built into. The choices are: cramfs, cloop, ext2, jffs2 and squashfs.
    Selecting a filesystem type for your root filesystem is a delicate process. Your decision must to be based on the filesystem’s capabilities and the target’s purpose. Do you need persistent write storage? If not , choose a filesystem like JFFS2 is useless. CRAMFS or SQUASHFS would be a better choice. Furthermore, if your system needs read ans write access to temporary files only, you could have most of its root filesystem mounted on CRAMFS while having its /var/tmp directory mounted on TMPFS or a RAM disk, and its /tmp being a symbolic link to /var/tmp.

    Target Options

  10. The next screen, “Board Support Options” is intend to help you build specific your toolchain and root filesystem for specifics projects, such as wireless access point, firewalling router or, build a development board. The Development Board option practically selects all available packages.

    Board Support Options

  11. Ok, we’re done with the configuration. Select exit to leave the Board Support Options and select exit again to leave the configuration tool. The tools will ask if you want to save the changes. Select yes.
  12. Now that you’re back to the prompt, type make and, <ENTER>. Buildroot will start downloading and compiling all the packages you have chosen. Once it finishes, you’ll have the toolchain in /opt/buildroot/build_powerpc/staging_dir. And, your filesystems will be in /opt/buildroot.
  13. We are almost there. Next, let’s set your environment path. On Bash, edit your ~/.bash_profile file and include something like that:export TOOLCHAIN_HOME=”/opt/buildroot/build_powerpc/staging_dir”
    PATH=${PATH}:${TOOLCHAIN_HOME}/bin

Now, we are done. You have a toolchain that you can use to compile all your embedded application and your Linux kernel for your target.

As I mentioned before, this article explained how to build an uClibc toolchain and root filesystem with buildroot. This choice was done, because buildroot eases the process of building an uClibc toolchain and a root filesystem with busybox and many other programs and libraries.

In the next article, we will consider the why’s of building an entire Embedded Linux System. Stay synchronised.

Advertisement

One Response

  1. please send me how do make embedded linux with build root

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.