175e8ca6aSBreno Matheus Lima--------------------------------------------- 275e8ca6aSBreno Matheus LimaImximage Boot Image generation using mkimage 375e8ca6aSBreno Matheus Lima--------------------------------------------- 475e8ca6aSBreno Matheus Lima 575e8ca6aSBreno Matheus LimaThis document describes how to set up a U-Boot image that can be booted 675e8ca6aSBreno Matheus Limaby Freescale MX25, MX35, MX51, MX53 and MX6 processors via internal boot 775e8ca6aSBreno Matheus Limamode. 875e8ca6aSBreno Matheus Lima 975e8ca6aSBreno Matheus LimaThese processors can boot directly from NAND, SPI flash and SD card flash 1075e8ca6aSBreno Matheus Limausing its internal boot ROM support. MX6 processors additionally support 1175e8ca6aSBreno Matheus Limaboot from NOR flash and SATA disks. All processors can boot from an internal 1275e8ca6aSBreno Matheus LimaUART, if booting from device media fails. 1375e8ca6aSBreno Matheus LimaBooting from NOR flash does not require to use this image type. 1475e8ca6aSBreno Matheus Lima 1575e8ca6aSBreno Matheus LimaFor more details refer Chapter 2 - System Boot and section 2.14 1675e8ca6aSBreno Matheus Lima(flash header description) of the processor's manual. 1775e8ca6aSBreno Matheus Lima 1875e8ca6aSBreno Matheus LimaCommand syntax: 1975e8ca6aSBreno Matheus Lima-------------- 2075e8ca6aSBreno Matheus Lima./tools/mkimage -l <mx u-boot_file> 2175e8ca6aSBreno Matheus Lima to list the imx image file details 2275e8ca6aSBreno Matheus Lima 2375e8ca6aSBreno Matheus Lima./tools/mkimage -T imximage \ 2475e8ca6aSBreno Matheus Lima -n <board specific configuration file> \ 2575e8ca6aSBreno Matheus Lima -e <execution address> -d <u-boot binary> <output image file> 2675e8ca6aSBreno Matheus Lima 2775e8ca6aSBreno Matheus LimaFor example, for the mx51evk board: 2875e8ca6aSBreno Matheus Lima./tools/mkimage -n ./board/freescale/mx51evk/imximage.cfg \ 2975e8ca6aSBreno Matheus Lima -T imximage -e 0x97800000 \ 3075e8ca6aSBreno Matheus Lima -d u-boot.bin u-boot.imx 3175e8ca6aSBreno Matheus Lima 3275e8ca6aSBreno Matheus LimaYou can generate directly the image when you compile u-boot with: 3375e8ca6aSBreno Matheus Lima 3475e8ca6aSBreno Matheus Lima$ make u-boot.imx 3575e8ca6aSBreno Matheus Lima 3675e8ca6aSBreno Matheus LimaThe output image can be flashed on the board SPI flash or on a SD card. 3775e8ca6aSBreno Matheus LimaIn both cases, you have to copy the image at the offset required for the 3875e8ca6aSBreno Matheus Limachosen media devices (0x400 for both SPI flash or SD card). 3975e8ca6aSBreno Matheus Lima 4075e8ca6aSBreno Matheus LimaPlease check Freescale documentation for further details. 4175e8ca6aSBreno Matheus Lima 4275e8ca6aSBreno Matheus LimaBoard specific configuration file specifications: 4375e8ca6aSBreno Matheus Lima------------------------------------------------- 4475e8ca6aSBreno Matheus Lima1. This file must present in the $(BOARDDIR) and the name should be 4575e8ca6aSBreno Matheus Lima imximage.cfg (since this is used in Makefile). 4675e8ca6aSBreno Matheus Lima2. This file can have empty lines and lines starting with "#" as first 4775e8ca6aSBreno Matheus Lima character to put comments. 4875e8ca6aSBreno Matheus Lima3. This file can have configuration command lines as mentioned below, 4975e8ca6aSBreno Matheus Lima any other information in this file is treated as invalid. 5075e8ca6aSBreno Matheus Lima 5175e8ca6aSBreno Matheus LimaConfiguration command line syntax: 5275e8ca6aSBreno Matheus Lima--------------------------------- 5375e8ca6aSBreno Matheus Lima1. Each command line is must have two strings, first one command or address 5475e8ca6aSBreno Matheus Lima and second one data string 5575e8ca6aSBreno Matheus Lima2. Following are the valid command strings and associated data strings:- 5675e8ca6aSBreno Matheus Lima Command string data string 5775e8ca6aSBreno Matheus Lima -------------- ----------- 5875e8ca6aSBreno Matheus Lima IMXIMAGE_VERSION 1/2 5975e8ca6aSBreno Matheus Lima 1 is for mx25/mx35/mx51 compatible, 6075e8ca6aSBreno Matheus Lima 2 is for mx53/mx6 compatible, 6175e8ca6aSBreno Matheus Lima others is invalid and error is generated. 6275e8ca6aSBreno Matheus Lima This command need appear the fist before 6375e8ca6aSBreno Matheus Lima other valid commands in configuration file. 6475e8ca6aSBreno Matheus Lima 6575e8ca6aSBreno Matheus Lima BOOT_OFFSET value 6675e8ca6aSBreno Matheus Lima 6775e8ca6aSBreno Matheus Lima This command is parallel to BOOT_FROM and 6875e8ca6aSBreno Matheus Lima is preferred over BOOT_FROM. 6975e8ca6aSBreno Matheus Lima 7075e8ca6aSBreno Matheus Lima value: Offset of the image header, this 7175e8ca6aSBreno Matheus Lima value shall be set to one of the 7275e8ca6aSBreno Matheus Lima values found in the file: 7375e8ca6aSBreno Matheus Lima arch/arm/include/asm/\ 7475e8ca6aSBreno Matheus Lima mach-imx/imximage.cfg 7575e8ca6aSBreno Matheus Lima Example: 7675e8ca6aSBreno Matheus Lima BOOT_OFFSET FLASH_OFFSET_STANDARD 7775e8ca6aSBreno Matheus Lima 7875e8ca6aSBreno Matheus Lima BOOT_FROM nand/spi/sd/onenand/nor/sata 7975e8ca6aSBreno Matheus Lima 8075e8ca6aSBreno Matheus Lima This command is parallel to BOOT_OFFSET and 8175e8ca6aSBreno Matheus Lima is to be deprecated in favor of BOOT_OFFSET. 8275e8ca6aSBreno Matheus Lima 8375e8ca6aSBreno Matheus Lima Example: 8475e8ca6aSBreno Matheus Lima BOOT_FROM spi 8575e8ca6aSBreno Matheus Lima 8675e8ca6aSBreno Matheus Lima CSF value 8775e8ca6aSBreno Matheus Lima 8875e8ca6aSBreno Matheus Lima Total size of CSF (Command Sequence File) 8975e8ca6aSBreno Matheus Lima used for Secure Boot/ High Assurance Boot 9075e8ca6aSBreno Matheus Lima (HAB). 9175e8ca6aSBreno Matheus Lima 9275e8ca6aSBreno Matheus Lima Using this command will populate the IVT 9375e8ca6aSBreno Matheus Lima (Initial Vector Table) CSF pointer and adjust 9475e8ca6aSBreno Matheus Lima the length fields only. The CSF itself needs 9575e8ca6aSBreno Matheus Lima to be generated with Freescale tools and 9675e8ca6aSBreno Matheus Lima 'manually' appended to the u-boot.imx file. 9775e8ca6aSBreno Matheus Lima 9875e8ca6aSBreno Matheus Lima The CSF is then simply concatenated 9975e8ca6aSBreno Matheus Lima to the u-boot image, making a signed bootloader, 10075e8ca6aSBreno Matheus Lima that the processor can verify 10175e8ca6aSBreno Matheus Lima if the fuses for the keys are burned. 10275e8ca6aSBreno Matheus Lima 10375e8ca6aSBreno Matheus Lima Further infos how to configure the SOC to verify 10475e8ca6aSBreno Matheus Lima the bootloader can be found in the "High 10575e8ca6aSBreno Matheus Lima Assurance Boot Version Application Programming 10675e8ca6aSBreno Matheus Lima Interface Reference Manual" as part of the 10775e8ca6aSBreno Matheus Lima Freescale Code Signing Tool, available on the 10875e8ca6aSBreno Matheus Lima manufacturer's website. 10975e8ca6aSBreno Matheus Lima 11075e8ca6aSBreno Matheus Lima Example: 11175e8ca6aSBreno Matheus Lima CSF 0x2000 11275e8ca6aSBreno Matheus Lima 11375e8ca6aSBreno Matheus Lima DATA type address value 11475e8ca6aSBreno Matheus Lima 11575e8ca6aSBreno Matheus Lima type: word=4, halfword=2, byte=1 11675e8ca6aSBreno Matheus Lima address: physycal register address 11775e8ca6aSBreno Matheus Lima value: value to be set in register 11875e8ca6aSBreno Matheus Lima All values are in in hexadecimal. 11975e8ca6aSBreno Matheus Lima Example (write to IOMUXC): 12075e8ca6aSBreno Matheus Lima DATA 4 0x73FA88a0 0x200 12175e8ca6aSBreno Matheus Lima 12275e8ca6aSBreno Matheus LimaThe processor support up to 60 register programming commands for IMXIMAGE_VERSION 1 12375e8ca6aSBreno Matheus Limaand 220 register programming commands for IMXIMAGE_VERSION 2. 12475e8ca6aSBreno Matheus LimaAn error is generated if more commands are found in the configuration file. 12575e8ca6aSBreno Matheus Lima 12675e8ca6aSBreno Matheus Lima3. All commands are optional to program. 12775e8ca6aSBreno Matheus Lima 12875e8ca6aSBreno Matheus LimaSetup a SD Card for booting 12975e8ca6aSBreno Matheus Lima-------------------------------- 13075e8ca6aSBreno Matheus Lima 13175e8ca6aSBreno Matheus LimaThe following example prepare a SD card with u-boot and a FAT partition 13275e8ca6aSBreno Matheus Limato be used to stored the kernel to be booted. 13375e8ca6aSBreno Matheus LimaI will set the SD in the most compatible mode, setting it with 13475e8ca6aSBreno Matheus Lima255 heads and 63 sectors, as suggested from several documentation and 13575e8ca6aSBreno Matheus Limahowto on line (I took as reference the preparation of a SD Card for the 13675e8ca6aSBreno Matheus LimaBeagleboard, running u-boot as bootloader). 13775e8ca6aSBreno Matheus Lima 13875e8ca6aSBreno Matheus LimaYou should start clearing the partitions table on the SD card. Because 13975e8ca6aSBreno Matheus Limathe u-boot image must be stored at the offset 0x400, it must be assured 14075e8ca6aSBreno Matheus Limathat there is no partition at that address. A new SD card is already 14175e8ca6aSBreno Matheus Limaformatted with FAT filesystem and the partition starts from the first 14275e8ca6aSBreno Matheus Limacylinder, so we need to change it. 14375e8ca6aSBreno Matheus Lima 14475e8ca6aSBreno Matheus LimaYou can do all steps with fdisk. If the device for the SD card is 14575e8ca6aSBreno Matheus Lima/dev/mmcblk0, the following commands make the job: 14675e8ca6aSBreno Matheus Lima 14775e8ca6aSBreno Matheus Lima1. Start the fdisk utility (as superuser) 14875e8ca6aSBreno Matheus Lima fdisk /dev/mmcblk0 14975e8ca6aSBreno Matheus Lima 15075e8ca6aSBreno Matheus Lima2. Clear the actual partition 15175e8ca6aSBreno Matheus Lima 15275e8ca6aSBreno Matheus LimaCommand (m for help): o 15375e8ca6aSBreno Matheus Lima 15475e8ca6aSBreno Matheus Lima3. Print card info: 15575e8ca6aSBreno Matheus Lima 15675e8ca6aSBreno Matheus LimaCommand (m for help): p 15775e8ca6aSBreno Matheus LimaDisk /dev/mmcblk0: 1981 MB, 1981284352 bytes 15875e8ca6aSBreno Matheus Lima 15975e8ca6aSBreno Matheus LimaIn my case, I have a 2 GB card. I need the size to set later the correct value 16075e8ca6aSBreno Matheus Limafor the cylinders. 16175e8ca6aSBreno Matheus Lima 16275e8ca6aSBreno Matheus Lima4. Go to expert mode: 16375e8ca6aSBreno Matheus Lima 16475e8ca6aSBreno Matheus LimaCommand (m for help): x 16575e8ca6aSBreno Matheus Lima 16675e8ca6aSBreno Matheus Lima5. Set card geometry 16775e8ca6aSBreno Matheus Lima 16875e8ca6aSBreno Matheus LimaExpert command (m for help): h 16975e8ca6aSBreno Matheus LimaNumber of heads (1-256, default 4): 255 17075e8ca6aSBreno Matheus Lima 17175e8ca6aSBreno Matheus LimaExpert command (m for help): s 17275e8ca6aSBreno Matheus LimaNumber of sectors (1-63, default 16): 63 17375e8ca6aSBreno Matheus LimaWarning: setting sector offset for DOS compatiblity 17475e8ca6aSBreno Matheus Lima 17575e8ca6aSBreno Matheus LimaWe have set 255 heads, 63 sector. We have to set the cylinder. 17675e8ca6aSBreno Matheus LimaThe value to be set can be calculated with: 17775e8ca6aSBreno Matheus Lima 178*5271dcf5SMichael Heimpold cylinder = <total size> / <heads> / <sectors> / <blocksize> 17975e8ca6aSBreno Matheus Lima 18075e8ca6aSBreno Matheus Limain this example, 18175e8ca6aSBreno Matheus Lima 1981284352 / 255 / 63 / 512 = 239.x = 239 18275e8ca6aSBreno Matheus Lima 18375e8ca6aSBreno Matheus Lima 18475e8ca6aSBreno Matheus LimaExpert command (m for help): c 18575e8ca6aSBreno Matheus LimaNumber of cylinders (1-1048576, default 60032): 239 18675e8ca6aSBreno Matheus Lima 18775e8ca6aSBreno Matheus Lima6. Leave the expert mode 18875e8ca6aSBreno Matheus LimaExpert command (m for help): r 18975e8ca6aSBreno Matheus Lima 19075e8ca6aSBreno Matheus Lima7. Set up a partition 19175e8ca6aSBreno Matheus Lima 19275e8ca6aSBreno Matheus LimaNow set a partition table to store the kernel or whatever you want. Of course, 19375e8ca6aSBreno Matheus Limayou can set additional partitions to store rootfs, data, etc. 19475e8ca6aSBreno Matheus LimaIn my example I want to set a single partition. I must take care 19575e8ca6aSBreno Matheus Limato not overwrite the space where I will put u-boot. 19675e8ca6aSBreno Matheus Lima 19775e8ca6aSBreno Matheus LimaCommand (m for help): n 19875e8ca6aSBreno Matheus LimaCommand action 19975e8ca6aSBreno Matheus Lima e extended 20075e8ca6aSBreno Matheus Lima p primary partition (1-4) 20175e8ca6aSBreno Matheus Limap 20275e8ca6aSBreno Matheus LimaPartition number (1-4): 1 20375e8ca6aSBreno Matheus LimaFirst cylinder (1-239, default 1): 3 20475e8ca6aSBreno Matheus LimaLast cylinder, +cylinders or +size{K,M,G} (3-239, default 239): +100M 20575e8ca6aSBreno Matheus Lima 20675e8ca6aSBreno Matheus LimaCommand (m for help): p 20775e8ca6aSBreno Matheus Lima 20875e8ca6aSBreno Matheus LimaDisk /dev/mmcblk0: 1967 MB, 1967128576 bytes 20975e8ca6aSBreno Matheus Lima255 heads, 63 sectors/track, 239 cylinders 21075e8ca6aSBreno Matheus LimaUnits = cylinders of 16065 * 512 = 8225280 bytes 21175e8ca6aSBreno Matheus LimaDisk identifier: 0xb712a870 21275e8ca6aSBreno Matheus Lima 21375e8ca6aSBreno Matheus Lima Device Boot Start End Blocks Id System 21475e8ca6aSBreno Matheus Lima/dev/mmcblk0p1 3 16 112455 83 Linux 21575e8ca6aSBreno Matheus Lima 21675e8ca6aSBreno Matheus LimaI have set 100MB, leaving the first 2 sectors free. I will copy u-boot 21775e8ca6aSBreno Matheus Limathere. 21875e8ca6aSBreno Matheus Lima 21975e8ca6aSBreno Matheus Lima8. Write the partition table and exit. 22075e8ca6aSBreno Matheus Lima 22175e8ca6aSBreno Matheus LimaCommand (m for help): w 22275e8ca6aSBreno Matheus LimaThe partition table has been altered! 22375e8ca6aSBreno Matheus Lima 22475e8ca6aSBreno Matheus LimaCalling ioctl() to re-read partition table. 22575e8ca6aSBreno Matheus Lima 22675e8ca6aSBreno Matheus Lima9. Copy u-boot.imx on the SD card 22775e8ca6aSBreno Matheus Lima 22875e8ca6aSBreno Matheus LimaI use dd: 22975e8ca6aSBreno Matheus Lima 23075e8ca6aSBreno Matheus Limadd if=u-boot.imx of=/dev/mmcblk0 bs=512 seek=2 23175e8ca6aSBreno Matheus Lima 23275e8ca6aSBreno Matheus LimaThis command copies the u-boot image at the address 0x400, as required 23375e8ca6aSBreno Matheus Limaby the processor. 23475e8ca6aSBreno Matheus Lima 23575e8ca6aSBreno Matheus LimaNow remove your card from the PC and go to the target. If evrything went right, 23675e8ca6aSBreno Matheus Limathe u-boot prompt should come after power on. 23775e8ca6aSBreno Matheus Lima 23875e8ca6aSBreno Matheus Lima------------------------------------------------ 23975e8ca6aSBreno Matheus LimaAuthor: Stefano babic <sbabic@denx.de> 240