Introduction to Buildroot and enabling USB in BeagleBone Black (BBB) [buildroot part-1]

Buildroot is a build system made by bootlin, formerly known as free electron. With buildroot you can build a minimized linux from source and choose which package and service is running in depth and detail.

Edit 25 May 2019: to correcting workflow. Initially we configuring kernel first then buildroot. Apparently it’s better to configure the buildroot first.

Preparation:
In this tutorial we will use this Hardware:

  1. Beaglebone black (also known as BBB)
  2. USB-Serial to connect into serial terminal in BBB using your computer
  3. USB soundcard ( we will try to enable USB driver in buildroot and USB SoundCard driver, so we shall be able to record and play some sound. We also can play some music in *.wav and *.mp3
  4. Speaker and Microphone, it’s obvious that we shall need them to record and play some sound.

Software we will need:

  1. We run Operating System Linux, preferable Ubuntu, I using the 16.04 lts version
  2. buildroot-2018.02.4 you can download this in tarball from bootlin
  3. Look for dependencies needed by buildroot. you can search this dependencies at buildroot manual [link will be here soon]

Let’s get started!

Extract buildroot-2018.02.4.tar.gz at /home/user/ (or any directory you prefer and it should be where your user can read and write also it’s better if your user own the directory. You don’t need and it’s advised to NOT use root user.:
$ tar -xzf buildroot-2018.02.4.tar.gz

When we extract we will have new directory containing the extraction from buildroot-2018.02.4.tar.gz. This directory if you ain’t rename is buildroot-2018.02.4. Let’s go into this directory:
$ cd buildroot-2018.02.4

  1. Preparing the minimum system using available defconfigs

To see every available defconfigs we can call:
$ make list-defconfigs

There every available defconfig will displayed, Yes it’s a lot. let’s filter the defconfig for beaglebone board using grep:
$ make list-defconfigs |grep beagle

there you’ll shall see that for BBB there’s a defconfig for beaglebone. Let’s use it:
$ make beaglebone_defconfig

Now, every configuration is done! if we don’t need much. But, as I promise you, we will activate the USB driver and USB Soundcard driver. For this tutorial is very specific for BBB Board and the Linux kernel version I am using is downloaded from TI with version 4.4.40. I have check using kernel 4.9.xx and there is some slight difference to configure regarding the dependencies.

Configuring the buildroot
In buildroot, to configure the kernel configuration we do make linux-menuconfig, unlike if we directly configure the kernel configuration file we do make menuconfig. In buildroot, if we do make menuconfig, we will configure the buildroot configuration which configure higher layer things like toolchain, rootfs, busybox, bootloader like U-boot and some summary configuration for kernel, also to configure which package will be included. In next section we will configure toolchain and package to include:

$ make menuconfig

Enable Toolchain C++ and wchar:
– Toolchain
– – [*] Enable WCHAR support
– – [*] Enable C++ support

If we edit any toolchain configuration, we will need to run make-clean IF, we ever run make before editing any toolchain configuration. Anyway this toolchain configuration are needed by package alsamixer which we will enable in a minute

If we need to do make clean in buildroot, the kernel configuration will also be erased, so you shall back up the configuration file located in output/linux-<git-hash-number>/.config then you need to restore this .config to it’s former directory before running make. We will cover how to configure backing up and restoring this configuration file in the next part.

Enable alsa-lib:
– Target packages
– – Libraries
– – – Audio / Sound
– – – – [*] alsa-lib

Enable alsamixer
– Target packages
– – – Audio and video applications
– – – – [*] alsa-utils
– – – – – [*]alsamixer

Enable aplay/arecord
– Target packages
– – – Audio and video applications
– – – – [*]alsa-utils
– – – – – [*] aplay/arecord

Enable mpg123
– Target packages
– – – Audio and video applications
– – – – [*] mpg123

exit the menuconfig

The package we enable in menuconfig like alsa will makes it’s easier for us to use an USB sound card. aplay/arecord package and mpg123 package is a wav and mp3 player respectively so we can play some music when the image is running in BBB Board

Configuring the Kernel
As usual, to configure the linux kernel in buildroot we do this command:
$ make linux-menuconfig

First, we shall need to Enable USB:
– Device Drivers
– – USB Support – – – >
– – – <*> Support for Host-side USB

Next we need to enable Root Hub Transaction Translator (EHCI, OHCI, INVENTRA)
– Device Drivers
– – USB support (USB-
– – – <*> Support for Host-side USB
– – – <*> EHCI HCD (USB 2.0) support
– – – [*] Root Hub Transaction Translator
– – – <*> EHCI support for OMAP3 and later chips
– – – <*> OHCI HCD (USB 1.1) support
– – – <*> OHCI support for OMAP3 and later chips
— – <*> INVENTRA Highspeed Dual Role Controller (TI, ADI, AW, …)
– – – <*> TI DSPS platforms

For kernel 4.9 you’ll need to enable USB Gadget and omap (which it automatically done in 4.4.40 kernel configuration.

The sound card:


From here, we already done configuring the kernel for enabling USB with our BBB Board. Next, we will configuring USB Sound Card Driver:
– Device Drivers
– – <*> Sound Card Support —>
– – – <*> Advanced Linux Sound Architecture —>
– – – – [*] USB sound devices — >
– – – – – <*> USB Audio/MIDI driver

Exit the linux-menuconfig.

Create our image:
$ make
We will find the sdcard image in output/image/sdcard.img

If you see something like “Mass storage” while Enabling USB in kernel configuration, That is a driver for Mass Storage like USB Flash Disk or USB Hard Drive. BTW, I already done this maybe I’ll edit this tutorial later. to include mass storage driver in comprehensive.

This is it for part-1, see you in the next part which I will cover for how we can burn the image in SD-card and connect to serial terminal in BBB from our computer.

Feedback and correction is appreciated
See You.

Leave a Reply

Your email address will not be published.