imximage.txt 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. ---------------------------------------------
  2. Imximage Boot Image generation using mkimage
  3. ---------------------------------------------
  4. This document describes how to set up a U-Boot image that can be booted
  5. by Freescale MX25, MX35, MX51, MX53 and MX6 processors via internal boot
  6. mode.
  7. These processors can boot directly from NAND, SPI flash and SD card flash
  8. using its internal boot ROM support. MX6 processors additionally support
  9. boot from NOR flash and SATA disks. All processors can boot from an internal
  10. UART, if booting from device media fails.
  11. Booting from NOR flash does not require to use this image type.
  12. For more details refer Chapter 2 - System Boot and section 2.14
  13. (flash header description) of the processor's manual.
  14. Command syntax:
  15. --------------
  16. ./tools/mkimage -l <mx u-boot_file>
  17. to list the imx image file details
  18. ./tools/mkimage -T imximage \
  19. -n <board specific configuration file> \
  20. -e <execution address> -d <u-boot binary> <output image file>
  21. For example, for the mx51evk board:
  22. ./tools/mkimage -n ./board/freescale/mx51evk/imximage.cfg \
  23. -T imximage -e 0x97800000 \
  24. -d u-boot.bin u-boot.imx
  25. You can generate directly the image when you compile u-boot with:
  26. $ make u-boot.imx
  27. The output image can be flashed on the board SPI flash or on a SD card.
  28. In both cases, you have to copy the image at the offset required for the
  29. chosen media devices (0x400 for both SPI flash or SD card).
  30. Please check Freescale documentation for further details.
  31. Board specific configuration file specifications:
  32. -------------------------------------------------
  33. 1. This file must present in the $(BOARDDIR) and the name should be
  34. imximage.cfg (since this is used in Makefile).
  35. 2. This file can have empty lines and lines starting with "#" as first
  36. character to put comments.
  37. 3. This file can have configuration command lines as mentioned below,
  38. any other information in this file is treated as invalid.
  39. Configuration command line syntax:
  40. ---------------------------------
  41. 1. Each command line is must have two strings, first one command or address
  42. and second one data string
  43. 2. Following are the valid command strings and associated data strings:-
  44. Command string data string
  45. -------------- -----------
  46. IMXIMAGE_VERSION 1/2
  47. 1 is for mx25/mx35/mx51 compatible,
  48. 2 is for mx53/mx6 compatible,
  49. others is invalid and error is generated.
  50. This command need appear the fist before
  51. other valid commands in configuration file.
  52. BOOT_OFFSET value
  53. This command is parallel to BOOT_FROM and
  54. is preferred over BOOT_FROM.
  55. value: Offset of the image header, this
  56. value shall be set to one of the
  57. values found in the file:
  58. arch/arm/include/asm/\
  59. mach-imx/imximage.cfg
  60. Example:
  61. BOOT_OFFSET FLASH_OFFSET_STANDARD
  62. BOOT_FROM nand/spi/sd/onenand/nor/sata
  63. This command is parallel to BOOT_OFFSET and
  64. is to be deprecated in favor of BOOT_OFFSET.
  65. Example:
  66. BOOT_FROM spi
  67. CSF value
  68. Total size of CSF (Command Sequence File)
  69. used for Secure Boot/ High Assurance Boot
  70. (HAB).
  71. Using this command will populate the IVT
  72. (Initial Vector Table) CSF pointer and adjust
  73. the length fields only. The CSF itself needs
  74. to be generated with Freescale tools and
  75. 'manually' appended to the u-boot.imx file.
  76. The CSF is then simply concatenated
  77. to the u-boot image, making a signed bootloader,
  78. that the processor can verify
  79. if the fuses for the keys are burned.
  80. Further infos how to configure the SOC to verify
  81. the bootloader can be found in the "High
  82. Assurance Boot Version Application Programming
  83. Interface Reference Manual" as part of the
  84. Freescale Code Signing Tool, available on the
  85. manufacturer's website.
  86. Example:
  87. CSF 0x2000
  88. DATA type address value
  89. type: word=4, halfword=2, byte=1
  90. address: physycal register address
  91. value: value to be set in register
  92. All values are in in hexadecimal.
  93. Example (write to IOMUXC):
  94. DATA 4 0x73FA88a0 0x200
  95. The processor support up to 60 register programming commands for IMXIMAGE_VERSION 1
  96. and 220 register programming commands for IMXIMAGE_VERSION 2.
  97. An error is generated if more commands are found in the configuration file.
  98. 3. All commands are optional to program.
  99. Setup a SD Card for booting
  100. --------------------------------
  101. The following example prepare a SD card with u-boot and a FAT partition
  102. to be used to stored the kernel to be booted.
  103. I will set the SD in the most compatible mode, setting it with
  104. 255 heads and 63 sectors, as suggested from several documentation and
  105. howto on line (I took as reference the preparation of a SD Card for the
  106. Beagleboard, running u-boot as bootloader).
  107. You should start clearing the partitions table on the SD card. Because
  108. the u-boot image must be stored at the offset 0x400, it must be assured
  109. that there is no partition at that address. A new SD card is already
  110. formatted with FAT filesystem and the partition starts from the first
  111. cylinder, so we need to change it.
  112. You can do all steps with fdisk. If the device for the SD card is
  113. /dev/mmcblk0, the following commands make the job:
  114. 1. Start the fdisk utility (as superuser)
  115. fdisk /dev/mmcblk0
  116. 2. Clear the actual partition
  117. Command (m for help): o
  118. 3. Print card info:
  119. Command (m for help): p
  120. Disk /dev/mmcblk0: 1981 MB, 1981284352 bytes
  121. In my case, I have a 2 GB card. I need the size to set later the correct value
  122. for the cylinders.
  123. 4. Go to expert mode:
  124. Command (m for help): x
  125. 5. Set card geometry
  126. Expert command (m for help): h
  127. Number of heads (1-256, default 4): 255
  128. Expert command (m for help): s
  129. Number of sectors (1-63, default 16): 63
  130. Warning: setting sector offset for DOS compatiblity
  131. We have set 255 heads, 63 sector. We have to set the cylinder.
  132. The value to be set can be calculated with:
  133. cylinder = <total size> / <heads> / <sectors> / <blocksize>
  134. in this example,
  135. 1981284352 / 255 / 63 / 512 = 239.x = 239
  136. Expert command (m for help): c
  137. Number of cylinders (1-1048576, default 60032): 239
  138. 6. Leave the expert mode
  139. Expert command (m for help): r
  140. 7. Set up a partition
  141. Now set a partition table to store the kernel or whatever you want. Of course,
  142. you can set additional partitions to store rootfs, data, etc.
  143. In my example I want to set a single partition. I must take care
  144. to not overwrite the space where I will put u-boot.
  145. Command (m for help): n
  146. Command action
  147. e extended
  148. p primary partition (1-4)
  149. p
  150. Partition number (1-4): 1
  151. First cylinder (1-239, default 1): 3
  152. Last cylinder, +cylinders or +size{K,M,G} (3-239, default 239): +100M
  153. Command (m for help): p
  154. Disk /dev/mmcblk0: 1967 MB, 1967128576 bytes
  155. 255 heads, 63 sectors/track, 239 cylinders
  156. Units = cylinders of 16065 * 512 = 8225280 bytes
  157. Disk identifier: 0xb712a870
  158. Device Boot Start End Blocks Id System
  159. /dev/mmcblk0p1 3 16 112455 83 Linux
  160. I have set 100MB, leaving the first 2 sectors free. I will copy u-boot
  161. there.
  162. 8. Write the partition table and exit.
  163. Command (m for help): w
  164. The partition table has been altered!
  165. Calling ioctl() to re-read partition table.
  166. 9. Copy u-boot.imx on the SD card
  167. I use dd:
  168. dd if=u-boot.imx of=/dev/mmcblk0 bs=512 seek=2
  169. This command copies the u-boot image at the address 0x400, as required
  170. by the processor.
  171. Now remove your card from the PC and go to the target. If evrything went right,
  172. the u-boot prompt should come after power on.
  173. ------------------------------------------------
  174. Author: Stefano babic <sbabic@denx.de>