18edcde5eSStefano Babic--------------------------------------------- 28edcde5eSStefano BabicImximage Boot Image generation using mkimage 38edcde5eSStefano Babic--------------------------------------------- 48edcde5eSStefano Babic 519b409c0SDirk BehmeThis document describes how to set up a U-Boot image that can be booted 619b409c0SDirk Behmeby Freescale MX25, MX35, MX51, MX53 and MX6 processors via internal boot 719b409c0SDirk Behmemode. 88edcde5eSStefano Babic 98edcde5eSStefano BabicThese processors can boot directly from NAND, SPI flash and SD card flash 1019b409c0SDirk Behmeusing its internal boot ROM support. MX6 processors additionally support 1119b409c0SDirk Behmeboot from NOR flash and SATA disks. All processors can boot from an internal 128edcde5eSStefano BabicUART, if booting from device media fails. 138edcde5eSStefano BabicBooting from NOR flash does not require to use this image type. 148edcde5eSStefano Babic 158edcde5eSStefano BabicFor more details refer Chapter 2 - System Boot and section 2.14 168edcde5eSStefano Babic(flash header description) of the processor's manual. 178edcde5eSStefano Babic 188edcde5eSStefano BabicCommand syntax: 198edcde5eSStefano Babic-------------- 208edcde5eSStefano Babic./tools/mkimage -l <mx u-boot_file> 218edcde5eSStefano Babic to list the imx image file details 228edcde5eSStefano Babic 238edcde5eSStefano Babic./tools/mkimage -T imximage \ 248edcde5eSStefano Babic -n <board specific configuration file> \ 258edcde5eSStefano Babic -e <execution address> -d <u-boot binary> <output image file> 268edcde5eSStefano Babic 278edcde5eSStefano BabicFor example, for the mx51evk board: 288edcde5eSStefano Babic./tools/mkimage -n ./board/freescale/mx51evk/imximage.cfg \ 298edcde5eSStefano Babic -T imximage -e 0x97800000 \ 308edcde5eSStefano Babic -d u-boot.bin u-boot.imx 318edcde5eSStefano Babic 328edcde5eSStefano BabicYou can generate directly the image when you compile u-boot with: 338edcde5eSStefano Babic 348edcde5eSStefano Babic$ make u-boot.imx 358edcde5eSStefano Babic 368edcde5eSStefano BabicThe output image can be flashed on the board SPI flash or on a SD card. 378edcde5eSStefano BabicIn both cases, you have to copy the image at the offset required for the 388edcde5eSStefano Babicchosen media devices (0x400 for both SPI flash or SD card). 398edcde5eSStefano Babic 408edcde5eSStefano BabicPlease check Freescale documentation for further details. 418edcde5eSStefano Babic 428edcde5eSStefano BabicBoard specific configuration file specifications: 438edcde5eSStefano Babic------------------------------------------------- 448edcde5eSStefano Babic1. This file must present in the $(BOARDDIR) and the name should be 458edcde5eSStefano Babic imximage.cfg (since this is used in Makefile). 468edcde5eSStefano Babic2. This file can have empty lines and lines starting with "#" as first 478edcde5eSStefano Babic character to put comments. 488edcde5eSStefano Babic3. This file can have configuration command lines as mentioned below, 498edcde5eSStefano Babic any other information in this file is treated as invalid. 508edcde5eSStefano Babic 518edcde5eSStefano BabicConfiguration command line syntax: 528edcde5eSStefano Babic--------------------------------- 538edcde5eSStefano Babic1. Each command line is must have two strings, first one command or address 548edcde5eSStefano Babic and second one data string 558edcde5eSStefano Babic2. Following are the valid command strings and associated data strings:- 568edcde5eSStefano Babic Command string data string 578edcde5eSStefano Babic -------------- ----------- 588a1edd7dSLiu Hui-R64343 IMXIMAGE_VERSION 1/2 598a1edd7dSLiu Hui-R64343 1 is for mx25/mx35/mx51 compatible, 6019b409c0SDirk Behme 2 is for mx53/mx6 compatible, 618a1edd7dSLiu Hui-R64343 others is invalid and error is generated. 628a1edd7dSLiu Hui-R64343 This command need appear the fist before 638a1edd7dSLiu Hui-R64343 other valid commands in configuration file. 648a1edd7dSLiu Hui-R64343 656cb83829SMarek Vasut BOOT_OFFSET value 666cb83829SMarek Vasut 676cb83829SMarek Vasut This command is parallel to BOOT_FROM and 686cb83829SMarek Vasut is preferred over BOOT_FROM. 696cb83829SMarek Vasut 706cb83829SMarek Vasut value: Offset of the image header, this 716cb83829SMarek Vasut value shall be set to one of the 726cb83829SMarek Vasut values found in the file: 736cb83829SMarek Vasut arch/arm/include/asm/\ 74*552a848eSStefano Babic mach-imx/imximage.cfg 756cb83829SMarek Vasut Example: 766cb83829SMarek Vasut BOOT_OFFSET FLASH_OFFSET_STANDARD 776cb83829SMarek Vasut 7819b409c0SDirk Behme BOOT_FROM nand/spi/sd/onenand/nor/sata 796cb83829SMarek Vasut 806cb83829SMarek Vasut This command is parallel to BOOT_OFFSET and 816cb83829SMarek Vasut is to be deprecated in favor of BOOT_OFFSET. 826cb83829SMarek Vasut 838edcde5eSStefano Babic Example: 848edcde5eSStefano Babic BOOT_FROM spi 856cb83829SMarek Vasut 860187c985SStefano Babic CSF value 870187c985SStefano Babic 880187c985SStefano Babic Total size of CSF (Command Sequence File) 890187c985SStefano Babic used for Secure Boot/ High Assurance Boot 900187c985SStefano Babic (HAB). 910187c985SStefano Babic 920187c985SStefano Babic Using this command will populate the IVT 930187c985SStefano Babic (Initial Vector Table) CSF pointer and adjust 940187c985SStefano Babic the length fields only. The CSF itself needs 950187c985SStefano Babic to be generated with Freescale tools and 960187c985SStefano Babic 'manually' appended to the u-boot.imx file. 970187c985SStefano Babic 980187c985SStefano Babic The CSF is then simply concatenated 990187c985SStefano Babic to the u-boot image, making a signed bootloader, 1000187c985SStefano Babic that the processor can verify 1010187c985SStefano Babic if the fuses for the keys are burned. 1020187c985SStefano Babic 1030187c985SStefano Babic Further infos how to configure the SOC to verify 1040187c985SStefano Babic the bootloader can be found in the "High 1050187c985SStefano Babic Assurance Boot Version Application Programming 1060187c985SStefano Babic Interface Reference Manual" as part of the 1070187c985SStefano Babic Freescale Code Signing Tool, available on the 1080187c985SStefano Babic manufacturer's website. 1090187c985SStefano Babic 1100187c985SStefano Babic Example: 1110187c985SStefano Babic CSF 0x2000 1120187c985SStefano Babic 1138edcde5eSStefano Babic DATA type address value 1148edcde5eSStefano Babic 1158edcde5eSStefano Babic type: word=4, halfword=2, byte=1 1168edcde5eSStefano Babic address: physycal register address 1178edcde5eSStefano Babic value: value to be set in register 1188edcde5eSStefano Babic All values are in in hexadecimal. 1198edcde5eSStefano Babic Example (write to IOMUXC): 1208edcde5eSStefano Babic DATA 4 0x73FA88a0 0x200 1218edcde5eSStefano Babic 1228a1edd7dSLiu Hui-R64343The processor support up to 60 register programming commands for IMXIMAGE_VERSION 1 1236ce79d2fSFabio Estevamand 220 register programming commands for IMXIMAGE_VERSION 2. 1248a1edd7dSLiu Hui-R64343An error is generated if more commands are found in the configuration file. 1258edcde5eSStefano Babic 1268edcde5eSStefano Babic3. All commands are optional to program. 1278edcde5eSStefano Babic 1288edcde5eSStefano BabicSetup a SD Card for booting 1298edcde5eSStefano Babic-------------------------------- 1308edcde5eSStefano Babic 1318edcde5eSStefano BabicThe following example prepare a SD card with u-boot and a FAT partition 1328edcde5eSStefano Babicto be used to stored the kernel to be booted. 1338edcde5eSStefano BabicI will set the SD in the most compatible mode, setting it with 1348edcde5eSStefano Babic255 heads and 63 sectors, as suggested from several documentation and 1358edcde5eSStefano Babichowto on line (I took as reference the preparation of a SD Card for the 1368edcde5eSStefano BabicBeagleboard, running u-boot as bootloader). 1378edcde5eSStefano Babic 1388edcde5eSStefano BabicYou should start clearing the partitions table on the SD card. Because 1398edcde5eSStefano Babicthe u-boot image must be stored at the offset 0x400, it must be assured 1408edcde5eSStefano Babicthat there is no partition at that address. A new SD card is already 1418edcde5eSStefano Babicformatted with FAT filesystem and the partition starts from the first 1428edcde5eSStefano Babiccylinder, so we need to change it. 1438edcde5eSStefano Babic 1448edcde5eSStefano BabicYou can do all steps with fdisk. If the device for the SD card is 1458edcde5eSStefano Babic/dev/mmcblk0, the following commands make the job: 1468edcde5eSStefano Babic 1478edcde5eSStefano Babic1. Start the fdisk utility (as superuser) 1488edcde5eSStefano Babic fdisk /dev/mmcblk0 1498edcde5eSStefano Babic 1508edcde5eSStefano Babic2. Clear the actual partition 1518edcde5eSStefano Babic 1528edcde5eSStefano BabicCommand (m for help): o 1538edcde5eSStefano Babic 1548edcde5eSStefano Babic3. Print card info: 1558edcde5eSStefano Babic 1568edcde5eSStefano BabicCommand (m for help): p 1578edcde5eSStefano BabicDisk /dev/mmcblk0: 1981 MB, 1981284352 bytes 1588edcde5eSStefano Babic 1598edcde5eSStefano BabicIn my case, I have a 2 GB card. I need the size to set later the correct value 1608edcde5eSStefano Babicfor the cylinders. 1618edcde5eSStefano Babic 1628edcde5eSStefano Babic4. Go to expert mode: 1638edcde5eSStefano Babic 1648edcde5eSStefano BabicCommand (m for help): x 1658edcde5eSStefano Babic 1668edcde5eSStefano Babic5. Set card geometry 1678edcde5eSStefano Babic 1688edcde5eSStefano BabicExpert command (m for help): h 1698edcde5eSStefano BabicNumber of heads (1-256, default 4): 255 1708edcde5eSStefano Babic 1718edcde5eSStefano BabicExpert command (m for help): s 1728edcde5eSStefano BabicNumber of sectors (1-63, default 16): 63 1738edcde5eSStefano BabicWarning: setting sector offset for DOS compatiblity 1748edcde5eSStefano Babic 1758edcde5eSStefano BabicWe have set 255 heads, 63 sector. We have to set the cylinder. 1768edcde5eSStefano BabicThe value to be set can be calculated with: 1778edcde5eSStefano Babic 1788edcde5eSStefano Babic cilynder = <total size> / <heads> / <sectors> / <blocksize> 1798edcde5eSStefano Babic 1808edcde5eSStefano Babicin this example, 1818edcde5eSStefano Babic 1981284352 / 255 / 63 / 512 = 239.x = 239 1828edcde5eSStefano Babic 1838edcde5eSStefano Babic 1848edcde5eSStefano BabicExpert command (m for help): c 1858edcde5eSStefano BabicNumber of cylinders (1-1048576, default 60032): 239 1868edcde5eSStefano Babic 1878edcde5eSStefano Babic6. Leave the expert mode 1888edcde5eSStefano BabicExpert command (m for help): r 1898edcde5eSStefano Babic 1908edcde5eSStefano Babic7. Set up a partition 1918edcde5eSStefano Babic 1928edcde5eSStefano BabicNow set a partition table to store the kernel or whatever you want. Of course, 1938edcde5eSStefano Babicyou can set additional partitions to store rootfs, data, etc. 1948edcde5eSStefano BabicIn my example I want to set a single partition. I must take care 1958edcde5eSStefano Babicto not overwrite the space where I will put u-boot. 1968edcde5eSStefano Babic 1978edcde5eSStefano BabicCommand (m for help): n 1988edcde5eSStefano BabicCommand action 1998edcde5eSStefano Babic e extended 2008edcde5eSStefano Babic p primary partition (1-4) 2018edcde5eSStefano Babicp 2028edcde5eSStefano BabicPartition number (1-4): 1 2038edcde5eSStefano BabicFirst cylinder (1-239, default 1): 3 2048edcde5eSStefano BabicLast cylinder, +cylinders or +size{K,M,G} (3-239, default 239): +100M 2058edcde5eSStefano Babic 2068edcde5eSStefano BabicCommand (m for help): p 2078edcde5eSStefano Babic 2088edcde5eSStefano BabicDisk /dev/mmcblk0: 1967 MB, 1967128576 bytes 2098edcde5eSStefano Babic255 heads, 63 sectors/track, 239 cylinders 2108edcde5eSStefano BabicUnits = cylinders of 16065 * 512 = 8225280 bytes 2118edcde5eSStefano BabicDisk identifier: 0xb712a870 2128edcde5eSStefano Babic 2138edcde5eSStefano Babic Device Boot Start End Blocks Id System 2148edcde5eSStefano Babic/dev/mmcblk0p1 3 16 112455 83 Linux 2158edcde5eSStefano Babic 2168edcde5eSStefano BabicI have set 100MB, leaving the first 2 sectors free. I will copy u-boot 2178edcde5eSStefano Babicthere. 2188edcde5eSStefano Babic 2198edcde5eSStefano Babic8. Write the partition table and exit. 2208edcde5eSStefano Babic 2218edcde5eSStefano BabicCommand (m for help): w 2228edcde5eSStefano BabicThe partition table has been altered! 2238edcde5eSStefano Babic 2248edcde5eSStefano BabicCalling ioctl() to re-read partition table. 2258edcde5eSStefano Babic 2268edcde5eSStefano Babic9. Copy u-boot.imx on the SD card 2278edcde5eSStefano Babic 2288edcde5eSStefano BabicI use dd: 2298edcde5eSStefano Babic 2308edcde5eSStefano Babicdd if=u-boot.imx of=/dev/mmcblk0 bs=512 seek=2 2318edcde5eSStefano Babic 2328edcde5eSStefano BabicThis command copies the u-boot image at the address 0x400, as required 2338edcde5eSStefano Babicby the processor. 2348edcde5eSStefano Babic 2358edcde5eSStefano BabicNow remove your card from the PC and go to the target. If evrything went right, 2368edcde5eSStefano Babicthe u-boot prompt should come after power on. 2378edcde5eSStefano Babic 2388edcde5eSStefano Babic------------------------------------------------ 2398edcde5eSStefano BabicAuthor: Stefano babic <sbabic@denx.de> 240