The document discusses compiling and using U-Boot on the BeagleBone board. It describes how pulling the SD card in and out for each compile was slowing down development. The author configured U-Boot to load kernels over the network via TFTP to speed up the process. Key steps included setting up a DHCP and TFTP server to distribute images, compiling U-Boot for the BeagleBone, and modifying boot commands to load from the TFTP server instead of the SD card.
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
Compile U-Boot for BeagleBone Boot over Ethernet
1. 5/15/13 Compiling and using U-Boot for BeagleBone. | कायशाला (Kāryaśālā)
bharath.lohray.com/weblog/compiling-and-using-u-boot-for-beaglebone/ 1/7
0 2
Compiling and using U-Boot for
BeagleBone.
Posted on January 7, 2013
The [www ] ships with a micro SD card that contains an
[www ]. The images may be found and downloaded from the Ångström website .
This image works perfectly out of the box.
The problem I faced was how to get the BeagleBone load a kernel or a program
from a server and execute it and to get [www ] to load a program from the TFTP
server at boot without the user having to manually execute the boot commands each time
In the past, kernel and baremetal development on the BeagleBoard (rev C3) required me to
pull out the SD card each time I compiled something and reboot the BeagleBoard. Pulling out
and reinserting the card into the slot about 3 or 4 times an hour and burning an image on to it
was a development bottleneck and not to mention, I risked mechanically damaging
some delicate parts. The projected ended prematurely when the mechanical stress while
handling the board resulted failures that led the I C operations to go dead. A ~$150 hit on
my exchequers.
When I bought the [www ], Pandaboard, BeagleBone, Raspberry Pi, Atlys
and Zed Board, all of which had an ethernet ports on them, it made sense to load the kernel
or baremetal program over the LAN to mitigate the risk of physical damage and unthrottle the
development bottleneck of writing images to an SD card for each modify-compile iteration.
Image Distribution
To dish out the kernel images to the development boards, A and a TFTP server were
Like 0
BeagleBone Ångström Linux
distribution
baremetal
TFTP U-Boot
2
BeagleBoard-xM
DHCP
कायशाला (Kāryaśālā)
The outcomes of the Lord Loh's tinkerings
2. 5/15/13 Compiling and using U-Boot for BeagleBone. | कायशाला (Kāryaśālā)
bharath.lohray.com/weblog/compiling-and-using-u-boot-for-beaglebone/ 2/7
setup. The DHCP server is configured to assign a fixed IP address, to the MAC address
corresponding to the BeagleBone. The configuration corresponding to the BeagleBone’s MAC
address also specifies the IP address of the TFTP server and the file name of the kernel
image file that it should download from that TFTP server. Specifying this for the specific MAC
lets various hosts (x86 PC / ARM / MIPS / PowerPC ) get their architecture specific images.
U-Boot
U-Boot or Das u-Boot is an openSource universal boot loader distributed under the GNU GPL
v2 for embedded ARM, PowerPC and MIPS systems. U-Boot needs to be configured for a
specific architecture and board before it can be built. U-Boot is a stage 2 boot loader (read
more ) which is loaded by the stage 1 boot loader. The Stage 1 boot loader is known as the
x-loader. The x-loader executable binary is in a file called MLO. Most ARM processors have
some basic ROM code that is enough to load and execute a file called MLOfrom the SD card
or NAND.
The x-loader may sometimes be found as independent projects for specific boards or
independent of U-Boot. For example TI’s x-loader which attempts to make x-loader
independent of U-Boot. An attempt to combine MLOand u-boot.imgfrom different releases
resulted in an unbootable system.
Compiling U-Boot
Pre-compiled binaries for various boards may be download from various sites such as the
Ångström distribution. However, if one chooses to compile their own U-Boot, the sources may
be obtained from here or from the git repository at git://git.denx.de/u-boot.git.
ST ART ING CLEAN:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
CONFIGURING FOR AN ARCHIT ECT URE:
Configuring for the BeagleBone
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_evm_config
Configuring for the BeagleBoard-xM
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap3_beagle_config
3. 5/15/13 Compiling and using U-Boot for BeagleBone. | कायशाला (Kāryaśālā)
bharath.lohray.com/weblog/compiling-and-using-u-boot-for-beaglebone/ 3/7
Configuring for the PandaBoard-ES
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap4_panda_config
BUILDING U-BOOT
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
This results in MLO, u-boot.binand u-boot.imgbeing generated. These files may be
copied into the FAT partition of the SD Card or flashed into the NAND.
U-Boot Boot Sequence
On power up or reset, the x-loader loads U-Boot and hands off control to it. The U-Boot waits
for a short while for the user to interrupt the boot and then proceeds to execute the
commands in the environment variable bootcmd.
The default boot sequence for the am3335x (BeagleBone) is -
mmc dev ${mmcdev};
if mmc rescan;
then
echo SD/MMC found on device ${mmcdev};
if run loadbootenv;
then
echo Loaded environment from ${bootenv};
run importbootenv;
fi;
if test -n $uenvcmd;
then
echo Running uenvcmd ...;
run uenvcmd;
fi;
if run loaduimage;
then
run mmcboot;
fi;
fi;
This initializes the SD card, loads uENV.txt to memory, imports the contents from the
memory to environment space, loads uImageand boots it. Various words seen in the script
above are actually variables. ${variableName} is substituted by the value in the
4. 5/15/13 Compiling and using U-Boot for BeagleBone. | कायशाला (Kāryaśālā)
bharath.lohray.com/weblog/compiling-and-using-u-boot-for-beaglebone/ 4/7
variable. Commands in variables may be executed as
run variableName
To change the boot sequence, the board configuration files have to modified and U-Boot has
to be recompiled. For the BeagleBone, this file is include/configs/am335x_evm.h. An
extract from the am335x_evm.hsource file is shown below -
#define CONFIG_BOOTCOMMAND
"mmc dev ${mmcdev}; if mmc rescan; then "
"echo SD/MMC found on device ${mmcdev};"
"if run loadbootenv; then "
"echo Loaded environment from ${bootenv};"
"run importbootenv;"
"fi;"
"if test -n $uenvcmd; then "
"echo Running uenvcmd ...;"
"run uenvcmd;"
"fi;"
"if run loaduimage; then "
"run mmcboot;"
"fi;"
"fi;"
To change the boot sequence to load a file from the TFTP server and boot it with the ext4 file
system on the SD card as the root, I modified the source as below and recompiled U-Boot to
behave as desired.
#define CONFIG_BOOTCOMMAND
"mmc dev ${mmcdev}; if mmc rescan; then "
"echo SD/MMC found on device ${mmcdev};"
"if run loadbootenv; then "
"echo Loaded environment from ${bootenv};"
"run importbootenv;"
"fi;"
"if test -n $uenvcmd; then "
"echo Running uenvcmd ...;"
"run uenvcmd;"
"fi;"
"if dhcp ${loadaddr}; then "
"run mmcargs;"
"bootm ${loadaddr};"
"fi;"
"fi;"
5. 5/15/13 Compiling and using U-Boot for BeagleBone. | कायशाला (Kāryaśālā)
bharath.lohray.com/weblog/compiling-and-using-u-boot-for-beaglebone/ 5/7
5 THOUGHTS ON “COMPILING AND USING U-BOOT FOR BEAGLEBONE.”
2
I would like to conclude this entry by touching on an alternate boot loader called barebox .
barebox is a boot loader that was derived from U-Boot and is also distributed under GNU GPL
v2. Barebox scripts and commands are very Similar to U-Boot and a knowledge of U-Boot can
get one started on barebox very quickly. Barebox also provides some good features like a
boot menu.
Barebox uses kconfig can be configured by -
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
Which lets the user tweak a lot of features before building the MLO & u-boot. While
BeagleBone is not supported by barebox yet, BeagleBoard & Pandaboard are. There are a
few patches floating around that claim to put in support for the AM335x processor, but none
of them worked out of the box on the current (2013-01-06) git copy.
This entry was posted in Embedded, Linux and tagged BeagleBone, Documentation,
Linux, u-boot by Lord Bharath Bhushan Lohray. Bookmark the permalink
[http://bharath.lohray.com/weblog/compiling-and-using-u-boot-for-beaglebone/] .
ShareShareShareShareMore
awesome
on March 24, 2013 at 18:59 said:
Thanks for this, this is exactly what I wanted to do.
In fact, I wasn’t even expecting to find such a match explaining right exactly what I
wanted to do — wanted to change the default u-boot command to tftp the kernel on
boot to avoid mechanical stress on the BeagleBone and speed up development.
Lord Bharath Bhushan Lohray
on March 24, 2013 at 19:05 said:
I am glad it helped. It took me quite a while to figure this out.
6. 5/15/13 Compiling and using U-Boot for BeagleBone. | कायशाला (Kāryaśālā)
bharath.lohray.com/weblog/compiling-and-using-u-boot-for-beaglebone/ 6/7
Pham
on April 27, 2013 at 18:55 said:
Hi,
Thank your for this, but I have a problem with booting my Beaglebone V3.
I’m successful booting my Beaglebone with u-boot and MLO which I downloaded on
the Internet but I wanted to build myself u-boot from scratch.
In fact I compiled exactly as yours and it genarated MLO and u-boot.img and I copied
this files into SDCard. But I can’t not boot with new MLO and u-boot.img(I tried to boot
with old MLO and u-boot.img, il boot successfully). Il has error message like this
“Booting from mmc …
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid”
Could you help me to find out why is this problem,
Thanks very much,
Lord Bharath Bhushan Lohray
on April 27, 2013 at 18:59 said:
Can you interrupt the U-Boot process by pressing any key? Do you have the
uENV.txt from your older U-Boot? What is in the variable bootcmd?
Pham
on April 28, 2013 at 06:34 said:
Hi,
Thanks yours answer quickly. I recompiled u-boot as like the site:
http://www.eewiki.net/display/linuxonarm/BeagleBone#BeagleBone-U-
BootConfigureandBuild: and this time it works:) . I’m very new in
embedded and I think your site is very useful with second part U-Boot
Boot Sequence.
Thanks again and have a nice weekend,
7. 5/15/13 Compiling and using U-Boot for BeagleBone. | कायशाला (Kāryaśālā)
bharath.lohray.com/weblog/compiling-and-using-u-boot-for-beaglebone/ 7/7