September 26, 2016

Building U-boot

Lots of versions are available for download, or you can fetch the latest sources using git. New designated versions come out about every 2 months. The latest is 2016.09. I am going to work with 2015.10.

Once you get the source tree unbundled, the trick is figuring out how to build for the BBB. To cut to the chase, the vital thing to know is that you want to use the configuration named "am335x_boneblack_config". However, I intend to monkey with this configuration a bit, so I do the following:

cd u-boot-2015.10
cd configs
cp am335x_boneblack_defconfig bbb_defconfig
cd ..
This gives me less to type in subsequent steps and provides a place for me to do some customization, in particular inserting the line:
But we are getting ahead of ourselves. I want to build and test the off the shelf version before doing any customization. After this, do:
make bbb_defconfig
make V=1
Adding the "V=1" switch is optional, but gives more information about the build process.

Build this on the BBB

However, the big question is what system should be used to do the build. Using an x86 desktop to build for an ARM target like the BBB could be done, but involves us in a bunch of issues with setting up the build to used a cross compiler. Another consideration is that U-boot include a set of linux kernel header files that are no longer compatible with the current ARM C compiler:

It would seem simpler and safer to just use the BBB itself.

scp u-boot-2015.10.tar root@bbb:
The first problem is no C compiler (we have tar). Along with the C compiler, also needed are:
apt-get install make
apt-get install bc
The need for "bc" was not apparent until make was run without the V=1 flag, which is very much the reason for the presence of this switch and the default selection to not use it.

For some reason the time is wrong on the BBB and I don't want to troubleshoot NTP right now, so I set the date by hand (important for make).

date 0928132716
cd u-boot-2015.10
make distclean
make bbb_defconfig
make V=1
The make process takes a while (at least 15 minutes, maybe longer). Here is the console output from the build: The resulting code does not work. It runs, but throws its hands up with the following messages and drops into the U-boot prompt.
switch to partitions #0, OK
mmc1(part 0) is current device
SD/MMC found on device 1
** File not found boot.scr **
** File not found uEnv.txt **
** Invalid partition 2 **
## Error: "nandboot" not defined
A console SD card is required to recover the system.

U-boot requires a patch as per this excellent discussion:

I provide the required patch in the link above.
tar -xjf u-boot-latest.tar.bz2
cd u-boot-2015.10
patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
patching file arch/arm/cpu/armv7/am33xx/board.c
patching file arch/arm/include/asm/omap_gpio.h
patching file board/ti/am335x/board.c
patching file board/ti/am335x/mux.c
patching file common/image.c
patching file configs/am335x_evm_defconfig
patching file drivers/gpio/omap_gpio.c
patching file include/configs/am335x_evm.h
patching file include/configs/ti_armv7_common.h
The patched version works and boots linux as always.

Feedback? Questions? Drop me a line!

Tom's Computer Info /