In this blog post, I'll be covering how the BeagleBone Black boots up.
The BeagleBone Black is very customizable. It's got 4 different methods of booting up.
For getting ArduPilot on the BeagleBone Black, we will be using the eMMC boot option. It's the fastest of them all, and that's important for our use case.
(There are certain other methods of loading an image into the memory of the am335x processor, but that is out of scope here)
The boot sequence is as follows : eMMC->microSD->USB port->serial and in the case that the boot button is pressed the sequence becomes microSD->USB port->serial.
Following are the different bootloaders that are used in the eMMC boot option. It's the fastest of them all, and that's what we are looking for.
This is hard-coded in the am335x chip from TI. The ROM Code performs platform configuration and initialization as part of the public start-up procedure. A booting device list is genertated by this ROM code. The booting devices can either be memory booting devices or a peripheral interface connected to a host. The ROM code goes through this device list, and tries to look for a valid booting image. Take note that this is not the Linux kernel image. It looks for a much smaller image, which can be of 109Kb at max. This image is the MLO image that is stored on either the eMMC/SD.
This is one of the many things that this ROM code does. It also does some other stuff like configuration of the clocks for executing it's own as well as other codes, sets up the stack and configures the
watchdog timer. For more on this topic, read from the am335x TRM(Chapter 26 onwards)
As stated above, the SYSBOOT pins, which are also the LCD_DATA pins, are located on the headers from P8:31 to P8:46. The pins are used to index the device table from which the list of devices is extracted.Any error that occurs in reading the value of these pins sends the ROM boot code into a loop, waiting for the watchdog to reset the system.
These pins can be used by software after ROM execution has completed. So, we can't have anything connected to these pins when the ROM code is executing.
As we discussed, the ROM boot code looks for a small image which is bootable in the boot devices list. It finds the MLO, either on the eMMC, SD card or any other peripheral device and then loads it up into the public RAM. This MLO file is not part of the ROM, it is located on the boot media that you are using. In normal cases, it will be the eMMC or the SD card. You can check out the binary version of this in boot/uboot directory.
root@beaglebone:/boot/uboot# ls -lah MLO-rwxr-xr-x 1 root root 103K Mar 4 23:37 MLO
The MLO is "secondary program loader". It will run and configure off-chip memory and then load the U Boot image. The MLO and the u-boot.img that it loads, both have to be located on a FAT filesystem.
The MLO is built when you build the U Boot bootloader. So the source code for this stage 1 is available to us with the U Boot source here
The U Boot image is located in the boot/uboot directory on our BeagleBone Black
root@beaglebone:/boot/uboot# ls -lah u-boot.img-rwxr-xr-x 1 root root 358K Mar 4 23:37 u-boot.img
You will notice that it's bigger than the MLO that we saw in the previous section.
Das U Boot is the most commonly used bootloader on embedded systems. More about the project can be found here
If you connect a 3.3V USB-Serial cable to the BeagleBone Black, you will see the following on a screen session when the BBB boots up.
U-Boot SPL 2013.10-00016-ga0e6bc6 (Feb 25 2014 - 10:27:54)reading argsspl: error reading image args, err - -1
U-Boot 2013.10-00016-ga0e6bc6 (Feb 25 2014 - 10:27:54)
DRAM: 512 MiB
WARNING: Caches not enabled
NAND: 0 MiB
MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
*** Warning - readenv() failed, using default environment
Net: <ethaddr> not set. Validating first E-fuse MAC
Hit any key to stop autoboot: 0
gpio: pin 53 (gpio 53) value is 1
Card did not respond to voltage select!
mmc0(part 0) is current device
Card did not respond to voltage select!
mmc1(part 0) is current device
gpio: pin 54 (gpio 54) value is 1
SD/MMC found on device 1
1417 bytes read in 6 ms (230.5 KiB/s)
Importing environment from mmc ...
gpio: pin 55 (gpio 55) value is 1
Checking if uenvcmd is set ...
gpio: pin 56 (gpio 56) value is 1
Running uenvcmd ...
3711864 bytes read in 352 ms (10.1 MiB/s)
2870984 bytes read in 275 ms (10 MiB/s)
24996 bytes read in 11 ms (2.2 MiB/s)
Kernel image @ 0x80300000 [ 0x000000 - 0x38a378 ]
## Flattened Device Tree blob at 815f0000
Booting using the fdt blob at 0x815f0000
Using Device Tree in place at 815f0000, end 815f91a3
Starting kernel ...
It loads the device tree, initializes pins as per the data structures
there and then loads the Linux kernel.
Uncompressing Linux... done, booting the kernel.[ 0.378462] omap2_mbox_probe: platform not supported[ 0.545588] tps65217-bl tps65217-bl: no platform data provided
[ 0.609407] bone-capemgr bone_capemgr.9: slot #0: No cape found
[ 0.646516] bone-capemgr bone_capemgr.9: slot #1: No cape found
[ 0.683623] bone-capemgr bone_capemgr.9: slot #2: No cape found
[ 0.720732] bone-capemgr bone_capemgr.9: slot #3: No cape found
[ 0.736869] bone-capemgr bone_capemgr.9: slot #6: BB-BONELT-HDMIN conflict P8.45 (#5:BB-BONELT-HDMI)
[ 0.746454] bone-capemgr bone_capemgr.9: slot #6: Failed verification
[ 0.753187] bone-capemgr bone_capemgr.9: loader: failed to load slot-6 BB-BONELT-HDMIN:00A0 (prio 2)
[ 0.769794] omap_hsmmc mmc.5: of_parse_phandle_with_args of 'reset' failed
[ 0.832336] pinctrl-single 44e10800.pinmux: pin 44e10854 already requested by 44e10800.pinmux; cannot claim for gpio-leds.8
[ 0.844029] pinctrl-single 44e10800.pinmux: pin-21 (gpio-leds.8) status -22
[ 0.851313] pinctrl-single 44e10800.pinmux: could not request pin 21 on device pinctrl-single
Loading, please wait...
Scanning for Btrfs filesystems
systemd-fsck: rootfs: clean, 57884/111104 files, 295616/444160 blocks
Debian GNU/Linux 7 beaglebone ttyO0
default username:password is [debian:temppwd]
The IP Address for usb0 is: 192.168.7.2
All the above messages are generated from within the Linux that has
been booted up now.
This blog is in connection with the work that is being carried out at the PixHawk Fire project, which is basically ArduPilot on Linux(BeagleBone Black to start with).
Most of the above content has been taken from the am335x Technical Reference Manual.