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