Team Emertxe
Embedded Boot Loaders
U-Boot
Contents
U-Boot
Contents
● Introduction
● Source Tree
● Building
● Responsibility
● Important Commands
U-Boot Introduction
U-Boot
Introduction - General
● The "Universal Bootloader" ("Das U-Boot") is a monitor
program
● Free Software: full source code under GPL
● Can get at: //www.denx.de/wiki/U-Boot
● Production quality: used as default boot loader by several
board vendors
● Portable and easy to port and to debug
● Many supported architectures: PPC, ARM, MIPS, x86,
m68k, NIOS, Microblaze
U-Boot
Introduction - General
● More than 216 boards supported by public source tree
● Simple user interface: CLI or Hush shell
● Environment variable storing option on different media
like EEPROM, Flash etc
● Advanced command supports
U-Boot
Introduction – Design Principles
● Easy to port to new architectures, new processors, and
new boards
● Easy to debug: serial console output as soon as possible
● Features and commands configurable
● As small as possible
● As reliable as possible
U-Boot Source Tree
U-Boot
Source Code Browsing
● Untar the U-Boot code
– tar xvf u-boot-<version>.tar.bz2
● Enter the U-Boot directory
– cd u-boot-<version>
● The following slide discuss the contents of the U-Boot
directory
U-Boot
Source Tree
● The left side of the slide
shows the source content of
the U-Boot
● The directory structure might
vary depending on the picked
version.
● The considered version is
u-boot-2015-01
● Lets us discuss some
important directories and files
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Machine/arch independent API
for external apps
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● All architecture dependent
functions
● CPU specific information
– <core>/cpu.c
– <core>/interrupt.c
– <core>/start.S
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Platform, board level files.
Eg, atmel, icecube, oxc etc.,
● Contains all board specific
initialization
– <boardname>/flash.c
– <boardname>/<boardname>_emac.c
– <boardname>/<boardname>.c
– <boardname>/soc.h
– <boardname>/platform.S
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● All architecture independent
functions
● All the commands
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Default configuration files for
boards
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Partition and device
information for disks
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● You can find all the README
files here
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Various device drivers files
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Contains Makefile for building
internal U-Boot fdt
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Example code for standalone
application
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● File system directories and
codes
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Various header files
– configs/<boardname>.h
– <core>.h
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Processor specific libraries
– board.c
– <arch>linux.c
– div0.c
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Networking related files.
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Power On Self Test
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Contains the sources for
various helper programs
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Various tools directories and
files
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot
Source Tree
● Top level make file for Uboot
build and configuration
driver
api
arch
board
common
configs
post
scripts
dts
examples
fs
include
lib
test
tools
Makefile
disk net
doc
u-boot-<version>
U-Boot Building
U-Boot
Building
● The include/configs/ directory contains one configuration
file for each supported board
– It defines the CPU type, the peripherals and their
configuration, the memory mapping, the Uboot features
that should be compiled in, etc.
– It is a simple .h file that sets preprocessor constants. See
the README file for the documentation of these constants.
● Assuming that your board is already supported by Uboot,
there should be a config corresponding to your board, for
example include/configs/at91rm9200ek.h
U-Boot
Building
● We need to configure U-Boot for the required board
which is generally done as
make <board_name>_config
● The board_name can be found in include/configs/
directory
● The newer version supports kernel like configuration
options like make menuconfig
● Compile Uboot, by specifying the cross compiler prefix.
make CROSS_COMPILE=<cross_compile_path>
U-Boot
Building
● cross_compile_path could be the command itself if
already exported in PATH variable, else you can specify
the installation path of command
● For example for arm platform it would look like
make CROSS_COMPILE=arm-linux-
● The result would be u-boot.bin which has to be stored in
flash memory (in most of the cases)
● The invocation of the stored image depends on the target
architecture. The memory used to store would play the
role here
U-Boot Introduction
U-Boot
Responsibility
Execute from flash (If configured). Do POST
Relocate to RAM
Setup console for user interaction
Setup device driver for kernel (& RFS) image
Choose the kernel (& RFS) image
Download the kernel (& RFS) image
Choose the kernel (& RFS) imageChoose the kernel (& RFS) image
Setup kernel command line arguments
Jump to kernel start address
Codeflow
U-Boot Important Commands
U-Boot
Utilities
● Environment Variables
● Commands
– Information
– Environment
– Network
– Boot
– Data Transfer
– Memory
U-Boot
Environment Variables
● bootcmd : Contains the command that U-Boot will
automatically execute at boot time after
a configurable delay, if the process is not
interrupted
● bootargs : contains the arguments passed to the
Linux kernel
● serverip : Server (Host) ip address for network
related commands
● ipaddr : Local ip address of the target
● ethaddr : MAC address. Will be set once
U-Boot
Important Environment Variables
● netmask : The network mask to communicate with
the server
● bootdelay : Time in seconds to delay the boot process
so that the u-boot can be interrupted
before executing bootcmd
● autostart : If set the loaded image in memory will be
executed automatically
U-Boot
Important Commands – Information
● help : Help command. Can be used to list all
supported built commands
● flinfo : Display flash informations (NOR and SPI
Flash)
● nand info : Display NAND flash informations
U-Boot
Important Commands – Environment
● printenv : Print all set environment variables
● setenv : Set the environment variable
● saveenv : Save environment variable to configured
memory
U-Boot
Important Commands – Network
● ping : Checks for network connectivity
U-Boot
Important Commands – Boot
● boot : Runs the default boot command, stored in
bootcmd variable
● bootm : Boot memory. Starts a kernel image
loaded at the specified address in RAM
Example: bootm <address>
U-Boot
Important Commands – Data Transfer
● loadb
● loads
● loady
: Load a file from the serial line to RAM
● tftpboot : Loads a file from the network to RAM
Example: tftpboot <address>
U-Boot
Important Commands – Memory
● erase : Erase the content of NOR flash
● protect : Protect the content of NOR flash
● cp : Write to NOR flash
● nand : Erase, read, write to NAND flash
Thank You

