slimbootloader.rst 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. .. sectionauthor:: Aiden Park <aiden.park@intel.com>
  3. Slim Bootloader
  4. ===============
  5. Introduction
  6. ------------
  7. This target is to enable U-Boot_ as a payload of `Slim Bootloader`_ (a.k.a SBL)
  8. boot firmware which currently supports QEMU, Apollolake, Whiskeylake,
  9. Coffeelake-R platforms.
  10. The `Slim Bootloader`_ is designed with multi-stages (Stage1A/B, Stage2, Payload)
  11. architecture to cover from reset vector to OS booting and it consumes
  12. `Intel FSP`_ for silicon initialization.
  13. * Stage1A: Reset vector, CAR init with FSP-T
  14. * Stage1B: Memory init with FSP-M, CAR teardown, Continue execution in memory
  15. * Stage2 : Rest of Silicon init with FSP-S, Create HOB, Hand-off to Payload
  16. * Payload: Payload init with HOB, Load OS from media, Booting OS
  17. The Slim Bootloader stages (Stage1A/B, Stage2) focus on chipset, hardware and
  18. platform specific initialization, and it provides useful information to a
  19. payload in a HOB (Hand-Off Block) which has serial port, memory map, performance
  20. data info and so on. This is Slim Bootloader architectural design to make a
  21. payload light-weight, platform independent and more generic across different
  22. boot solutions or payloads, and to minimize hardware re-initialization in a
  23. payload.
  24. Build Instruction for U-Boot as a Slim Bootloader payload
  25. ---------------------------------------------------------
  26. Build U-Boot and obtain u-boot-dtb.bin::
  27. $ make distclean
  28. $ make slimbootloader_defconfig
  29. $ make all
  30. Prepare Slim Bootloader
  31. -----------------------
  32. 1. Setup Build Environment for Slim Bootloader.
  33. Refer to `Getting Started`_ page in `Slim Bootloader`_ document site.
  34. 2. Get source code. Let's simply clone the repo::
  35. $ git clone https://github.com/slimbootloader/slimbootloader.git
  36. 3. Copy u-boot-dtb.bin to Slim Bootloader.
  37. Slim Bootloader looks for a payload from the specific location.
  38. Copy the build u-boot-dtb.bin to the expected location::
  39. $ mkdir -p <Slim Bootloader Dir>/PayloadPkg/PayloadBins/
  40. $ cp <U-Boot Dir>/u-boot-dtb.bin <Slim Bootloader Dir>/PayloadPkg/PayloadBins/u-boot-dtb.bin
  41. Build Instruction for Slim Bootloader for QEMU target
  42. -----------------------------------------------------
  43. Slim Bootloader supports multiple payloads, and a board of Slim Bootloader
  44. detects its target payload by PayloadId in board configuration.
  45. The PayloadId can be any 4 Bytes value.
  46. 1. Update PayloadId. Let's use 'U-BT' as an example::
  47. $ vi Platform/QemuBoardPkg/CfgData/CfgDataExt_Brd1.dlt
  48. -GEN_CFG_DATA.PayloadId | 'AUTO'
  49. +GEN_CFG_DATA.PayloadId | 'U-BT'
  50. 2. Update payload text base. PAYLOAD_EXE_BASE must be the same as U-Boot
  51. CONFIG_SYS_TEXT_BASE in board/intel/slimbootloader/Kconfig.
  52. PAYLOAD_LOAD_HIGH must be 0::
  53. $ vi Platform/QemuBoardPkg/BoardConfig.py
  54. + self.PAYLOAD_LOAD_HIGH = 0
  55. + self.PAYLOAD_EXE_BASE = 0x00100000
  56. 3. Build QEMU target. Make sure u-boot-dtb.bin and U-BT PayloadId
  57. in build command. The output is Outputs/qemu/SlimBootloader.bin::
  58. $ python BuildLoader.py build qemu -p "OsLoader.efi:LLDR:Lz4;u-boot-dtb.bin:U-BT:Lzma"
  59. 4. Launch Slim Bootloader on QEMU.
  60. You should reach at U-Boot serial console::
  61. $ qemu-system-x86_64 -machine q35 -nographic -serial mon:stdio -pflash Outputs/qemu/SlimBootloader.bin
  62. Test Linux booting on QEMU target
  63. ---------------------------------
  64. Let's use LeafHill (APL) Yocto image for testing.
  65. Download it from http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/machines/leafhill/.
  66. 1. Prepare Yocto hard disk image::
  67. $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/machines/leafhill/leafhill-4.0-jethro-2.0.tar.bz2
  68. $ tar -xvf leafhill-4.0-jethro-2.0.tar.bz2
  69. $ ls -l leafhill-4.0-jethro-2.0/binary/core-image-sato-intel-corei7-64.hddimg
  70. 2. Launch Slim Bootloader on QEMU with disk image::
  71. $ 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
  72. 3. Update boot environment values on shell::
  73. => setenv bootfile vmlinuz
  74. => setenv bootdev scsi
  75. => boot
  76. Build Instruction for Slim Bootloader for LeafHill (APL) target
  77. ---------------------------------------------------------------
  78. Prepare U-Boot and Slim Bootloader as described at the beginning of this page.
  79. Also, the PayloadId needs to be set for APL board.
  80. 1. Update PayloadId. Let's use 'U-BT' as an example::
  81. $ vi Platform/ApollolakeBoardPkg/CfgData/CfgData_Int_LeafHill.dlt
  82. -GEN_CFG_DATA.PayloadId | 'AUTO
  83. +GEN_CFG_DATA.PayloadId | 'U-BT'
  84. 2. Update payload text base.
  85. * PAYLOAD_EXE_BASE must be the same as U-Boot CONFIG_SYS_TEXT_BASE
  86. in board/intel/slimbootloader/Kconfig.
  87. * PAYLOAD_LOAD_HIGH must be 0::
  88. $ vi Platform/ApollolakeBoardPkg/BoardConfig.py
  89. + self.PAYLOAD_LOAD_HIGH = 0
  90. + self.PAYLOAD_EXE_BASE = 0x00100000
  91. 3. Build APL target. Make sure u-boot-dtb.bin and U-BT PayloadId
  92. in build command. The output is Outputs/apl/Stitch_Components.zip::
  93. $ python BuildLoader.py build apl -p "OsLoader.efi:LLDR:Lz4;u-boot-dtb.bin:U-BT:Lzma"
  94. 4. Stitch IFWI.
  95. Refer to Apollolake_ page in Slim Bootloader document site::
  96. $ python Platform/ApollolakeBoardPkg/Script/StitchLoader.py -i <Existing IFWI> -s Outputs/apl/Stitch_Components.zip -o <Output IFWI>
  97. 5. Flash IFWI.
  98. Use DediProg to flash IFWI. You should reach at U-Boot serial console.
  99. Build Instruction to use ELF U-Boot
  100. -----------------------------------
  101. 1. Enable CONFIG_OF_EMBED::
  102. $ vi configs/slimbootloader_defconfig
  103. +CONFIG_OF_EMBED=y
  104. 2. Build U-Boot::
  105. $ make distclean
  106. $ make slimbootloader_defconfig
  107. $ make all
  108. $ strip u-boot (removing symbol for reduced size)
  109. 3. Do same steps as above
  110. * Copy u-boot (ELF) to PayloadBins directory
  111. * Update PayloadId 'U-BT' as above.
  112. * No need to set PAYLOAD_LOAD_HIGH and PAYLOAD_EXE_BASE.
  113. * Build Slim Bootloader. Use u-boot instead of u-boot-dtb.bin::
  114. $ python BuildLoader.py build <qemu or apl> -p "OsLoader.efi:LLDR:Lz4;u-boot:U-BT:Lzma"
  115. .. _U-Boot: https://source.denx.de/
  116. .. _`Slim Bootloader`: https://github.com/slimbootloader/
  117. .. _`Intel FSP`: https://github.com/IntelFsp/
  118. .. _`Getting Started`: https://slimbootloader.github.io/getting-started/
  119. .. _Apollolake: https://slimbootloader.github.io/supported-hardware/apollo-lake-crb.html#stitching