NOTE: if you’ve already read previous posts of this series, you may find the first part to be repetitive so you can just omit and go directly to the BeagleBone Black title.

What is Buildroot?

Buildroot is a tool that simplifies and automates the process of building a complete Linux system for an embedded system, using cross-compilation.

In order to achieve this, Buildroot is able to generate a cross-compilation toolchain, a root filesystem, a Linux kernel image and a bootloader for your target. Buildroot can be used for any combination of these options, independently (you can for example use an existing cross-compilation toolchain, and build only your root filesystem with Buildroot).

You can see a lot more info in the BR site and BR manual, which is very (very!) complete, explaining many details, with examples and more

About Qt and EGLFS backend

“EGLFS is a platform plugin for running Qt5 applications on top of EGL and OpenGL ES 2.0 without an actual windowing system (like X11 or Wayland).” “This is the recommended plugin for modern Embedded Linux devices that include a GPU.”

In order to use graphic hardware acceleration (i.e. GPU), platform-specific libraries has to be provided. For the BeagleBone Black case, the TI GFX Buildroot package (Graphics libraries for TI boards) will install the proper libraries on the target.

Why Buildroot?

Cross-building a root filesystem can be hard if done manually. This is particularly true when building a complex package such as Qt5. However doing this with Buildroot it’s quite simple!

Buildroot provides a package to install Qt5 on the target device, allowing the selection of various backends (i.e. EGLFS, LinuxFB, XCB). You just have to provide the platform-specific libraries and drivers for you hardware and that’s it.

Anyway, don’t let the simplicity scares you. Buildroot is an ideal tool for developing Open Source BSPs in order to create complex Embedded Linux products. There’s a big and active community behind Buildroot, which is constantly adding new features for almost everything needed. Don’t be shy and subcribe to the mail list, be part of the discussions and start contributing!

Enough talking, let’s do something…

Getting started with Buildroot

The first step when using Buildroot is to get a repository to work with.

1

2

$ git clone git://git.busybox.net/buildroot

$ cd buildroot/

In this post, we’re going to use a specific Buildroot version to avoid any breaking change that could be added in the future. Buildroot tag 2016.02 was successfully tested, so lets create a branch from that.

1

$ git checkout 2016.02 -b bbb_opengles

BeagleBone Black

We start with the defconfig and then access the menu to tweak and enable some options.

1

2

$ make beaglebone_defconfig

$ make menuconfig

We are going to enable the options listed below. Once we are in the ncurses-based menu, we can look for the option pressing the key ‘/’ and entering its name. This will print some information about the option, like its location and prompt.

The TI Graphics libraries (TI GFX) package requires a toolchain based on Glibc with C++ support:

1

2

BR2_TOOLCHAIN_BUILDROOT_GLIBC

BR2_TOOLCHAIN_BUILDROOT_CXX

Install the Graphics libraries for TI boards and some tests/demos:

1

2

BR2_PACKAGE_TI_GFX

BR2_PACKAGE_TI_GFX_ES8

Enable Qt5 package with examples and EGLFS backend:

1

2

3

4

5

BR2_PACKAGE_QT5

BR2_PACKAGE_QT5BASE_LICENSE_APPROVED

BR2_PACKAGE_QT5BASE_EXAMPLES

BR2_PACKAGE_QT5BASE_GUI

BR2_PACKAGE_QT5BASE_EGLFS

Finally we run make (it may take a while… this is where you can prepare yourself some mate). If everything went OK, you should get the following output:

1

2

3

4

5

6

7

8

9

$ make

$ tree output/images/

├── am335x-boneblack.dtb

├── am335x-bone.dtb

├── MLO

├── rootfs.ext2

├── u-boot.img

├── uEnv.txt

└── zImage

Preparing the SDCard

These instructions are pretty good described in: board/beaglebone/readme.txt
Here we assume that SDCard is /dev/sdb.

You need to prepare a first partition in fat32 and marked as bootable, and a second partition where you will write rootfs.

Hey,
I like your guide. The buildroot solution sure looks simple.
Although after following your steps, the beaglebone won’t boot from the SD card.
Do you know of any braking changes in u-boot or buildroot?

Yes, there seems to be an issue when building u-boot with the latest Buildroot version (2016.05). Will check it.
Anyway, this completely breaks the compilation process, so you shouldn’t even got the desired output files at output/images/. You said your board isn’t booting, how did you prepare the SD card? Did you get the required output files?

I’ve built and booted using Buildroot 2016.02 tag with no errors. Could you give a try on that version? I’m modifying this post so it details a specific working Buildroot tag.

Hey,
thank you for your response!
I’ve managed to figure it out:
My first misconception was that I thought I’d get a console output over HDMI. Accessing the BBB via serial fixed that.
Building with 2016.02 gave me the proper files and after repartitioning and formatting both partitions on the SD card I managed to run the qt example without problems.
Thanks alot!

Thanks for writing this tutorial. When i come to run make I get an error:

“You have PERL_MM_OPT defined because Perl local::lib is installed on your system. Please unset this variable before starting Buildroot”

Does this mean I need to set/unset something in the menuconfig? I have searched it for ‘PERL_MM_OPT’ but I cannot find anything. Is there something I need to remove on my host system (running Ubuntu 14.04 LTS and I have perl 5.18 installed).

So I have managed to answer my own question: I re-read the error message and realised myself what the problem was: I have to unset the environment variable PERL_MM_OPT in Ubuntu by running ‘unset PERL_MM_OPT’ – it’s now building

I want to get this working with a custom LCD cape I have connected to my Beaglebone. The cape works with Debian using the bone cape manager but the kernel being used in your tutorial doesn’t seem to have the cape manager included. Do you know a way of adding cape manager support?

I’m not sure Buildroot supports the cape manager, so I can’t say if it’s possible to use devicetree overlays with this setup. However, you can modify the DTS file to support your custom LCD cape and it will work just fine. However, you will have to use BR2_LINUX_KERNEL_USE_CUSTOM_DTS instead of the in-tree devicetree.
Once you have switched to using a custom DTS (you can start by copying the in-tree), just extend it, adding the DT node for your device to the DTS.
If it’s the first time you do this, it be bumpy at first, but it’s definitely doable.

Another approach is to patch the intree kernel devicetree, and do the DTS modification that way.
Either way, your goal is to modify your devicetree adding your LCD device description.

I have managed to do as you suggested and have successfully added by custom cape to the device tree – thanks for your guidance! This has also allowed me to add one of the I2C buses and some GPIO. You were right; it’s a bit of a learning curve at first but I managed to get my head around it.