I will complete this chapter with a look at another bootloader that has the same roots as U-Boot but takes a new approach to bootloaders. It is derived from U-Boot and was actually called U-Boot v2 in the early days. The Barebox developers aimed to combine the best parts of U-Boot and Linux, including a POSIX-like API and mountable filesystems.
The Barebox project website is www.barebox.org and the developer mailing list is <barebox@lists.infradead.org>
.
To get Barebox, clone the git repository and check out the version you want to use:
$ git clone git://git.pengutronix.de/git/barebox.git $ cd barebox $ git checkout v2014.12.0
The layout of the code is similar to U-Boot:
arch
: Contains code specific to each supported architecture, which includes all the major embedded architectures. SoC support is in arch/[architecture]/mach-[SoC]
. Support for individual boards is in arch/[architecture]/boards
.common
: Contains core functions, including the shell.commands
: Contains the commands that can be called from the shell.Documentation
: Contains the templates for documentation files. To build it, type "make docs
". The results are put in Documentation/html
.drivers
: Contains the code for the device drivers.include
: Contains header files.Barebox has used kconfig/kbuild
for a long time. There are default configuration files in arch/[architecture]/configs
. As an example, assume that you want to build Barebox for the BeagleBoard C4. You need two configurations, one for the SPL, and one for the main binary. Firstly, build MLO:
$ make ARCH=arm CROSS_COMPILE=arm-cortex_a8-linux-gnueabi- omap3530_beagle_xload_defconfig $ make ARCH=arm CROSS_COMPILE=arm-cortex_a8-linux-gnueabi-
The result is the secondary program loader, MLO.
Next, build Barebox:
$ make ARCH=arm CROSS_COMPILE=arm-cortex_a8-linux-gnueabi- omap3530_beagle_defconfig $ make ARCH=arm CROSS_COMPILE=arm-cortex_a8-linux-gnueabi-
Copy both to an SD card:
$ cp MLO /media/boot/ $ cp barebox-flash-image /media/boot/barebox.bin
Then, boot up the board and you should see messages like these on the console:
barebox 2014.12.0 #1 Wed Dec 31 11:04:39 GMT 2014 Board: Texas Instruments beagle nand: Trying ONFI probe in 16 bits mode, aborting ! nand: NAND device: Manufacturer ID: 0x2c, Chip ID: 0xba (Micron ), 256MiB, page size: 2048, OOB size: 64 omap-hsmmc omap3-hsmmc0: registered as omap3-hsmmc0 mci0: detected SD card version 2.0 mci0: registered disk0 malloc space: 0x87bff400 -> 0x87fff3ff (size 4 MiB) booting from MMC barebox 2014.12.0 #2 Wed Dec 31 11:08:59 GMT 2014 Board: Texas Instruments beagle netconsole: registered as netconsole-1 i2c-omap i2c-omap30: bus 0 rev3.3 at 100 kHz ehci ehci0: USB EHCI 1.00 nand: Trying ONFI probe in 16 bits mode, aborting ! nand: NAND device: Manufacturer ID: 0x2c, Chip ID: 0xba (Micron NAND 256MiB 1,8V 16-bit), 256MiB, page size: 2048, OOB size: 64 omap-hsmmc omap3-hsmmc0: registered as omap3-hsmmc0 mci0: detected SD card version 2.0 mci0: registered disk0 malloc space: 0x85e00000 -> 0x87dfffff (size 32 MiB) environment load /boot/barebox.env: No such file or directory Maybe you have to create the partition. no valid environment found on /boot/barebox.env. Using default environment running /env/bin/init... Hit any key to stop autoboot: 0
Barebox is continuing to evolve. At the time of writing, it lacks the breadth of hardware support that U-Boot has, but it is worth considering for new projects.