README.falcon 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. Falcon boot option
  2. ------------------
  3. Falcon boot is a short cut boot method for SD/eMMC targets. It skips loading the
  4. RAM version U-Boot. Instead, it loads FIT image and boot directly to Linux.
  5. CONFIG_SPL_OS_BOOT enables falcon boot. CONFIG_SPL_LOAD_FIT enables the FIT
  6. image support (also need CONFIG_SPL_OF_LIBFDT, CONFIG_SPL_FIT and optionally
  7. CONFIG_SPL_GZIP).
  8. To enable falcon boot, a hook function spl_start_uboot() returns 0 to indicate
  9. booting U-Boot is not the first choice. The kernel FIT image needs to be put
  10. at CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR. SPL mmc driver reads the header to
  11. determine if this is a FIT image. If true, FIT image components are parsed and
  12. copied or decompressed (if applicable) to their destinations. If FIT image is
  13. not found, normal U-Boot flow will follow.
  14. An important part of falcon boot is to prepare the device tree. A normal U-Boot
  15. does FDT fixups when booting Linux. For falcon boot, Linux boots directly from
  16. SPL, skipping the normal U-Boot. The device tree has to be prepared in advance.
  17. A command "spl export" should be called under the normal RAM version U-Boot.
  18. It is equivalent to go through "bootm" step-by-step until device tree fixup is
  19. done. The device tree in memory is the one needed for falcon boot. Falcon boot
  20. flow suggests to save this image to SD/eMMC at the location pointed by macro
  21. CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR, with maximum size specified by macro
  22. CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS. However, when FIT image is used for
  23. Linux, the device tree stored in FIT image overwrites the memory loaded by spl
  24. driver from these sectors. We could change this loading order to favor the
  25. stored sectors. But when secure boot is enabled, these sectors are used for
  26. signature header and needs to be loaded before the FIT image. So it is important
  27. to understand the device tree in FIT image should be the one actually used, or
  28. leave it absent to favor the stored sectors. It is easier to deploy the FIT
  29. image with embedded static device tree to multiple boards.
  30. Macro CONFIG_SYS_SPL_ARGS_ADDR serves two purposes. One is the pointer to load
  31. the stored sectors to. Normally this is the static device tree. The second
  32. purpose is the memory location of signature header for secure boot. After the
  33. FIT image is loaded into memory, it is validated against the signature header
  34. before individual components are extracted (and optionally decompressed) into
  35. their final memory locations, respectively. After the validation, the header
  36. is no longer used. The static device tree is copied into this location. So
  37. this macro is passed as the location of device tree when booting Linux.
  38. Steps to prepare static device tree
  39. -----------------------------------
  40. To prepare the static device tree for Layerscape boards, it is important to
  41. understand the fixups in U-Boot. Memory size and location, as well as reserved
  42. memory blocks are added/updated. Ethernet MAC addressed are updated. FMan
  43. microcode (if used) is embedded in the device tree. Kernel command line and
  44. initrd information are embedded. Others including CPU status, boot method,
  45. Ethernet port status, etc. are also updated.
  46. Following normal booting process, all variables are set, all images are loaded
  47. before "bootm" command would be issued to boot, run command
  48. spl export fdt <address>
  49. where the address is the location of FIT image. U-Boot goes through the booting
  50. process as if "bootm start", "bootm loados", "bootm ramdisk"... commands but
  51. stops before "bootm go". There we have the fixed-up device tree in memory.
  52. We can check the device tree header by these commands
  53. fdt addr <fdt address>
  54. fdt header
  55. Where the fdt address is the device tree in memory. It is printed by U-Boot.
  56. It is useful to know the exact size. One way to extract this static device
  57. tree is to save it to eMMC/SD using command in U-Boot, and extract under Linux
  58. with these commands, repectively
  59. mmc write <address> <sector> <sectors>
  60. dd if=/dev/mmcblk0 of=<filename> bs=512 skip=<sector> count=<sectors>
  61. Note, U-Boot takes values as hexadecimals while Linux takes them as decimals by
  62. default. If using NAND or other storage, the commands are slightly different.
  63. When we have the static device tree image, we can re-make the FIT image with
  64. it. It is important to specify the load addresses in FIT image for every
  65. components. Otherwise U-Boot cannot load them correctly.
  66. Generate FIT image with static device tree
  67. ------------------------------------------
  68. Example:
  69. /dts-v1/;
  70. / {
  71. description = "Image file for the LS1043A Linux Kernel";
  72. #address-cells = <1>;
  73. images {
  74. kernel {
  75. description = "ARM64 Linux kernel";
  76. data = /incbin/("./arch/arm64/boot/Image.gz");
  77. type = "kernel";
  78. arch = "arm64";
  79. os = "linux";
  80. compression = "gzip";
  81. load = <0x80080000>;
  82. entry = <0x80080000>;
  83. };
  84. fdt-1 {
  85. description = "Flattened Device Tree blob";
  86. data = /incbin/("./fsl-ls1043ardb-static.dtb");
  87. type = "flat_dt";
  88. arch = "arm64";
  89. compression = "none";
  90. load = <0x90000000>;
  91. };
  92. ramdisk {
  93. description = "LS1043 Ramdisk";
  94. data = /incbin/("./rootfs.cpio.gz");
  95. type = "ramdisk";
  96. arch = "arm64";
  97. os = "linux";
  98. compression = "none";
  99. load = <0xa0000000>;
  100. };
  101. };
  102. configurations {
  103. default = "config-1";
  104. config-1 {
  105. description = "Boot Linux kernel";
  106. kernel = "kernel";
  107. fdt = "fdt-1";
  108. ramdisk = "ramdisk";
  109. loadables = "fdt", "ramdisk";
  110. };
  111. };
  112. };
  113. The "loadables" is not optional. It tells SPL which images to load into memory.
  114. Falcon mode with QSPI boot
  115. --------------------------
  116. To use falcon mode with QSPI boot, SPL needs to be enabled. Similar to SD or
  117. NAND boot, a RAM version full feature U-Boot is needed. Unlike SD or NAND boot,
  118. SPL with QSPI doesn't need to combine SPL image with RAM version image. Two
  119. separated images are used, u-boot-spl.pbl and u-boot.img. The former is SPL
  120. image with RCW and PBI commands to load the SPL payload into On-Chip RAM. The
  121. latter is RAM version U-Boot in FIT format (or legacy format if FIT is not
  122. used).
  123. Other things to consider
  124. -----------------------
  125. Falcon boot skips a lot of initialization in U-Boot. If Linux expects the
  126. hardware to be initialized by U-Boot, the related code should be ported to SPL
  127. build. For example, if Linux expect Ethernet PHY to be initialized in U-Boot
  128. (which is not a common case), the PHY initialization has to be included in
  129. falcon boot. This increases the SPL image size and should be handled carefully.
  130. If Linux has PHY driver enabled, it still depends on the correct MDIO bus setup
  131. in U-Boot. Normal U-Boot sets the MDC ratio to generate a proper clock signal.