README.falcon 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. U-Boot Falcon Mode
  2. ====================
  3. Introduction
  4. ------------
  5. This document provides an overview of how to add support for Falcon Mode
  6. to a board.
  7. Falcon Mode is introduced to speed up the booting process, allowing
  8. to boot a Linux kernel (or whatever image) without a full blown U-Boot.
  9. Falcon Mode relies on the SPL framework. In fact, to make booting faster,
  10. U-Boot is split into two parts: the SPL (Secondary Program Loader) and U-Boot
  11. image. In most implementations, SPL is used to start U-Boot when booting from
  12. a mass storage, such as NAND or SD-Card. SPL has now support for other media,
  13. and can generally be seen as a way to start an image performing the minimum
  14. required initialization. SPL mainly initializes the RAM controller, and then
  15. copies U-Boot image into the memory.
  16. The Falcon Mode extends this way allowing to start the Linux kernel directly
  17. from SPL. A new command is added to U-Boot to prepare the parameters that SPL
  18. must pass to the kernel, using ATAGS or Device Tree.
  19. In normal mode, these parameters are generated each time before
  20. loading the kernel, passing to Linux the address in memory where
  21. the parameters can be read.
  22. With Falcon Mode, this snapshot can be saved into persistent storage and SPL is
  23. informed to load it before running the kernel.
  24. To boot the kernel, these steps under a Falcon-aware U-Boot are required:
  25. 1. Boot the board into U-Boot.
  26. Use the "spl export" command to generate the kernel parameters area or the DT.
  27. U-Boot runs as when it boots the kernel, but stops before passing the control
  28. to the kernel.
  29. 2. Save the prepared snapshot into persistent media.
  30. The address where to save it must be configured into board configuration
  31. file (CONFIG_CMD_SPL_NAND_OFS for NAND).
  32. 3. Boot the board into Falcon Mode. SPL will load the kernel and copy
  33. the parameters which are saved in the persistent area to the required address.
  34. It is required to implement a custom mechanism to select if SPL loads U-Boot
  35. or another image.
  36. The value of a GPIO is a simple way to operate the selection, as well as
  37. reading a character from the SPL console if CONFIG_SPL_CONSOLE is set.
  38. Falcon Mode is generally activated by setting CONFIG_SPL_OS_BOOT. This tells
  39. SPL that U-Boot is not the only available image that SPL is able to start.
  40. Configuration
  41. ----------------------------
  42. CONFIG_CMD_SPL Enable the "spl export" command.
  43. The command "spl export" is then available in U-Boot
  44. mode
  45. CONFIG_SYS_SPL_ARGS_ADDR Address in RAM where the parameters must be
  46. copied by SPL.
  47. In most cases, it is <start_of_ram> + 0x100
  48. CONFIG_SYS_NAND_SPL_KERNEL_OFFS Offset in NAND where the kernel is stored
  49. CONFIG_CMD_SPL_NAND_OFS Offset in NAND where the parameters area was saved.
  50. CONFIG_CMD_SPL_WRITE_SIZE Size of the parameters area to be copied
  51. CONFIG_SPL_OS_BOOT Activate Falcon Mode.
  52. Function that a board must implement
  53. ------------------------------------
  54. void spl_board_prepare_for_linux(void) : optional
  55. Called from SPL before starting the kernel
  56. spl_start_uboot() : required
  57. Returns "0" if SPL should start the kernel, "1" if U-Boot
  58. must be started.
  59. Using spl command
  60. -----------------
  61. spl - SPL configuration
  62. Usage:
  63. spl export <img=atags|fdt> [kernel_addr] [initrd_addr] [fdt_addr ]
  64. img : "atags" or "fdt"
  65. kernel_addr : kernel is loaded as part of the boot process, but it is not started.
  66. This is the address where a kernel image is stored.
  67. initrd_addr : Address of initial ramdisk
  68. can be set to "-" if fdt_addr without initrd_addr is used
  69. fdt_addr : in case of fdt, the address of the device tree.
  70. The spl export command does not write to a storage media. The user is
  71. responsible to transfer the gathered information (assembled ATAGS list
  72. or prepared FDT) from temporary storage in RAM into persistant storage
  73. after each run of 'spl export'. Unfortunately the position of temporary
  74. storage can not be predicted nor provided at commandline, it depends
  75. highly on your system setup and your provided data (ATAGS or FDT).
  76. However at the end of an succesful 'spl export' run it will print the
  77. RAM address of temporary storage.
  78. Now the user have to save the generated BLOB from that printed address
  79. to the pre-defined address in persistent storage
  80. (CONFIG_CMD_SPL_NAND_OFS in case of NAND).
  81. The following example shows how to prepare the data for Falcon Mode on
  82. twister board with ATAGS BLOB.
  83. The "spl export" command is prepared to work with ATAGS and FDT. However,
  84. using FDT is at the moment untested. The ppc port (see a3m071 example
  85. later) prepares the fdt blob with the fdt command instead.
  86. Usage on the twister board:
  87. --------------------------------
  88. Using mtd names with the following (default) configuration
  89. for mtdparts:
  90. device nand0 <omap2-nand.0>, # parts = 9
  91. #: name size offset mask_flags
  92. 0: MLO 0x00080000 0x00000000 0
  93. 1: u-boot 0x00100000 0x00080000 0
  94. 2: env1 0x00040000 0x00180000 0
  95. 3: env2 0x00040000 0x001c0000 0
  96. 4: kernel 0x00600000 0x00200000 0
  97. 5: bootparms 0x00040000 0x00800000 0
  98. 6: splashimg 0x00200000 0x00840000 0
  99. 7: mini 0x02800000 0x00a40000 0
  100. 8: rootfs 0x1cdc0000 0x03240000 0
  101. twister => nand read 82000000 kernel
  102. NAND read: device 0 offset 0x200000, size 0x600000
  103. 6291456 bytes read: OK
  104. Now the kernel is in RAM at address 0x82000000
  105. twister => spl export atags 0x82000000
  106. ## Booting kernel from Legacy Image at 82000000 ...
  107. Image Name: Linux-3.5.0-rc4-14089-gda0b7f4
  108. Image Type: ARM Linux Kernel Image (uncompressed)
  109. Data Size: 3654808 Bytes = 3.5 MiB
  110. Load Address: 80008000
  111. Entry Point: 80008000
  112. Verifying Checksum ... OK
  113. Loading Kernel Image ... OK
  114. OK
  115. cmdline subcommand not supported
  116. bdt subcommand not supported
  117. Argument image is now in RAM at: 0x80000100
  118. The result can be checked at address 0x80000100:
  119. twister => md 0x80000100
  120. 80000100: 00000005 54410001 00000000 00000000 ......AT........
  121. 80000110: 00000000 00000067 54410009 746f6f72 ....g.....ATroot
  122. 80000120: 65642f3d 666e2f76 77722073 73666e20 =/dev/nfs rw nfs
  123. The parameters generated with this step can be saved into NAND at the offset
  124. 0x800000 (value for twister for CONFIG_CMD_SPL_NAND_OFS)
  125. nand erase.part bootparms
  126. nand write 0x80000100 bootparms 0x4000
  127. Now the parameters are stored into the NAND flash at the address
  128. CONFIG_CMD_SPL_NAND_OFS (=0x800000).
  129. Next time, the board can be started into Falcon Mode moving the
  130. setting the gpio (on twister gpio 55 is used) to kernel mode.
  131. The kernel is loaded directly by the SPL without passing through U-Boot.
  132. Example with FDT: a3m071 board
  133. -------------------------------
  134. To boot the Linux kernel from the SPL, the DT blob (fdt) needs to get
  135. prepard/patched first. U-Boot usually inserts some dynamic values into
  136. the DT binary (blob), e.g. autodetected memory size, MAC addresses,
  137. clocks speeds etc. To generate this patched DT blob, you can use
  138. the following command:
  139. 1. Load fdt blob to SDRAM:
  140. => tftp 1800000 a3m071/a3m071.dtb
  141. 2. Set bootargs as desired for Linux booting (e.g. flash_mtd):
  142. => run mtdargs addip2 addtty
  143. 3. Use "fdt" commands to patch the DT blob:
  144. => fdt addr 1800000
  145. => fdt boardsetup
  146. => fdt chosen
  147. 4. Display patched DT blob (optional):
  148. => fdt print
  149. 5. Save fdt to NOR flash:
  150. => erase fc060000 fc07ffff
  151. => cp.b 1800000 fc060000 10000
  152. ...
  153. Falcon Mode was presented at the RMLL 2012. Slides are available at:
  154. http://schedule2012.rmll.info/IMG/pdf/LSM2012_UbootFalconMode_Babic.pdf