Home | Projects | Notes > Embedded Linux > BBB Linux Boot Sequence - Step 3: U-boot
Initialize some of the peripherals like I2C, NAND Flash, ETHERNET, UART, USB, MMC, etc, because it supports loading kernel from all these peripherals.
While in U-boot, the target can communicate with the host over UART, USB, etc.
Load the Linux kernel image from various boot sources to the DDR Memory of the board.
Boot sources could be USB, eMMC, SD card, Ethernet, serial port, NAND Flash, etc.
Passing of boot arguments to the kernel.
The file uEnv.txt
need to be provided. It contains environment variables that determines the behavior of U-boot.
You can overwrite these environment variables to alter the behavior of the U-boot.
Use this file to set the environment variables which drives the U-boot according to your needs.
U-boot always looks for uImage, which is nothing but zImage + U-boot image header.
U-boot gets information from the U-boot image header. (Basically, the total size of the structure image_header
is 64 bytes.)
Download the root file system Angstrom-systemd-image-eglibc-ipk-v2012.12-beagleboard.rootfs
to be used in our demo. (Inside the boot/
folder, uImage-3.8.10
is the kernel image we will be using.)
Copy all the folders in side the root file system into the ROOTFS section of your SD card.
xxxxxxxxxx
21.../Angstrom-systemd-image-eglibc-ipk-v2012.12-beagleboard.rootfs
2$ sudo cp -r * /media/klee/ROOTFS/
And, sync:
xxxxxxxxxx
11$ sync
Now, you need to tell U-boot where to locate the Linux kernel image using uEnv.txt
. Copy this file into BOOT section. It is in under boot/
folder. (It does not come filled out of the box. You need to fill it in.)
xxxxxxxxxx
81console=ttyUSB0,115200n8
2ipaddr=192.168.7.2
3serverip=192.168.7.1
4loadaddr=0x82000000
5fdtaddr=0x88000000
6loadfromsd=load mmc 0:2 ${loadaddr} /boot/uImage;load mmc 0:2 ${fdtaddr} /boot/am335x-boneblack.dtb
7linuxbootargs=setenv bootargs console=${console} root=/dev/mmcblk0p2 rw
8uenvcmd=setenv autoload no; run loadfromsd; run linuxbootargs; bootm ${loadaddr} - ${fdtaddr}
L4: Load address of DDR memory (Telling the U-boot to keep the Linux kernel at this address)
L5:
.dtb
file addressL8:
bootm
is where U-boot hands over the control to the Linux kernel.
Unmount the SD card from your system:
xxxxxxxxxx
21umount /media/klee/BOOT
2umount /media/klee/ROOTFS
Insert your SD card into BBB and open minicom.
Boot from SD card, then you'll see all the boot messages followed by the login screen from Angstrom.
xxxxxxxxxx
331...
2mmc0 is current device
3SD/MMC found on device 0
4...
5Checking for: /uEnv.txt ...
6370 bytes read in 4 ms (89.8 KiB/s)
7gpio: pin 55 (gpio 55) value is 1
8Loaded environment from /uEnv.txt
9Importing environment from mmc ...
10Checking if uenvcmd is set ...
11gpio: pin 56 (gpio 56) value is 1
12Running uenvcmd ...
134002080 bytes read in 291 ms (13.1 MiB/s)
1423334 bytes read in 18 ms (1.2 MiB/s)
15## Booting kernel from Legacy Image at 82000000 ...
16 Image Name: Angstrom/3.8.10/beaglebone
17 Created: 2013-04-29 19:56:00 UTC
18 Image Type: ARM Linux Kernel Image (uncompressed)
19 Data Size: 4002016 Bytes = 3.8 MiB
20 Load Address: 80008000
21 Entry Point: 80008000
22 Verifying Checksum ... OK
23## Flattened Device Tree blob at 88000000
24 Booting using the fdt blob at 0x88000000
25 Loading Kernel Image ... OK
26 Loading Device Tree to 8fff7000, end 8ffffb25 ... OK
27
28Starting kernel ...
29
30Uncompressing Linux... done, booting the kernel.
31[ 0.000000] Booting Linux on physical CPU 0x0
32[ 0.000000] Initializing cgroup subsys cpu
33...
L2: U-boot has detected SD card.
L8: Read
uEnv.txt
L13: Read Linux kernel.
L14: Read
.dtb
file.L15: U-boot prints information extracted from the U-boot image header.
L22: If the image is corrupted, checksum will not match and the boot will fail.
L28: The very last message printed by the U-boot. From this point on, control is handed over to the Linux bootstrap loader.
L30: Uncompressing of the kernel is handled by
misc.c
which is part of the Linux bootstrap loader.
Reading U-boot header information of the uImage manually by using U-boot commands
Load the uImage from Memory device (SD card / eMMC) into DDR memory of the board.
At power on, keep pressing "spacebar" to enter U-boot prompt. (minicom)
If, in your environment, the keyboard doesn't seem to work, check your minicom setting and disable Hardware Flow Control:
Ctrl + A
o
Serial port setup
Hardware Flow Control : No
. If Hardware flow control enabled, then minicom will not be able to send data to BBB via serial cable. Minicom will take log messages from BBB. (This took me 5 hours to figure out!)
To load a file from FAT based file system into memory, use fatload
.
To load a file from any file system: load
Example:
xxxxxxxxxx
31fatload usb 0:1 0x82000000 uImage
2fatload mmc 0:1 0x88000000 initramfs
3load mmc 0:1 0x88000000 uImage
MMC0 interface
SD card MMC1 interface
eMMC
Use help
to use help functionality. e.g., help load
Use load
to load uImage from the memory device into DDR memory of the board. First 64 bytes starting from 0x82000000 is the U-boot Image Header.
xxxxxxxxxx
21==> load mmc 0:2 0x82000000 /boot/uImage
24002080 bytes read in 291 ms (13.1 MiB/s)
2 in
0:2
because our uImage is in theboot/
folder in the 2nd partition of the SD card.0x82000000 is DDR address.
This loads uImage from the memory device into DDR memory of the board. First 64 bytes starting from 0x82000000 is the U-boot Image Header.
Use the memory dump command of U-boot to dump header information.
Use md
to display memory:
xxxxxxxxxx
21==> md 0x82000000 4
282000000: 56190527 62153da1 50d07e51 e0103d00 '..V.=.bQ~.P.=..
Display 4 objects starting from the specified memory address.
First object is
ih_magic
, the magic number. Since this is in little-endian, the actual magic number is 0x27051956.Fourth object is
ih_size
, the image data size. Since this is in little-endian, the actual size is 0x3d10e0, which is 4002016 in decimal, together with 64 byte makes 4002080 that we got earlier withload
command.
And so on...
Use imi
command to dump image information:
xxxxxxxxxx
111=> imi 0x82000000
2
3## Checking Image at 82000000 ...
4 Legacy image found
5 Image Name: Angstrom/3.8.10/beaglebone
6 Created: 2013-04-29 19:56:00 UTC
7 Image Type: ARM Linux Kernel Image (uncompressed)
8 Data Size: 4002016 Bytes = 3.8 MiB
9 Load Address: 80008000
10 Entry Point: 80008000
11 Verifying Checksum ... OK
There are many more U-boot command you can use. Consult the U-boot documentation!
Nayak, K. (2022). Embedded Linux Step by Step Using Beaglebone Black [Video file]. Retrieved from https://www.udemy.com/course/embedded-linux-step-by-step-using-beaglebone/