U-Boot - An universal bootloader

  • 1.
  • 2.
  • 3.
    U-Boot Contents ● Introduction ● SourceTree ● Building ● Responsibility ● Important Commands
  • 4.
  • 5.
    U-Boot Introduction - General ●The "Universal Bootloader" ("Das U-Boot") is a monitor program ● Free Software: full source code under GPL ● Can get at: //www.denx.de/wiki/U-Boot ● Production quality: used as default boot loader by several board vendors ● Portable and easy to port and to debug ● Many supported architectures: PPC, ARM, MIPS, x86, m68k, NIOS, Microblaze
  • 6.
    U-Boot Introduction - General ●More than 216 boards supported by public source tree ● Simple user interface: CLI or Hush shell ● Environment variable storing option on different media like EEPROM, Flash etc ● Advanced command supports
  • 7.
    U-Boot Introduction – DesignPrinciples ● Easy to port to new architectures, new processors, and new boards ● Easy to debug: serial console output as soon as possible ● Features and commands configurable ● As small as possible ● As reliable as possible
  • 8.
  • 9.
    U-Boot Source Code Browsing ●Untar the U-Boot code – tar xvf u-boot-<version>.tar.bz2 ● Enter the U-Boot directory – cd u-boot-<version> ● The following slide discuss the contents of the U-Boot directory
  • 10.
    U-Boot Source Tree ● Theleft side of the slide shows the source content of the U-Boot ● The directory structure might vary depending on the picked version. ● The considered version is u-boot-2015-01 ● Lets us discuss some important directories and files driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 11.
    U-Boot Source Tree ● Machine/archindependent API for external apps driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 12.
    U-Boot Source Tree ● Allarchitecture dependent functions ● CPU specific information – <core>/cpu.c – <core>/interrupt.c – <core>/start.S driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 13.
    U-Boot Source Tree ● Platform,board level files. Eg, atmel, icecube, oxc etc., ● Contains all board specific initialization – <boardname>/flash.c – <boardname>/<boardname>_emac.c – <boardname>/<boardname>.c – <boardname>/soc.h – <boardname>/platform.S driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 14.
    U-Boot Source Tree ● Allarchitecture independent functions ● All the commands driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 15.
    U-Boot Source Tree ● Defaultconfiguration files for boards driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 16.
    U-Boot Source Tree ● Partitionand device information for disks driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 17.
    U-Boot Source Tree ● Youcan find all the README files here driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 18.
    U-Boot Source Tree ● Variousdevice drivers files driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 19.
    U-Boot Source Tree ● ContainsMakefile for building internal U-Boot fdt driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 20.
    U-Boot Source Tree ● Examplecode for standalone application driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 21.
    U-Boot Source Tree ● Filesystem directories and codes driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 22.
    U-Boot Source Tree ● Variousheader files – configs/<boardname>.h – <core>.h driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 23.
    U-Boot Source Tree ● Processorspecific libraries – board.c – <arch>linux.c – div0.c driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 24.
    U-Boot Source Tree ● Networkingrelated files. driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 25.
    U-Boot Source Tree ● PowerOn Self Test driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 26.
    U-Boot Source Tree ● Containsthe sources for various helper programs driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 27.
  • 28.
    U-Boot Source Tree ● Varioustools directories and files driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 29.
    U-Boot Source Tree ● Toplevel make file for Uboot build and configuration driver api arch board common configs post scripts dts examples fs include lib test tools Makefile disk net doc u-boot-<version>
  • 30.
  • 31.
    U-Boot Building ● The include/configs/directory contains one configuration file for each supported board – It defines the CPU type, the peripherals and their configuration, the memory mapping, the Uboot features that should be compiled in, etc. – It is a simple .h file that sets preprocessor constants. See the README file for the documentation of these constants. ● Assuming that your board is already supported by Uboot, there should be a config corresponding to your board, for example include/configs/at91rm9200ek.h
  • 32.
    U-Boot Building ● We needto configure U-Boot for the required board which is generally done as make <board_name>_config ● The board_name can be found in include/configs/ directory ● The newer version supports kernel like configuration options like make menuconfig ● Compile Uboot, by specifying the cross compiler prefix. make CROSS_COMPILE=<cross_compile_path>
  • 33.
    U-Boot Building ● cross_compile_path couldbe the command itself if already exported in PATH variable, else you can specify the installation path of command ● For example for arm platform it would look like make CROSS_COMPILE=arm-linux- ● The result would be u-boot.bin which has to be stored in flash memory (in most of the cases) ● The invocation of the stored image depends on the target architecture. The memory used to store would play the role here
  • 34.
  • 35.
    U-Boot Responsibility Execute from flash(If configured). Do POST Relocate to RAM Setup console for user interaction Setup device driver for kernel (& RFS) image Choose the kernel (& RFS) image Download the kernel (& RFS) image Choose the kernel (& RFS) imageChoose the kernel (& RFS) image Setup kernel command line arguments Jump to kernel start address Codeflow
  • 36.
  • 37.
    U-Boot Utilities ● Environment Variables ●Commands – Information – Environment – Network – Boot – Data Transfer – Memory
  • 38.
    U-Boot Environment Variables ● bootcmd: Contains the command that U-Boot will automatically execute at boot time after a configurable delay, if the process is not interrupted ● bootargs : contains the arguments passed to the Linux kernel ● serverip : Server (Host) ip address for network related commands ● ipaddr : Local ip address of the target ● ethaddr : MAC address. Will be set once
  • 39.
    U-Boot Important Environment Variables ●netmask : The network mask to communicate with the server ● bootdelay : Time in seconds to delay the boot process so that the u-boot can be interrupted before executing bootcmd ● autostart : If set the loaded image in memory will be executed automatically
  • 40.
    U-Boot Important Commands –Information ● help : Help command. Can be used to list all supported built commands ● flinfo : Display flash informations (NOR and SPI Flash) ● nand info : Display NAND flash informations
  • 41.
    U-Boot Important Commands –Environment ● printenv : Print all set environment variables ● setenv : Set the environment variable ● saveenv : Save environment variable to configured memory
  • 42.
    U-Boot Important Commands –Network ● ping : Checks for network connectivity
  • 43.
    U-Boot Important Commands –Boot ● boot : Runs the default boot command, stored in bootcmd variable ● bootm : Boot memory. Starts a kernel image loaded at the specified address in RAM Example: bootm <address>
  • 44.
    U-Boot Important Commands –Data Transfer ● loadb ● loads ● loady : Load a file from the serial line to RAM ● tftpboot : Loads a file from the network to RAM Example: tftpboot <address>
  • 45.
    U-Boot Important Commands –Memory ● erase : Erase the content of NOR flash ● protect : Protect the content of NOR flash ● cp : Write to NOR flash ● nand : Erase, read, write to NAND flash
  • 46.