SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
U-boot startup sequence
CCMA, ITRI
houcheng
Agenda
• U-boot introduction
• Multistage boot
• U-boot on Arndale octa board
• Secure boot
U-boot
• Features
– initialize: Bootstrap CPU, serial console, boot string`
– hardware: detection, test and flash EEPROM
– loading kernel image from: network, SSD, EEPROM
– support secure boot and loading trust software
– loading hypervisor (TYPE1/ TYPE2)
• Supports
– hardware: different architecture, CPU, boards and devices
– software: different file format, flash based file system and
fat file system
U-boot history
• 1999: PPCBoot start from MPC860-fads board, PPC CPU
• 2000: network support
• 2002: merge with armboot (support 106 boards PPC/ ARM)
• 2002: x86 support
• 2003: MIP32 MIPS64 support
• 2003: NIOS support
• today: u-boot 1.1.2 , support > 216 boards
Boot code initialize these
• initialize components on CPU
– disable: icache, dcache, TLB, MMU
– setting UART
• initialize software context
– Interrupt vector of all mode
– Stack pointer point to iRAM or RAM
• initialize components on board
– System clock controller
– DDR memory controller
• Relocate codes
– move code to proper location (iRAM or RAM) and jump to
it
Initial state, few resource with
limitation
CPU
boot
software
Gained resource
software context
UART
After initialize devices/ controller on
board
CPU
boot
software
RAM
flash
ether
Gained resource
software context
OS1
OS binary
UART
Multi stages then U-boot
• Multistage boot loader
– BL0, BL1, BL2, u-boot
• Why multi stages?
– CPU comes up with bare resource: CPU, iRAM and iROM only
– incremental initialize more resources on every stage
• CPU components (caches, TLB, MMU)
• execution environment: stack, exception vector, interrupt controller
• devices: sys clock, memory, serial IO, network, RTC,
– every stage runs on different text base
• BL0: runs on iROM (vendor fused)
• BL1: runs on iRAM (vendor provided)
• BL2: runs on memory (u-boot SPL version)
• U-boot boot loader: runs on high memory (u-boot)
• uImage: runs on memory (a compressed kernel with de-compressor)
Boot loaders sequence
BL1
BL2 (u-boot.spl)
u-boot
env variables
SD card
318K
16K
8K
Linux
uImage
BL0
iROMiRAM
u-bootrelocate
BL2 (u-boot.spl)
u-boot
BL1
Linux
uImage
loading
decompressor
load
Linux
decompress
CPUDRAM
trust software
U-boot for Arndale Octa board
• Board configuration defines
– include/configs/arndale_octa.h
– arch/arm/include/asm/arch-exynos/movi_partition.h
• CPU dependent code
– arch/arm/cpu/armv7/*.c;*.S
– arch/arm/cpu/armv7/exynos/*.c
– arch/arm/lib/*.c
• Board dependent code
– board/samsung/smdk5420/*.c; *.S
• Board independent code
– common(cmd, flash, env, stdio, usb, …), disk (partition),
– drivers, fs, net, lib (CRC, SHA1,…),
– SPL: ld script to generate BL2 u-boot
armv7/start.S
1) bl save_boot_params
2) set CPU to SVC32 mode
3) set exception table VBAR to _start
4) bl cpu_init_cp15
5) bl cpu_init_cr
6) setup stack to memory and call C function: _board_init_f
reset:
Exception vector table on _start
exception vector
handler table handler function:
cpu_init_cp15 and cpu_init_cr
• cpu_init_cp15
– invalidate TLB, MMU, icache and dcache
• cpu_init_cr
– call smdk5420 board’s lowlevel_init.S
• use iRAM as stack
• read board boot switch and store flag in iRAM
• relocate code if needed
• check every reset switches on board is not set
• read boot string stored on board’s EEPROM
• initialize system clock (system_clock_init)
• initialize memory controller (mem_ctrl_init)
board_init_f (f:flash)
• Fill board information into global_data object
– board rate, clock rate, FDT data (hard coded)
– monitor size, ram size, ram base, memory bank size
• Reserve high memory to store
– hardware buffer: TLB, frame buffer, monitor
– software buffer: IRQ stack, heap, program stack and another copy of
global data object
• Call init_sequence function array
– serial_init, console_init, timer_init, disp_banner,
– env_init, dram_init (detect memory size)
• relocate code then call call board_init_r with param:
– pointer of stack
– pointer of copied global_data object
– pointer of heap
board_init_r (r: ram)
• Initialize devices and related libraries
– serial console, flash, MMC, ether net
• setup interrupt handlers and enable interrupt
• POST
• Command line main loop
ARM trusted boot
• Trust boot
– SOC vendor fuse PUK in BL0 and stored in ROM
– SOC vendor hold the private key that can sign BL1/ BL2
– Trust boot sequence
• CPU runs in secure mode, from BL0
• BL0 initialize bare hardware and verify BL1’s signaure with PUK
• BL1 or BL2 setup necessary protection in secure world, loading trust
software in secure world and perform world switch
• Some trust boot options
– Use OTP (One Time Programming) in SOC to store PUK
• If PUK > OTP memory, store hash of Puk in OTP and store Puk from
flash
– PUK may changed on next stage
Secondary CPU enter hyper mode
u-boot
Linux
uImage
decompressor
Primary CPU
DRAM
Secondary CPUs
arch init
….
smp_pen()
1. kick
2. Load and jump to decompressor
• wake up by CPU0
• Install hyper stubs by setting HTBAR
• enter SVC32
• run oridinary kernel SMP init
a) decompress done and jump
b) board init complete
c) SMP code kick Secondary CPU
Primary CPU in kernel Secondary CPU in kernel

Weitere ähnliche Inhalte

Was ist angesagt?

Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
Emertxe Information Technologies Pvt Ltd
 

Was ist angesagt? (20)

Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
Bootloaders
BootloadersBootloaders
Bootloaders
 
U boot-boot-flow
U boot-boot-flowU boot-boot-flow
U boot-boot-flow
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
 
Linux device drivers
Linux device drivers Linux device drivers
Linux device drivers
 
BusyBox for Embedded Linux
BusyBox for Embedded LinuxBusyBox for Embedded Linux
BusyBox for Embedded Linux
 
LCU13: An Introduction to ARM Trusted Firmware
LCU13: An Introduction to ARM Trusted FirmwareLCU13: An Introduction to ARM Trusted Firmware
LCU13: An Introduction to ARM Trusted Firmware
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 

Ähnlich wie Uboot startup sequence

Computer Main Comppponents.pdf
Computer Main Comppponents.pdfComputer Main Comppponents.pdf
Computer Main Comppponents.pdf
thinalost
 
Porting_uClinux_CELF2008_Griffin
Porting_uClinux_CELF2008_GriffinPorting_uClinux_CELF2008_Griffin
Porting_uClinux_CELF2008_Griffin
Peter Griffin
 

Ähnlich wie Uboot startup sequence (20)

TMS320DM8148 Embedded Linux
TMS320DM8148 Embedded LinuxTMS320DM8148 Embedded Linux
TMS320DM8148 Embedded Linux
 
NXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded Linux
 
Introduction to Linux Kernel by Quontra Solutions
Introduction to Linux Kernel by Quontra SolutionsIntroduction to Linux Kernel by Quontra Solutions
Introduction to Linux Kernel by Quontra Solutions
 
BSP.pptx
BSP.pptxBSP.pptx
BSP.pptx
 
Board support package_on_linux
Board support package_on_linuxBoard support package_on_linux
Board support package_on_linux
 
Computer Main Comppponents.pdf
Computer Main Comppponents.pdfComputer Main Comppponents.pdf
Computer Main Comppponents.pdf
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Embedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theory
Embedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theoryEmbedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theory
Embedded Fest 2019. Руслан Биловол. Linux Boot: The Big Bang theory
 
1 study of motherboard
1 study of motherboard1 study of motherboard
1 study of motherboard
 
5120224.ppt
5120224.ppt5120224.ppt
5120224.ppt
 
TC and TPM.ppt
TC and TPM.pptTC and TPM.ppt
TC and TPM.ppt
 
Porting_uClinux_CELF2008_Griffin
Porting_uClinux_CELF2008_GriffinPorting_uClinux_CELF2008_Griffin
Porting_uClinux_CELF2008_Griffin
 
Linux Kernel Platform Development: Challenges and Insights
 Linux Kernel Platform Development: Challenges and Insights Linux Kernel Platform Development: Challenges and Insights
Linux Kernel Platform Development: Challenges and Insights
 
101 1.1 hardware settings
101 1.1 hardware settings101 1.1 hardware settings
101 1.1 hardware settings
 
Identifying and Supporting 'X-compatible' Hardware Blocks
Identifying and Supporting 'X-compatible' Hardware BlocksIdentifying and Supporting 'X-compatible' Hardware Blocks
Identifying and Supporting 'X-compatible' Hardware Blocks
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Porting Android ABS 2011
Porting Android ABS 2011Porting Android ABS 2011
Porting Android ABS 2011
 
Embedding Linux On The Encore Simputer
Embedding Linux On The Encore SimputerEmbedding Linux On The Encore Simputer
Embedding Linux On The Encore Simputer
 
Nvidia tegra K1 Presentation
Nvidia tegra K1 PresentationNvidia tegra K1 Presentation
Nvidia tegra K1 Presentation
 
Hardware hacking
Hardware hackingHardware hacking
Hardware hacking
 

Uboot startup sequence

  • 2. Agenda • U-boot introduction • Multistage boot • U-boot on Arndale octa board • Secure boot
  • 3. U-boot • Features – initialize: Bootstrap CPU, serial console, boot string` – hardware: detection, test and flash EEPROM – loading kernel image from: network, SSD, EEPROM – support secure boot and loading trust software – loading hypervisor (TYPE1/ TYPE2) • Supports – hardware: different architecture, CPU, boards and devices – software: different file format, flash based file system and fat file system
  • 4. U-boot history • 1999: PPCBoot start from MPC860-fads board, PPC CPU • 2000: network support • 2002: merge with armboot (support 106 boards PPC/ ARM) • 2002: x86 support • 2003: MIP32 MIPS64 support • 2003: NIOS support • today: u-boot 1.1.2 , support > 216 boards
  • 5. Boot code initialize these • initialize components on CPU – disable: icache, dcache, TLB, MMU – setting UART • initialize software context – Interrupt vector of all mode – Stack pointer point to iRAM or RAM • initialize components on board – System clock controller – DDR memory controller • Relocate codes – move code to proper location (iRAM or RAM) and jump to it
  • 6. Initial state, few resource with limitation CPU boot software Gained resource software context UART
  • 7. After initialize devices/ controller on board CPU boot software RAM flash ether Gained resource software context OS1 OS binary UART
  • 8. Multi stages then U-boot • Multistage boot loader – BL0, BL1, BL2, u-boot • Why multi stages? – CPU comes up with bare resource: CPU, iRAM and iROM only – incremental initialize more resources on every stage • CPU components (caches, TLB, MMU) • execution environment: stack, exception vector, interrupt controller • devices: sys clock, memory, serial IO, network, RTC, – every stage runs on different text base • BL0: runs on iROM (vendor fused) • BL1: runs on iRAM (vendor provided) • BL2: runs on memory (u-boot SPL version) • U-boot boot loader: runs on high memory (u-boot) • uImage: runs on memory (a compressed kernel with de-compressor)
  • 9. Boot loaders sequence BL1 BL2 (u-boot.spl) u-boot env variables SD card 318K 16K 8K Linux uImage BL0 iROMiRAM u-bootrelocate BL2 (u-boot.spl) u-boot BL1 Linux uImage loading decompressor load Linux decompress CPUDRAM trust software
  • 10. U-boot for Arndale Octa board • Board configuration defines – include/configs/arndale_octa.h – arch/arm/include/asm/arch-exynos/movi_partition.h • CPU dependent code – arch/arm/cpu/armv7/*.c;*.S – arch/arm/cpu/armv7/exynos/*.c – arch/arm/lib/*.c • Board dependent code – board/samsung/smdk5420/*.c; *.S • Board independent code – common(cmd, flash, env, stdio, usb, …), disk (partition), – drivers, fs, net, lib (CRC, SHA1,…), – SPL: ld script to generate BL2 u-boot
  • 11. armv7/start.S 1) bl save_boot_params 2) set CPU to SVC32 mode 3) set exception table VBAR to _start 4) bl cpu_init_cp15 5) bl cpu_init_cr 6) setup stack to memory and call C function: _board_init_f reset:
  • 12. Exception vector table on _start exception vector handler table handler function:
  • 13. cpu_init_cp15 and cpu_init_cr • cpu_init_cp15 – invalidate TLB, MMU, icache and dcache • cpu_init_cr – call smdk5420 board’s lowlevel_init.S • use iRAM as stack • read board boot switch and store flag in iRAM • relocate code if needed • check every reset switches on board is not set • read boot string stored on board’s EEPROM • initialize system clock (system_clock_init) • initialize memory controller (mem_ctrl_init)
  • 14. board_init_f (f:flash) • Fill board information into global_data object – board rate, clock rate, FDT data (hard coded) – monitor size, ram size, ram base, memory bank size • Reserve high memory to store – hardware buffer: TLB, frame buffer, monitor – software buffer: IRQ stack, heap, program stack and another copy of global data object • Call init_sequence function array – serial_init, console_init, timer_init, disp_banner, – env_init, dram_init (detect memory size) • relocate code then call call board_init_r with param: – pointer of stack – pointer of copied global_data object – pointer of heap
  • 15. board_init_r (r: ram) • Initialize devices and related libraries – serial console, flash, MMC, ether net • setup interrupt handlers and enable interrupt • POST • Command line main loop
  • 16. ARM trusted boot • Trust boot – SOC vendor fuse PUK in BL0 and stored in ROM – SOC vendor hold the private key that can sign BL1/ BL2 – Trust boot sequence • CPU runs in secure mode, from BL0 • BL0 initialize bare hardware and verify BL1’s signaure with PUK • BL1 or BL2 setup necessary protection in secure world, loading trust software in secure world and perform world switch • Some trust boot options – Use OTP (One Time Programming) in SOC to store PUK • If PUK > OTP memory, store hash of Puk in OTP and store Puk from flash – PUK may changed on next stage
  • 17. Secondary CPU enter hyper mode u-boot Linux uImage decompressor Primary CPU DRAM Secondary CPUs arch init …. smp_pen() 1. kick 2. Load and jump to decompressor • wake up by CPU0 • Install hyper stubs by setting HTBAR • enter SVC32 • run oridinary kernel SMP init a) decompress done and jump b) board init complete c) SMP code kick Secondary CPU Primary CPU in kernel Secondary CPU in kernel