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