README.mxs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. Booting U-Boot on a MXS processor
  2. =================================
  3. This document describes the MXS U-Boot port. This document mostly covers topics
  4. related to making the module/board bootable.
  5. Terminology
  6. -----------
  7. The term "MXS" refers to a family of Freescale SoCs that is composed by MX23
  8. and MX28.
  9. The dollar symbol ($) introduces a snipped of shell code. This shall be typed
  10. into the unix command prompt in U-Boot source code root directory.
  11. The (=>) introduces a snipped of code that should by typed into U-Boot command
  12. prompt
  13. Contents
  14. --------
  15. 1) Prerequisites
  16. 2) Compiling U-Boot for a MXS based board
  17. 3) Installation of U-Boot for a MXS based board to SD card
  18. 4) Installation of U-Boot into NAND flash on a MX28 based board
  19. 5) Installation of U-Boot into SPI NOR flash on a MX28 based board
  20. 1) Prerequisites
  21. ----------------
  22. To make a MXS based board bootable, some tools are necessary. The only
  23. mandatory tool is the "mxsboot" tool found in U-Boot source tree. The
  24. tool is built automatically when compiling U-Boot for i.MX23 or i.MX28.
  25. The production of BootStream image is handled via "mkimage", which is
  26. also part of the U-Boot source tree. The "mkimage" requires OpenSSL
  27. development libraries to be installed. In case of Debian and derivates,
  28. this is installed by running:
  29. $ sudo apt-get install libssl-dev
  30. NOTE: The "elftosb" tool distributed by Freescale Semiconductor is no
  31. longer necessary for general use of U-Boot on i.MX23 and i.MX28.
  32. The mkimage supports generation of BootStream images encrypted
  33. with a zero key, which is the vast majority of use-cases. In
  34. case you do need to produce image encrypted with non-zero key
  35. or other special features, please use the "elftosb" tool,
  36. otherwise continue to section 2). The installation procedure of
  37. the "elftosb" is outlined below:
  38. Firstly, obtain the elftosb archive from the following location:
  39. ftp://ftp.denx.de/pub/tools/elftosb-10.12.01.tar.gz
  40. We use a $VER variable here to denote the current version. At the time of
  41. writing of this document, that is "10.12.01". To obtain the file from command
  42. line, use:
  43. $ VER="10.12.01"
  44. $ wget ftp://ftp.denx.de/pub/tools/elftosb-${VER}.tar.gz
  45. Extract the file:
  46. $ tar xzf elftosb-${VER}.tar.gz
  47. Compile the file. We need to manually tell the linker to use also libm:
  48. $ cd elftosb-${VER}/
  49. $ make LIBS="-lstdc++ -lm" elftosb
  50. Optionally, remove debugging symbols from elftosb:
  51. $ strip bld/linux/elftosb
  52. Finally, install the "elftosb" binary. The "install" target is missing, so just
  53. copy the binary by hand:
  54. $ sudo cp bld/linux/elftosb /usr/local/bin/
  55. Make sure the "elftosb" binary can be found in your $PATH, in this case this
  56. means "/usr/local/bin/" has to be in your $PATH.
  57. 2) Compiling U-Boot for a MXS based board
  58. -------------------------------------------
  59. Compiling the U-Boot for a MXS board is straightforward and done as compiling
  60. U-Boot for any other ARM device. For cross-compiler setup, please refer to
  61. ELDK5.0 documentation. First, clean up the source code:
  62. $ make mrproper
  63. Next, configure U-Boot for a MXS based board
  64. $ make <mxs_based_board_name>_config
  65. Examples:
  66. 1. For building U-Boot for Denx M28EVK board:
  67. $ make m28evk_config
  68. 2. For building U-Boot for Freescale MX28EVK board:
  69. $ make mx28evk_config
  70. 3. For building U-Boot for Freescale MX23EVK board:
  71. $ make mx23evk_config
  72. 4. For building U-Boot for Olimex MX23 Olinuxino board:
  73. $ make mx23_olinuxino_config
  74. Lastly, compile U-Boot and prepare a "BootStream". The "BootStream" is a special
  75. type of file, which MXS CPUs can boot. This is handled by the following
  76. command:
  77. $ make u-boot.sb
  78. HINT: To speed-up the build process, you can add -j<N>, where N is number of
  79. compiler instances that'll run in parallel.
  80. The code produces "u-boot.sb" file. This file needs to be augmented with a
  81. proper header to allow successful boot from SD or NAND. Adding the header is
  82. discussed in the following chapters.
  83. NOTE: The process that produces u-boot.sb uses the mkimage to generate the
  84. BootStream. The BootStream is encrypted with zero key. In case you need
  85. some special features of the BootStream and plan on using the "elftosb"
  86. tool instead, the invocation to produce a compatible BootStream with the
  87. one produced by mkimage is outlined below. For further details, refer to
  88. the documentation bundled with the "elftosb" package.
  89. $ elftosb -zf imx23 -c arch/arm/cpu/arm926ejs/mxs/u-boot-imx23.bd \
  90. -o u-boot.sb
  91. $ elftosb -zf imx28 -c arch/arm/cpu/arm926ejs/mxs/u-boot-imx28.bd \
  92. -o u-boot.sb
  93. 3) Installation of U-Boot for a MXS based board to SD card
  94. ----------------------------------------------------------
  95. To boot a MXS based board from SD, set the boot mode DIP switches according to
  96. to MX28 manual, section 12.2.1 (Table 12-2) or MX23 manual, section 35.1.2
  97. (Table 35-3).
  98. The SD card used to boot U-Boot must contain a DOS partition table, which in
  99. turn carries a partition of special type and which contains a special header.
  100. The rest of partitions in the DOS partition table can be used by the user.
  101. To prepare such partition, use your favourite partitioning tool. The partition
  102. must have the following parameters:
  103. * Start sector .......... sector 2048
  104. * Partition size ........ at least 1024 kb
  105. * Partition type ........ 0x53 (sometimes "OnTrack DM6 Aux3")
  106. For example in Linux fdisk, the sequence for a clear card follows. Be sure to
  107. run fdisk with the option "-u=sectors" to set units to sectors:
  108. * o ..................... create a clear partition table
  109. * n ..................... create new partition
  110. * p ............. primary partition
  111. * 1 ............. first partition
  112. * 2048 .......... first sector is 2048
  113. * +1M ........... make the partition 1Mb big
  114. * t 1 ................... change first partition ID
  115. * 53 ............ change the ID to 0x53 (OnTrack DM6 Aux3)
  116. * <create other partitions>
  117. * w ..................... write partition table to disk
  118. The partition layout is ready, next the special partition must be filled with
  119. proper contents. The contents is generated by running the following command
  120. (see chapter 2)):
  121. $ ./tools/mxsboot sd u-boot.sb u-boot.sd
  122. The resulting file, "u-boot.sd", shall then be written to the partition. In this
  123. case, we assume the first partition of the SD card is /dev/mmcblk0p1:
  124. $ dd if=u-boot.sd of=/dev/mmcblk0p1
  125. Last step is to insert the card into the MXS based board and boot.
  126. NOTE: If the user needs to adjust the start sector, the "mxsboot" tool contains
  127. a "-p" switch for that purpose. The "-p" switch takes the sector number as
  128. an argument.
  129. 4) Installation of U-Boot into NAND flash on a MX28 based board
  130. ---------------------------------------------------------------
  131. To boot a MX28 based board from NAND, set the boot mode DIP switches according
  132. to MX28 manual section 12.2.1 (Table 12-2), PORT=GPMI, NAND 1.8 V.
  133. There are two possibilities when preparing an image writable to NAND flash.
  134. I) The NAND wasn't written at all yet or the BCB is broken
  135. ----------------------------------------------------------
  136. In this case, both BCB (FCB and DBBT) and firmware needs to be
  137. written to NAND. To generate NAND image containing all these,
  138. there is a tool called "mxsboot" in the "tools/" directory. The tool
  139. is invoked on "u-boot.sb" file from chapter 2):
  140. $ ./tools/mxsboot nand u-boot.sb u-boot.nand
  141. NOTE: The above invokation works for NAND flash with geometry of
  142. 2048b per page, 64b OOB data, 128kb erase size. If your chip
  143. has a different geometry, please use:
  144. -w <size> change page size (default 2048 b)
  145. -o <size> change oob size (default 64 b)
  146. -e <size> change erase size (default 131072 b)
  147. The geometry information can be obtained from running U-Boot
  148. on the MX28 board by issuing the "nand info" command.
  149. The resulting file, "u-boot.nand" can be written directly to NAND
  150. from the U-Boot prompt. To simplify the process, the U-Boot default
  151. environment contains script "update_nand_full" to update the system.
  152. This script expects a working TFTP server containing the file
  153. "u-boot.nand" in it's root directory. This can be changed by
  154. adjusting the "update_nand_full_filename" variable.
  155. To update the system, run the following in U-Boot prompt:
  156. => run update_nand_full
  157. In case you would only need to update the bootloader in future,
  158. see II) below.
  159. II) The NAND was already written with a good BCB
  160. ------------------------------------------------
  161. This part applies after the part I) above was done at least once.
  162. If part I) above was done correctly already, there is no need to
  163. write the FCB and DBBT parts of NAND again. It's possible to upgrade
  164. only the bootloader image.
  165. To simplify the process of firmware update, the U-Boot default
  166. environment contains script "update_nand_firmware" to update only
  167. the firmware, without rewriting FCB and DBBT.
  168. This script expects a working TFTP server containing the file
  169. "u-boot.sb" in it's root directory. This can be changed by
  170. adjusting the "update_nand_firmware_filename" variable.
  171. To update the system, run the following in U-Boot prompt:
  172. => run update_nand_firmware
  173. III) Special settings for the update scripts
  174. --------------------------------------------
  175. There is a slight possibility of the user wanting to adjust the
  176. STRIDE and COUNT options of the NAND boot. For description of these,
  177. see MX28 manual section 12.12.1.2 and 12.12.1.3.
  178. The update scripts take this possibility into account. In case the
  179. user changes STRIDE by blowing fuses, the user also has to change
  180. "update_nand_stride" variable. In case the user changes COUNT by
  181. blowing fuses, the user also has to change "update_nand_count"
  182. variable for the update scripts to work correctly.
  183. In case the user needs to boot a firmware image bigger than 1Mb, the
  184. user has to adjust the "update_nand_firmware_maxsz" variable for the
  185. update scripts to work properly.
  186. 5) Installation of U-Boot into SPI NOR flash on a MX28 based board
  187. ------------------------------------------------------------------
  188. The u-boot.sb file can be directly written to SPI NOR from U-Boot prompt.
  189. Load u-boot.sb into RAM, this can be done in several ways and one way is to use
  190. tftp:
  191. => tftp u-boot.sb 0x42000000
  192. Probe the SPI NOR flash:
  193. => sf probe
  194. (SPI NOR should be succesfully detected in this step)
  195. Erase the blocks where U-Boot binary will be written to:
  196. => sf erase 0x0 0x80000
  197. Write u-boot.sb to SPI NOR:
  198. => sf write 0x42000000 0 0x80000
  199. Power off the board and set the boot mode DIP switches to boot from the SPI NOR
  200. according to MX28 manual section 12.2.1 (Table 12-2)
  201. Last step is to power up the board and U-Boot should start from SPI NOR.