SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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 NLKBshimosawa
 
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 driversHoucheng Lin
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_BootingRashila Rr
 
LAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
LAS16-402: ARM Trusted Firmware – from Enterprise to EmbeddedLAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
LAS16-402: ARM Trusted Firmware – from Enterprise to EmbeddedLinaro
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)RuggedBoardGroup
 
OPTEE on QEMU - Build Tutorial
OPTEE on QEMU - Build TutorialOPTEE on QEMU - Build Tutorial
OPTEE on QEMU - Build TutorialDalton Valadares
 
Q4.11: Introduction to eMMC
Q4.11: Introduction to eMMCQ4.11: Introduction to eMMC
Q4.11: Introduction to eMMCLinaro
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewHKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewLinaro
 
linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
 
Linux Porting
Linux PortingLinux Porting
Linux PortingChamp Yen
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)shimosawa
 

La actualidad más candente (20)

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
 
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
 
Spi drivers
Spi driversSpi drivers
Spi drivers
 
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
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
I2c drivers
I2c driversI2c drivers
I2c drivers
 
LAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
LAS16-402: ARM Trusted Firmware – from Enterprise to EmbeddedLAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
LAS16-402: ARM Trusted Firmware – from Enterprise to Embedded
 
A practical guide to buildroot
A practical guide to buildrootA practical guide to buildroot
A practical guide to buildroot
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
 
OPTEE on QEMU - Build Tutorial
OPTEE on QEMU - Build TutorialOPTEE on QEMU - Build Tutorial
OPTEE on QEMU - Build Tutorial
 
I2C Drivers
I2C DriversI2C Drivers
I2C Drivers
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
Q4.11: Introduction to eMMC
Q4.11: Introduction to eMMCQ4.11: Introduction to eMMC
Q4.11: Introduction to eMMC
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewHKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting Review
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
Linux Porting
Linux PortingLinux Porting
Linux Porting
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 

Similar a Uboot startup sequence

NXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNEEVEE Technologies
 
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 SolutionsQUONTRASOLUTIONS
 
BSP.pptx
BSP.pptxBSP.pptx
BSP.pptxtaruian
 
Board support package_on_linux
Board support package_on_linuxBoard support package_on_linux
Board support package_on_linuxVandana Salve
 
Computer Main Comppponents.pdf
Computer Main Comppponents.pdfComputer Main Comppponents.pdf
Computer Main Comppponents.pdfthinalost
 
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 theoryEmbeddedFest
 
1 study of motherboard
1 study of motherboard1 study of motherboard
1 study of motherboardAnkit Dubey
 
TC and TPM.ppt
TC and TPM.pptTC and TPM.ppt
TC and TPM.pptyhaxpsos
 
Porting_uClinux_CELF2008_Griffin
Porting_uClinux_CELF2008_GriffinPorting_uClinux_CELF2008_Griffin
Porting_uClinux_CELF2008_GriffinPeter 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 InsightsGlobalLogic Ukraine
 
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 BlocksChen-Yu Tsai
 
Porting Android ABS 2011
Porting Android ABS 2011Porting Android ABS 2011
Porting Android ABS 2011Opersys inc.
 
Embedding Linux On The Encore Simputer
Embedding Linux On The Encore SimputerEmbedding Linux On The Encore Simputer
Embedding Linux On The Encore SimputerSatpal Parmar
 
Nvidia tegra K1 Presentation
Nvidia tegra K1 PresentationNvidia tegra K1 Presentation
Nvidia tegra K1 PresentationANURAG SEKHSARIA
 

Similar a 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