Boot process
DevelBoard, just like Linux, follows a multi-stage boot process, which involves three separated bootstrap stages (and as many bootloaders).
In this section, we'll briefly explain the significance and operations of each bootloaders, how to format an SD card to boot from it, and how to modify the boot options for the Linux kernel.
Bootloaders
As said before, the boot process involves three bootloaders:
-
a hardware bootloader, which is embedded in the Atmel AT91 SoC, which is responsible for checking the presence in FLASH of the second level bootloader and loading it in SRAM;
-
a second level bootloader,
AT91Bootstrap
, specifically designed for Atmel AT91 microprocessors, which initializes several on-board peripherals (clock speed, PIO, DRAM), to load from FLASH or SD Card to main memory the third level bootloader; -
finally, a third level bootloader,
barebox
, which is in charge of retrieving or downloading the kernel binaries from a specified location (FLASH, SD Card, network etc.).
From a DevelBoard user perspective, only barebox
is of particular
significance, since it is the one responsible for passing boot options to the
kernel. These options, and the barebox
configuration in general, can be
modified by the user, as described in the next sections.
Boot menu
During the boot sequence, the barebox
boot menu will appear for a few seconds
(specified in the configuration file):
Welcome on Barebox Boot Sequence
1: boot
2: boot tftp
3: boot mmc
4: boot mmc-rw
5: kernel location ->
6: rootfs location ->
7: update ->
8: test ->
9: shell
10: reset
This is used to change the default behavior of the bootloader (which is, boot the system from FLASH after 3 seconds).
The various boot
options allow to choose alternative locations for retrieving
the system files:
- tftp: from a remote location in the network, using the TFTP protocol
- mmc: from the SD card, in read-only mode (changes to the filesystem are lost upon power down)
- mmc-rw: from the SD card, with persistency support
- kernel location and rootfs location: different sources for kernel and root filesystem
Other options available include:
- test: perform various self-tests
- shell: open the
barebox
shell - reset: reset the device
If no input is detected in 3 seconds, the bootloader proceeds to boot into the system.
Modifying the boot process
To modify the kernel boot process, we must modify the barebox
environment
configuration file. This file contains several customization options, ranging
from default kernel and root filesystem locations, startup network interface
configuration, kernel boot args etc.
There are multiple ways to go about this, but the easiest and most user-friendly
is by using the dboard
tool. A basic tutorial on
the tool is available in the tool's section of the guide. For the sake of
simplicity, we will assume that the user is already familiar with the tool, and
has created a new DevelBoard project which needs to be modified.
Once you have a project up and running, and you have created an SD card using
dboard makesd
, a new folder images/bareboxenv
will be automatically created.
This folder contains a config
file you need to modify in order to
change barebox
configuration.
Example of configuration change
Let's assume we want to modify the default bootloader behavior, and boot from the SD card rather than from FLASH by default.
This is done by opening the images/bareboxenv/config
file and changing the
following lines from:
kernel_loc=nand
rootfs_loc=nand
to:
kernel_loc=mmc
rootfs_loc=mmc
Now you need to remove the precompiled images/barebox.env
file in order
for dboard
to regenerate it from the configuration file:
$ rm images/barebox.env
$ dboard makesd
You can now verify that everything is working correctly by waiting for barebox
to autoboot from the SD card in the boot menu.