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