OpenGL ES on BeagleBone Black

Home / blog / OpenGL ES on BeagleBone Black

This post is part of a series of posts about using Buildroot to compile Qt5 with EGLFS. We are going to be listing the steps required for several popular embedded linux development boards.

In a previous post we worked with an Olimex Allwinner A20 development board. Now, we will repeat the process on a BeagleBone Black board, which has a PowerVR SGX530 GPU. At the end, we’ll show some examples that can be run on the target to check everything is setup.

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

From the Qt docs:

“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.

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.

BeagleBone Black

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

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:

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

Enable Qt5 package with examples and EGLFS backend:

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:

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.

If everything was OK we should get a similar output to this:

Format the boot partition with:

Copy the files to the SDCard’s boot partition (assuming it is mounted at /media/boot):

Write the rootfs image onto SDCard:

Running Qt5 on target

That’s it, unmount the SDCard partitions, insert the card into the BeagleBone Black and plug in the HDMI – mini HDMI cable to the board.

This should render a 3D Qt logo spinning on the screen connected through HDMI. The logo should be similar to the following one:

Example of the Qt logo show in the HDMI screen

More info about the example can be found here.

Simultaneously, we run top so on the UART console we should see the Linux processes status. The hellowindow process is using about ~10% of the CPU, the rest of the work is done by the GPU.

That’s it?

Yeah, that’s it. Is there any other platform you would like to have Qt5 EGLFS support for? Don’t hesitate to contact us!

Showing 15 comments
  • Michael
    Reply

    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?

    • Ariel D'Alessandro
      Reply

      Hi Michael,

      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.

      Thanks for your feedback!

      • Michael
        Reply

        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!

  • Frank Mertens
    Reply

    How large is the rootfs?

    • Ariel D'Alessandro
      Reply

      Hey Frank,

      Here’s to rootfs size (in bytes):

      $ du -b output/images/rootfs.ext2
      39747584 output/images/rootfs.ext2

      • Frank Mertens
        Reply

        THX.

        Btw. dd if=rootfs.ext2 of=/dev/sdb2 bs=1M is usually faster.

  • Adam Foster
    Reply

    Hi,

    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).

    Thank you in advance for any help you can give me.

    Adam

    • Adam Foster
      Reply

      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 :-)

  • Adam Foster
    Reply

    Hi Ariel,

    Thanks for replying to my previous post.

    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?

    Thank you in advance.

    Adam

    • Ezequiel Garcia
      Reply

      Hi Adam,

      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.

      • Adam Foster
        Reply

        Hi,

        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.

        Thanks again for your help :-)

  • Prem
    Reply

    Is there any option to enable -platform eglfs in this buildroot system. I’m using LCD3 as my display. Now its showing error message ” EGLFS: Failed to open /dev/fb0″

  • Michał Ciołek
    Reply

    Hey.

    Please update your post. Following this instructions, for the current buildroot 2017.05, build error will occur. Eg https://bugs.busybox.net/show_bug.cgi?id=9991

    $ git checkout 2017.05 -b bbb_opengles
    #use predefined configuration with: qt5, ti-sgx-km, ti-sgx-um, eglfs
    $ make beaglebone_qt5_defconfig
    $ make

    That’s all!

    You do not need to prepare sd cards (boot, partitions, etc). Use image sdcard.img:
    $ dd if=output/images/sdcard.img of of=/dev/sdb

    To compile your QT app:
    $ cd your_qt_app
    $ buildroot_path/output/host/usr/bin/qmake YourProject.pro
    $ make

Leave a Reply to Michał Ciołek Cancel reply