Introduction To U-Boot 2020
Introduction To U-Boot 2020
June, 2020
This Talk originally written by Marek Vašut
Multi-stage bootloader
First stage bootloader
I Resides on reset vector
I Often on-chip BootROM
I Initializes HW and loads the next stage
User bootloader
I First user-controlled code
Linux kernel
Userspace
U-Boot bootloader
First stage bootloader
U-Boot SPL
I First user-controlled code
I Responsible for additional HW initialization
I Loads U-Boot or Linux directly
U-Boot
I Bootloader with interactive shell
I Boot monitor
I Debug tool
Linux kernel
Userspace
U-Boot example
1 => help
2 ? - alias for 'help'
3 bdinfo - print Board Info structure
4 bootm - boot application image from memory
5 cmp - memory compare
6 coninfo - print console devices and information
7 crc32 - checksum calculation
8 dhcp - boot image via network using DHCP/TFTP protocol
9 echo - echo args to console
10 go - start application at address 'addr'
11 help - print command description/usage
12 i2c - I2C sub-system
13 load - load binary file from a filesystem
14 usb - USB sub-system
Running ’help’ on a command
1 => bdinfo
2 arch_number = 0x00000E05
3 boot_params = 0x80000100
4 DRAM bank = 0x00000000
5 -> start = 0x80000000
6 -> size = 0x20000000
7 eth0name = usb_ether
8 ethaddr = 60:64:05:f4:79:7f
9 current eth = usb_ether
10 ip_addr = 192.168.1.2
11 baudrate = 115200 bps
12 TLB addr = 0x9FFF0000
13 relocaddr = 0x9FF44000
14 reloc off = 0x1F744000
15 irq_sp = 0x9DF23EC0
16 sp start = 0x9DF23EB0
17 Early malloc usage: 2a8 / 400
Getting further help
1 => mm 0x4804c134
2 4804c134: ffffffff ? fe1fffff
3 4804c138: f0002300 ?
4 4804c13c: 00000000 ? 00400000
5 4804c140: 00000000 ? q
6 =>
Memory access commands, ’cp’, ’cmp’
I cp – copy memory
I cmp – compare memory
I Same properties as md/mw above apply
1 => md 0x9ff4e000 1
2 9ff4e000: ea0000b8
3 => setexpr foo *0x9ff4e000
4 => env print foo
5 foo=ea0000b8
6
7 => env set foo 1 ; env set bar 2
8 => setexpr baz $foo + $bar
9 => env print baz
10 baz=3
11
12 => setexpr foo gsub ab+ x "aabbcc"
13 foo=axcc
U-Boot shell conditional
expressions and loops
The ’true’/’false’ commands
1 => true
2 => echo $?
3 0
4 => false
5 => echo $?
6 1
Conditional expressions
1 U-Boot> loady
2 <send file over ymodem protocol, e.g. sb -T>
4 Usage:
5 bootz [addr [initrd[:size]] [fdt]]
6 - boot Linux zImage stored in memory
7 The argument 'initrd' is optional... The optional arg
8 ':size' allows specifying the size of RAW initrd.
9
1 /dts-v1/;
2 #include "arm-realview-eb-mp.dtsi"
3 / {
4 model = "ARM RealView EB Cortex A9 MPCore";
5 [...]
6 cpus {
7 #address-cells = <1>;
8 #size-cells = <0>;
9 enable-method = "arm,realview-smp";
10 A9_0: cpu@0 {
11 device_type = "cpu";
12 compatible = "arm,cortex-a9";
13 reg = <0>;
14 next-level-cache = <&L2>;
15 };
16 [...]
17 pmu: pmu@0 {
18 interrupt-affinity = <&A9_0>, <&A9_1>, <&A9_2>, <&A9_3>;
19 }; };
fitImage example (1)
1 /dts-v1/;
2
3 / {
4 description = "Linux kernel and FDT blob for sockit";
5
6 images {
7 kernel@1 {
8 description = "Linux kernel";
9 data = /incbin/("./arch/arm/boot/zImage");
10 type = "kernel";
11 arch = "arm";
12 os = "linux";
13 compression = "none";
14 load = <0x00008000>;
15 entry = <0x00008000>;
16 hash@1 {
17 algo = "crc32";
18 };
19 };
fitImage example (2)
1 fdt@1 {
2 description = "Flattened Device Tree blob";
3 data = /incbin/("./arch/arm/boot/dts/socfpga....dtb");
4 type = "flat_dt";
5 arch = "arm";
6 compression = "none";
7 hash@1 {
8 algo = "crc32";
9 };
10 };
11 };
fitImage example (3)
1 configurations {
2 default = "conf@1";
3 conf@1 {
4 description = "Boot Linux kernel with FDT blob";
5 kernel = "kernel@1";
6 fdt = "fdt@1";
7 hash@1 {
8 algo = "crc32";
9 };
10 };
11 };
12 };
Compile with
I FDT manipulation
I fdt addr – Tell U-Boot where the FDT is
I fdt resize – Add extra space to FDT
I fdt print – Print DT path
I fdt set – Add or change DT entry
Practical labs
Button input
I HINT: ’gpio input’ command
I HINT: 0x4804c138 is the offset of the GPIO input register
I HINT: gpio 45 is the USR button GPIO
Task 3
1 $ make sandbox_defconfig
2 HOSTCC scripts/basic/fixdep
3 ...
4 #
5 # configuration written to .config
6 #
7
8 $ make -j $(nproc)
9 scripts/kconfig/conf --syncconfig Kconfig
10 CHK include/config.h
11 UPD include/config.h
12 ...
13 CFGCHK u-boot.cfg
14 $ ./u-boot
15
16 U-Boot 2018.11-rc1-00033-ga16accc9fb (Oct 07 2018 - 17:13:29 +0200)
17
18 Model: sandbox
19 DRAM: 128 MiB
20 ...
21 =>
Task 8
bjs
Questions