Compiling u-boot for the BeagleBone Black and Octavo Systems OSD335x

If you have created your own design based around the BeagleBone family, then one of the issues you may well encounter is trying to boot your board with u-boot with a blank EEPROM and the standard method of creating a complete system as described in the BeagleBone Black page may fail.

As part of the boot process, u-boot will read the EEPROM fields (see the article on the EEPROM) to determine the bard type for configuration.

If your EEPROM is blank, u-boot will not be able to read the board ID and therefore will not boot. At this point you have two main options – hard coding the ID or recognise a ‘blank’ EEPROM, but both of these involve compiling your own version of u-boot.

Pre-Requsites for compiling u-boot

In order to compile u-boot, you will need:

While it is easier to have one of these running on dedicated hardware, I have managed to compile u-boot on a virtual machine as well.

ARM GCC Toolchain – Linaro

While you could compile your own version of gcc and toolchain, it is far easier to make use of a pre-built one. This however only runs on 64bit Linux (if you are still on 32bit, now is a really good time to upgrade your system!)

Download the toolchain

I like to keep all of my tools in a seperate directory of ~/tools so you may need to modify the following commands for your own preferences and environment.

cd ~/tools
wget -c https://releases.linaro.org/components/toolchain/binaries/6.5-2018.12/arm-linux-gnueabihf/gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf.tar.xz

Extract the toolchain.

tar xf gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf.tar.xz

Define the Cross-Compiler prefix

This is used to allow the x86 version of GCC and a toolchain version of GCC to co-exist on the same system and still be uniquely identifed.

export CC=`pwd`/gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-

Note the trailing – I have lost count of the number of times when I am teaching, that people don’t notice the trailing dash.

If you look in the directory `pwd`/gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf/bin/ you will see all of your familiar tools but with the arm-linux-gnueabihf- prefix

Test the Toolchain

Ensure you can run the toolchain GCC

${CC}gcc --version
arm-linux-gnueabihf-gcc (Linaro GCC 6.5-2018.12) 6.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Note: you will need to set the CC environment variable for each new session. If you are using the toolchain often, it would be worth putting it into your ~/.profile – but change `pwd` to the top level directory where you installed the toolchain.

Das U-boot

Downloading u-boot is just cloning the git repository. Again, I like to keep my working directory seperate, so will create a ~/wip (Work In Progress) directory.

Clone u-boot

git clone https://github.com/u-boot/u-boot
cd u-boot/
git checkout v2019.04 -b tmp

Download and apply the patches

wget -c https://github.com/eewiki/u-boot-patches/raw/master/v2019.04/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
wget -c https://github.com/eewiki/u-boot-patches/raw/master/v2019.04/0002-U-Boot-BeagleBone-Cape-Manager.patch

patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
patch -p1 < 0002-U-Boot-BeagleBone-Cape-Manager.patch

Decide which method to use

At this point you need to decide which method you want to use to – hard coding or recognising a blank ID

Hard Coding the Board ID

This is the simplest option, but is only suitable if your design is very close to the BeagleBone that you will claim to be. Also, if you want to change your identifer, you would need to compile a new copy of u-boot.

In your u-boot source code, find the file ./board/ti/am335x/board.h as this header file contains the tests for each board type. To force a particular board type, simply return ‘1’ from the relevent function.

To force u-boot to always use a BeagleBone Black for example:

static inline int board_is_bone_lt(void)
{
//      return board_ti_is("A335BNLT");  -- Hard code board ID to BeagleBone Black
        return 1;
}
            

Recognising a blank ID

The other option is to modify u-boot so that if it finds a blank EEPROM, it will assume it is a blank BeagleBone Black.

wget -c wget -c https://github.com/RobertCNelson/Bootloader-Builder/raw/master/patches/v2019.04/0003-NFM-Production-eeprom-assume-device-is-BeagleBone-Bl.patch
patch -p1 < 0003-NFM-Production-eeprom-assume-device-is-BeagleBone-Bl.patch

This will then also make u-boot look for a file /boot/.eeprom.txt which it will then read the variables to program the EEPROM.

Build u-boot

At this point you can now continue to compile u-boot. In your u-boot source directory:

make ARCH=arm CROSS_COMPILE=${CC} distclean
make ARCH=arm CROSS_COMPILE=${CC} am335x_evm_defconfig
make ARCH=arm CROSS_COMPILE=${CC}

This should create the MLO (Secondary Program Loader) and u-boot.img, as well as tools/mkimage which can be used to program the EEPROM (see the article on the EEPROM)

Install u-boot

You can now continue with the installation as described in the BeagleBone Black page (skipping the first section on the Bootloader, as you have just done that!)