Hi,
I have a general problem in understanding the BBB and its boot process. With factory defaults BBB starts Angstrom Linux on power-up - correct?
Now when one connects this board via USB and with no micro-SD-card plugged to a host computer, a drive is shown there which contains some files (MLO bootloader u-boot.img and some documentation). So my question here: where are these things stored? And where is the Linux-filesystem stored which does not appear within this drives data?
I’d assume it has something to do with internal NAND-flash…but in this case the boot procedure of BBB is not clear to me - is the CPU itself able to read a FAT-formatted filesystem to start the MLO-bootloader? Or how else is booting done in this configuration?
BBB can boot from several sources, but I’ll restrict this explanation to the internal eMMC and the SDCard. uBoot considers the SDCard to be MMC 0 and the eMMC is considered MMC 1. Both devices are configured the same; namely a small FAT partition which stores MLO (first stage loader), u-boot (second stage loader) and uImage (Linux Kernel); and a second partition formatted as EXT4 which contains the linux filesystem. When you first boot, you will see u-boot countdown (“Hit any key to stop autoboot”) which requires you to press any key to enter the u-boot prompt. At the u-boot prompt, enter the following command:
U-Boot# printenv
This line is probably the most important to understand how BBB boots:
bootcmd=gpio set 53; i2c mw 0x24 1 0x3e; run findfdt; mmc dev 0; if mmc rescan ;
then echo micro SD card found;setenv mmcdev 0;else echo No micro SD card found,
setting mmcdev to 1;setenv mmcdev 1;fi;setenv bootpart ${mmcdev}:2;mmc dev ${mm
cdev}; if mmc rescan; then gpio set 54; 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;gpio set 5
5; if run loaduimage; then gpio set 56; run loadfdt;run mmcboot;fi;fi;
U-Boot# gpio set 53
sets LED0 (D2)
U-Boot# run findfdt
runs the following command:
findfdt=if test $board_name = A335BONE; then setenv fdtfile am335x-bone.dtb; fi;
if test $board_name = A335BNLT; then setenv fdtfile am335x-boneblack.dtb; fi; i
f test $board_name = A33515BB; then setenv fdtfile am335x-evm.dtb; fi; if test $
board_name = A335X_SK; then setenv fdtfile am335x-evmsk.dtb; fi
which determines the board type, in this case fdtfile=am335x-boneblack.dtb
Next, mmc is set to dev 0 (mmc dev 0), which is the SDCard. (mmc rescan) checks to see if the SDCard is installed and if it is, mmcdev=0 (setenv mmcdev 0) and if not, mmcdev is set to 1 (setenv mmcdev 1). Next, bootpart is set to 0 if the SDCard is installed; otherwise, it is set to 1.
I won’t go into detail for the remainder, but you can now see that the following commands are run:
U-Boot# run loadbootenv //loads uEnv.txt into memory
U-Boot# run importbootenv //imports uEnv.txt from memory into the u-boot env
U-Boot# run loaduimage // load uImage into memory
U-Boot# run loadfdt // load devicetree
U-Boot# run mmcboot // runs the linux kernel
BTW, you could always enter these commands individually and if you do this correctly, you will boot the BBB successfully.
It is the linux kernel that mounts the second partition (ext4) which contains the filesystem and then the init scripts are run to configure and setup everything needed for device drivers, display a login console and present a graphical environment available.
This is a very brief description, but I hope it is enough to help you understand the remainder of the u-boot environment and see how it works.
Regards,
John