Slim Bootloader¶
Introduction¶
This target is to enable U-Boot as a payload of Slim Bootloader (a.k.a SBL) boot firmware which currently supports QEMU, Apollolake, Whiskeylake, Coffeelake-R platforms.
The Slim Bootloader is designed with multi-stages (Stage1A/B, Stage2, Payload) architecture to cover from reset vector to OS booting and it consumes Intel FSP for silicon initialization.
- Stage1A: Reset vector, CAR init with FSP-T
- Stage1B: Memory init with FSP-M, CAR teardown, Continue execution in memory
- Stage2 : Rest of Silicon init with FSP-S, Create HOB, Hand-off to Payload
- Payload: Payload init with HOB, Load OS from media, Booting OS
The Slim Bootloader stages (Stage1A/B, Stage2) focus on chipset, hardware and platform specific initialization, and it provides useful information to a payload in a HOB (Hand-Off Block) which has serial port, memory map, performance data info and so on. This is Slim Bootloader architectural design to make a payload light-weight, platform independent and more generic across different boot solutions or payloads, and to minimize hardware re-initialization in a payload.
Build Instruction for U-Boot as a Slim Bootloader payload¶
Build U-Boot and obtain u-boot-dtb.bin:
$ make distclean
$ make slimbootloader_defconfig
$ make all
Prepare Slim Bootloader¶
Setup Build Environment for Slim Bootloader.
Refer to Getting Started page in Slim Bootloader document site.
Get source code. Let’s simply clone the repo:
$ git clone https://github.com/slimbootloader/slimbootloader.git
Copy u-boot-dtb.bin to Slim Bootloader. Slim Bootloader looks for a payload from the specific location. Copy the build u-boot-dtb.bin to the expected location:
$ mkdir -p <Slim Bootloader Dir>/PayloadPkg/PayloadBins/ $ cp <U-Boot Dir>/u-boot-dtb.bin <Slim Bootloader Dir>/PayloadPkg/PayloadBins/u-boot-dtb.bin
Build Instruction for Slim Bootloader for QEMU target¶
Slim Bootloader supports multiple payloads, and a board of Slim Bootloader detects its target payload by PayloadId in board configuration. The PayloadId can be any 4 Bytes value.
Update PayloadId. Let’s use ‘U-BT’ as an example:
$ vi Platform/QemuBoardPkg/CfgData/CfgDataExt_Brd1.dlt -GEN_CFG_DATA.PayloadId | 'AUTO' +GEN_CFG_DATA.PayloadId | 'U-BT'
Update payload text base. PAYLOAD_EXE_BASE must be the same as U-Boot CONFIG_SYS_TEXT_BASE in board/intel/slimbootloader/Kconfig. PAYLOAD_LOAD_HIGH must be 0:
$ vi Platform/QemuBoardPkg/BoardConfig.py + self.PAYLOAD_LOAD_HIGH = 0 + self.PAYLOAD_EXE_BASE = 0x00100000
Build QEMU target. Make sure u-boot-dtb.bin and U-BT PayloadId in build command. The output is Outputs/qemu/SlimBootloader.bin:
$ python BuildLoader.py build qemu -p "OsLoader.efi:LLDR:Lz4;u-boot-dtb.bin:U-BT:Lzma"
Launch Slim Bootloader on QEMU. You should reach at U-Boot serial console:
$ qemu-system-x86_64 -machine q35 -nographic -serial mon:stdio -pflash Outputs/qemu/SlimBootloader.bin
Test Linux booting on QEMU target¶
Let’s use LeafHill (APL) Yocto image for testing. Download it from http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/machines/leafhill/.
Prepare Yocto hard disk image:
$ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/machines/leafhill/leafhill-4.0-jethro-2.0.tar.bz2 $ tar -xvf leafhill-4.0-jethro-2.0.tar.bz2 $ ls -l leafhill-4.0-jethro-2.0/binary/core-image-sato-intel-corei7-64.hddimg
Launch Slim Bootloader on QEMU with disk image:
$ qemu-system-x86_64 -machine q35 -nographic -serial mon:stdio -pflash Outputs/qemu/SlimBootloader.bin -drive id=mydrive,if=none,file=/path/to/core-image-sato-intel-corei7-64.hddimg,format=raw -device ide-hd,drive=mydrive
Update boot environment values on shell:
=> setenv bootfile vmlinuz => setenv bootdev scsi => boot
Build Instruction for Slim Bootloader for LeafHill (APL) target¶
Prepare U-Boot and Slim Bootloader as described at the beginning of this page. Also, the PayloadId needs to be set for APL board.
Update PayloadId. Let’s use ‘U-BT’ as an example:
$ vi Platform/ApollolakeBoardPkg/CfgData/CfgData_Int_LeafHill.dlt -GEN_CFG_DATA.PayloadId | 'AUTO +GEN_CFG_DATA.PayloadId | 'U-BT'
Update payload text base.
PAYLOAD_EXE_BASE must be the same as U-Boot CONFIG_SYS_TEXT_BASE in board/intel/slimbootloader/Kconfig.
PAYLOAD_LOAD_HIGH must be 0:
$ vi Platform/ApollolakeBoardPkg/BoardConfig.py + self.PAYLOAD_LOAD_HIGH = 0 + self.PAYLOAD_EXE_BASE = 0x00100000
Build APL target. Make sure u-boot-dtb.bin and U-BT PayloadId in build command. The output is Outputs/apl/Stitch_Components.zip:
$ python BuildLoader.py build apl -p "OsLoader.efi:LLDR:Lz4;u-boot-dtb.bin:U-BT:Lzma"
Stitch IFWI.
Refer to Apollolake page in Slim Bootloader document site:
$ python Platform/ApollolakeBoardPkg/Script/StitchLoader.py -i <Existing IFWI> -s Outputs/apl/Stitch_Components.zip -o <Output IFWI>
Flash IFWI.
Use DediProg to flash IFWI. You should reach at U-Boot serial console.
Build Instruction to use ELF U-Boot¶
Enable CONFIG_OF_EMBED:
$ vi configs/slimbootloader_defconfig +CONFIG_OF_EMBED=y
Build U-Boot:
$ make distclean $ make slimbootloader_defconfig $ make all $ strip u-boot (removing symbol for reduced size)
Do same steps as above
Copy u-boot (ELF) to PayloadBins directory
Update PayloadId ‘U-BT’ as above.
No need to set PAYLOAD_LOAD_HIGH and PAYLOAD_EXE_BASE.
Build Slim Bootloader. Use u-boot instead of u-boot-dtb.bin:
$ python BuildLoader.py build <qemu or apl> -p "OsLoader.efi:LLDR:Lz4;u-boot:U-BT:Lzma"