Build a custom embedded Linux system using buildroot


In this post I build a custom embedded Linux bootable CD that I can run in an x86 VM. I would like to appreciate the help I received from the official documentation.

Obtain buildroot

Get buildroot. I use version 2011.02 in this post. My build machine is a Virtual Box VM running Ubuntu 10.04 LTS. I have Virtual Box Guest Additions installed, which I use to access a shared folder on the host OS, to get files in and out of the VM (I could probably use a raft of different things to do this but I find this setup painless).

To configure buildroot you require several tools to be present, make is one, but most Linux installations have that already. You’ll probably need to apt-get a few things along the way. You’ll will certainly require ncurses, which can be obtained as follows:

sudo apt-get install libncurses5-dev

Configure buildroot

To configure buildroot you need run make menuconfig in the folder you extracted it. Here’re the options I use:

  • Target architecture – i386
  • Target architecture variant – i686
  • Kernel – Kernel version: 2.6.37.2, Kernel configuration: Using a defconfig, Defconfig name: i386
  • Target filesystem options – ext2, iso image
  • Bootloaders – grub

Exit and choose to save the configuration file.

Build

Run make once you are done saving the buildroot configuration. The build process takes some time because it downloads lots of different things required to build the toolchain, Linux kernel, and the root filesystem. Go and have some coffee. You can speed up the build process by setting up the Virtual Box VM to use multiple cores on the host PC, and allowing buildroot to run as many jobs as you have cores (default setting is 2). This is done using make menuconfig at Build Options, Number of jobs to run simultaneously. Using multiple cores can be buggy, I have had my VM freeze several time, so use it sparingly.

Run embedded Linux

Copy the iso file rootfs.iso9660 from the output/images folder to the host machine as rootfs.iso. Create a new Virtual Box VM and set the iso file as the CD/DVD drive. Start the new VM. If all goes well (it won’t) you’ll get the login prompt where just typing root should let you in to the command line. This first time you’ll not be able to get in because we did not configure the Linux kernel for the ext2 filesystem. Let us see how to do that now.

Configure the Linux kernel

You have built once and all kernel sources should be available at the folder output/build/linux-2.6.37.2. The kernel build configuration file .config is located in that folder. To change that configuration we’ll need to do two things – modify the linux configuration using make linux-menuconfig, and modify the buildroot configuration for the kernel to use that configuration file during the build.

To modify the Linux configuration, invoke make linux-menuconfig from the buildroot root folder. Head over to File systems and select Second extended fs support. Exit and save the configuration.

To modify the buildroot configuration to use the new kernel configuration, execute make menuconfig. Head over to Kernel, Kernel configuration, and select Using a custom config file. Change Configuration file path to output/build/linux-2.6.37.2/.config. Exit and save the buildroot configuration. Build, copy the resulting iso file to the host OS and run the test VM. You should now be able to log in as root.

Next steps

Now, you can modify your custom embedded Linux kernel to support other devices you’ll need, deploy it to hardware… sky’s the limit!

Kudos: Fabio Urquiza at cesar.org.br

11 thoughts on “Build a custom embedded Linux system using buildroot

  1. Thank you! The buildroot documentation doesn’t make it clear that you need to do this if you don’t just want the linux defconfig. Suspected this was the reason my network driver wasn’t getting compiled. :)

  2. Hello! I did the procedures as described in the text, but when i tested on VirtualBox, the system stop in the follow message: “ip used greatest stack depth: 6032 bytes left”.

    You can help me?

    Sorry if you don’t understand my write in English, i’m from Brazil.

      1. Hi Devandra!

        Thanks for your reply! I seen the message and my problem is same but not have solution reported in next threads. If possible, you can make the same procedures with the new Build Root version and report the results?

        Thanks for help me!

  3. Hello Devendra!

    I discovered how to solve the problem! Is necessary changing the directive “System configuration” => “(ttyS0) Port to run a getty (login prompt) on” from ttyS0 (default) to tty1.

    With this changes, the system is booted correctly.

    Thanks for help-me!

  4. hey!! I got every process right….but it does not show login prompt at last.
    it stops there only…at last point
    input,hidraw0:USB HID v1.10 mouse [virtual USB Tablet] on usb-0000:00:06.0-1/input0
    what is wrong hapenned?

  5. So, whenever we want to install any driver in our custom Linux we have to make all the buildroot again right? And then copy the new filesystem for our SD card right? Is there any other kind of solution not so complex? It’s just because I’m full of coffee and all this waiting process kills me :D

    1. It depends. If you’re rebuilding the Kernel with static modules only, copy just the Kernel image to the boot partition. If you’re rebuilding Buildroot and packages you’ll have to copy/untar the root filesystem as well. It usually doesn’t take very long. With some experience and planning you’ll avoid having to do it very often.

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 )

Google+ photo

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

Connecting to %s