How to build a super simple Linux Based Embedded System Using Buildroot

MSys Editorial Dec 31 - 5 min read

Audio : Listen to This Blog.

What’s an embedded system?

An embedded system, in simple language, is designed for a specific requirement. It has its own operating software (or operating system), which is designed or specified by you. The coffee machine and the ID card reader at our office are examples of small embedded systems, but there are bigger ones.

Have you ever thought of building an embedded system with your choice of hardware and OS modifications and software above it? Believe me; it’s not at all as arduous as it sounds. You need a little knowledge of C, Makefiles (compilation process), shell scripting, and a Linux based workstation, before you start. The process involves an open-source tool called Buildroot. You can download the latest version of Buildroot from www.buildroot.org. Consider you need a system with Linux OS running on an ARM processor with serial, Ethernet, Wi-Fi, and USB modules loaded on it. You can get these pieces of hardware assembled from a hardware vendor or an electronics shop, if you ask for evaluation boards.

[Fig: Evaluation board, Lantronix]

The term “embedded” is used to indicate memory size restrictions, as it will be expensive to put a lot of memory into a small device. This creates hardware constraints in embedded systems.

What about the software or operating system to run on this? Let’s have a look into this in the next section.

Buildroot

The executables or software you develop on your PC will usually be only for its own hardware configuration (i.e., x86-based), but our target device is different in this case (i.e., ARM). If you have only one file, we can compile it with hardware specific flags in gcc, but what if we have thousands of files? How to build all the files for a different hardware configuration? Here comes Buildroot into picture.
Buildroot is a cross-compilation environment. It provides all the options to compile and build software for specified target hardware. Basically, it’s a cross-compilation platform to generate an image according to the required architecture.

Buildroot Configuration

As I mentioned earlier, you may download Buildroot and untar it. In Command Prompt, change the directory to the untared folder and issue “make menuconfig”. (You may be asked to install a few GNU-based packages on your host system to support the GUI of Buildroot; install them.)

Here it goes; you can see a graphical interface as below.

[Fig: Buildroot Main Screen/ Menuconfig]

Go through the options, select target hardware or processor in “Target Options” menu. A snippet to select ARM processor is shown below.

[Fig: Target Selection]

Linux Configuration

One of the most important things to remember is the target hardware is different from our host. So, the same Linux OS running on your PC won’t run on the target hardware. We have to specify the Linux kernel as shown below.

[Fig: Linux Selection]

Once the kernel is downloaded and untared to a directory, you can change to that directory and issue the command “make linux-menuconfig”, to build the Linux OS and select the configuration options. Usually, you can specify the path to save the configuration.

Now the “make” from the top directory (i.e., Buildroot) will give you the compiled Linux kernel, which gives you a kernel image in uImage format or one of your choice. Final Linux binary comes around 2MB of size.

Busybox configuration

OK, we got the kernel now, but have you wondered how Linux commands will be included to the target device? Who will put them into the device? The commands like “ls”, “ifconfig” etc., come with Busybox, which is a software package that provides lite Unix commands. Like Linux, we have to download and configure Busybox. You can change into Busybox directory and configure the stuff needed. Remember, this is an embedded device, and every “bit” matters. So you cannot have all the commands installed over it.

Package selection

As I mentioned repeatedly, because of memory constraints, Busybox selects lightweight commands only—low memory size. They can provide basic functionalities. You may also require a few advanced commands, such as “tar”. The Busybox version doesn’t support “-z” option, but a full version supports that. So you have to select the full target package, not the one which comes with Busybox.
Think something like a dhcpv6 server on your target device, but it doesn’t come with Busybox by default, as it’s not a basic requirement. That command may be incorporated on the device by including it on the “Package Selection” menu. You can select “wide-dhcpv6” package under Networking Application to achieve this.
Like this, you can go through the entire menu and get whichever package you need for your target.

Target selection

You can select the folder structure on your target device, like /bin, /tmp/, /usr, etc.

Final Image

A “make” from the top directory will build the kernel image and root file system image for you.
You can get the images at the “topdir/output/build/images” path. Then, you can transfer or load images by following the process mentioned below (or the evaluation board manual).

    • Use conventional method like “tftp” to flash images into the device.
    • Alternatively, use serial download to load the images to the device.
    • If the board is fresh without any loaded binaries, you can use a “flash programmer”, which loads the binary at starting location of the flash.

Sounds easy, right? I am here to read your reviews and comments. Please feel free, also, to voice your doubts.

Leave a Reply

At MSys, we provide multiple embedded application development services. To learn more, download our brochure