The document describes the Linux boot process on embedded systems. It has 5 stages: 1) BootRom loads BootStrap, 2) BootStrap loads U-Boot from storage to RAM, 3) U-Boot loads the kernel and provides arguments, 4) The kernel mounts the root file system, 5) The kernel starts the init process. It then provides details on BootStrap, U-Boot, configuring boot arguments and commands in U-Boot, and using BuildRoot to build a root file system.
2. Linux Booting Process on Embedded Board
Linux load process can be divided on next stages:
1.BootRoom is internal loader of BootStrap from ROM
flash (NandFlash or SD card)
2.BootStrap (X-Loader in case BeagleBoard) –
initializes eternal RAM and loads to it U-Boot from SD
card fist FAT partition
3.BootLoader (U-Boot) – loads kernel and provides
boot arguments
4.Kernel mount Root FS
5. Kernel start Init proccess
3. BootStrap (X-Loader)
X-Loader is 2nd stage bootstrap loader loaded by OMAP3
BootRom from NAND flash to internal RAM to start 3rd
stage tool like U-Boot.
Bootstrap is usually limited by internal RAM size and has
serial console to manage update of BootLoader (U-Boot).
X-loader can be updated from SD card to NAND
Must have 255 heads and 63 sectors/track
First partition is FAT and bootable
Must have “MLO” file of X-Loader.bin
For detail instruction how format SD card please refer to
https://code.google.com/p/beagleboard/wiki/LinuxBoot
DiskFormat
4. BootLoader (U-Boot)
Universal Bootloader is an open source, primary boot loader
used in embedded devices to start linux kernel.
X-Loader uploads U-Boot to external RAM (SDRAM or DDR)
from NAND flash or SD card.
U-Boot is responsible for next actions
Implement FAT file system and TCP/IP stack.
Load kernel image from SD card first FAT partition to ext
RAM (in case BeagleBoard at address 0x80300000)
Manage bootargs and bootcmd and provide it for kernel
5. U-Boot how to manage bootargs and
bootcmd
To manage U-Boot used one of the next serial ports
/dev/ttyS0
/dev/ttyUSB0
As console terminal can be used for Linux “Minicom” and for
Windows “PuTTY”. The serial port settings is 115200 8N1,
no flow control.
Environment settings bootargs and bootcmd managed by
next U-boot commands
printenv (lists all env vars)
seteenv (saves variables to flash for next boot)
bootargs (lists all kernel arguments)
bootcmd (default boot command)
6. U-Boot how to manage bootargs and
bootcmd
To set up kernel argument used next string:
setenv bootargs 'console=ttyS0,115200n8
root=/dev/mmcblk0p2 rootfstype=ext2 rw'
Here you can see next arguments:
1) console kernel settings 115200n8 and ttyS0
(can be ttyS2 in case console on ext screen)
2) Root fs mount path to SD card
/dev/mmcblk0p2, filetype ext2 (can be ext3)
privileges read and write
7. U-Boot how to manage bootargs and
bootcmd
To set up boot command used next string:
setenv bootcmd 'mmcinit; fatload mmc 0
0x80300000 uImage; bootm 0x80300000'
String above contain next boot commands:
Init mmc (also work for SD) card
Load kernel image file “uImage” from mmc (SD)
card partition 0 to memory at address
0x80300000
Boot application image from address
0x80300000
8. BuildRoot
BuildRoot is an embedded Linux build system
Its goal is to build
a cross-compiling toolchain
a root file-system with multiple cross-compiled libraries and
applications
a kernel image and bootloader images
or any combination of these
It has a menuconfig configuration mechanism, identical to the one
used in the kernel
It is completely written in make
It builds only what's necessary. A base system, containing just
Busybox, takes less than 2 minutes to be built from scratch.
BusyBox combines tiny versions of many common UNIX utilities into
a single small executable. It provides replacements for most of the
utilities you usually find in GNU fileutils, shellutils, etc.
10. BuildRoot basic usage
To config linux kernel type:
$ make linux-menuconfig
To build all run simple command:
$ make
...
Here You will be involved to install all necessary libs and
tools
...
$ ls output/images/
dataflash_at91sam9m10g45ek.bin rootfs.tar
rootfs.ubi rootfs.ubifs
u-boot.bin u-boot-env.bin
uImage
11. BuildRoot how does it work
Configuration options defined in Config.in files, and
stored in a .config file
Buildroot starts with the toolchain: either it generates it,
or imports an existing toolchain for instance
CodeSourcery ARM GNU/Linux tool chain
It creates a basic root filesystem from a skeleton (just a
few conguration files)
Once the toolchain is ready, Buildroot goes through the
list of selected packages. It simply fetches, configures,
builds and installs all packages, respecting their
dependencies.
It builds the kernel image and/or bootloader images, if
requested
It creates root file system images
12. BuildRoot source code organization
board/
contains hardware-specific and project-specific files.
boot/
contains config options and recipes for various
bootloaders
configs/
the default congurations
docs/
some documentation.
fs/
contains config options and makefiles to generate the
various filesystem images (j
s2, ubifs, ext2, iso9660, initramfs, tar and more). Also
contains the root file system skeleton
13. BuildRoot source code organization
linux/
contains the config options and makefile to generate the
Linux kernel
package/
contains the config options and makefiles for all
userspace packages
support/
various misc stuff
needed for the build (kcong code, etc.)
target/
mostly historic directory. No longer contains anything
useful
toolchain/
config options and makefiles to build or import the
toolchain
14. BuildRoot output generated source and
images
output/build/
a directory with one sub-directory per component build.
The directory contains the source of that component and
this is where it is built.
output/host/
a directory that contains the utilities built for the host
machine, including the toolchain
output/target/ the target root file system
output/images/ where final images are stored