xref: /rk3399_rockchip-uboot/doc/README.imximage (revision 6cb83829a013ed2631cba5d5c9bf42eaf2380131)
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 BabicThis implementation does not use at the moment the secure boot feature
198edcde5eSStefano Babicof the processor. The image is generated disabling all security fields.
208edcde5eSStefano Babic
218edcde5eSStefano BabicCommand syntax:
228edcde5eSStefano Babic--------------
238edcde5eSStefano Babic./tools/mkimage -l <mx u-boot_file>
248edcde5eSStefano Babic		to list the imx image file details
258edcde5eSStefano Babic
268edcde5eSStefano Babic./tools/mkimage -T imximage \
278edcde5eSStefano Babic		-n <board specific configuration file> \
288edcde5eSStefano Babic		-e <execution address> -d <u-boot binary>  <output image file>
298edcde5eSStefano Babic
308edcde5eSStefano BabicFor example, for the mx51evk board:
318edcde5eSStefano Babic./tools/mkimage -n ./board/freescale/mx51evk/imximage.cfg \
328edcde5eSStefano Babic		-T imximage -e 0x97800000  \
338edcde5eSStefano Babic		-d u-boot.bin u-boot.imx
348edcde5eSStefano Babic
358edcde5eSStefano BabicYou can generate directly the image when you compile u-boot with:
368edcde5eSStefano Babic
378edcde5eSStefano Babic$ make u-boot.imx
388edcde5eSStefano Babic
398edcde5eSStefano BabicThe output image can be flashed on the board SPI flash or on a SD card.
408edcde5eSStefano BabicIn both cases, you have to copy the image at the offset required for the
418edcde5eSStefano Babicchosen media devices (0x400 for both SPI flash or SD card).
428edcde5eSStefano Babic
438edcde5eSStefano BabicPlease check Freescale documentation for further details.
448edcde5eSStefano Babic
458edcde5eSStefano BabicBoard specific configuration file specifications:
468edcde5eSStefano Babic-------------------------------------------------
478edcde5eSStefano Babic1. This file must present in the $(BOARDDIR) and the name should be
488edcde5eSStefano Babic	imximage.cfg (since this is used in Makefile).
498edcde5eSStefano Babic2. This file can have empty lines and lines starting with "#" as first
508edcde5eSStefano Babic	character to put comments.
518edcde5eSStefano Babic3. This file can have configuration command lines as mentioned below,
528edcde5eSStefano Babic	any other information in this file is treated as invalid.
538edcde5eSStefano Babic
548edcde5eSStefano BabicConfiguration command line syntax:
558edcde5eSStefano Babic---------------------------------
568edcde5eSStefano Babic1. Each command line is must have two strings, first one command or address
578edcde5eSStefano Babic	and second one data string
588edcde5eSStefano Babic2. Following are the valid command strings and associated data strings:-
598edcde5eSStefano Babic	Command string		data string
608edcde5eSStefano Babic	--------------		-----------
618a1edd7dSLiu Hui-R64343	IMXIMAGE_VERSION        1/2
628a1edd7dSLiu Hui-R64343				1 is for mx25/mx35/mx51 compatible,
6319b409c0SDirk Behme				2 is for mx53/mx6 compatible,
648a1edd7dSLiu Hui-R64343				others is invalid and error is generated.
658a1edd7dSLiu Hui-R64343				This command need appear the fist before
668a1edd7dSLiu Hui-R64343				other valid commands in configuration file.
678a1edd7dSLiu Hui-R64343
68*6cb83829SMarek Vasut	BOOT_OFFSET		value
69*6cb83829SMarek Vasut
70*6cb83829SMarek Vasut				This command is parallel to BOOT_FROM and
71*6cb83829SMarek Vasut				is preferred over BOOT_FROM.
72*6cb83829SMarek Vasut
73*6cb83829SMarek Vasut				value:  Offset of the image header, this
74*6cb83829SMarek Vasut					value shall be set to one of the
75*6cb83829SMarek Vasut					values found in the file:
76*6cb83829SMarek Vasut						arch/arm/include/asm/\
77*6cb83829SMarek Vasut						imx-common/imximage.cfg
78*6cb83829SMarek Vasut				Example:
79*6cb83829SMarek Vasut				BOOT_OFFSET FLASH_OFFSET_STANDARD
80*6cb83829SMarek Vasut
8119b409c0SDirk Behme	BOOT_FROM		nand/spi/sd/onenand/nor/sata
82*6cb83829SMarek Vasut
83*6cb83829SMarek Vasut				This command is parallel to BOOT_OFFSET and
84*6cb83829SMarek Vasut				is to be deprecated in favor of BOOT_OFFSET.
85*6cb83829SMarek Vasut
868edcde5eSStefano Babic				Example:
878edcde5eSStefano Babic				BOOT_FROM spi
88*6cb83829SMarek Vasut
898edcde5eSStefano Babic	DATA			type address value
908edcde5eSStefano Babic
918edcde5eSStefano Babic				type: word=4, halfword=2, byte=1
928edcde5eSStefano Babic				address: physycal register address
938edcde5eSStefano Babic				value: value to be set in register
948edcde5eSStefano Babic				All values are in in hexadecimal.
958edcde5eSStefano Babic				Example (write to IOMUXC):
968edcde5eSStefano Babic				DATA 4 0x73FA88a0 0x200
978edcde5eSStefano Babic
988a1edd7dSLiu Hui-R64343The processor support up to 60 register programming commands for IMXIMAGE_VERSION 1
998a1edd7dSLiu Hui-R64343and 121 register programming commands for IMXIMAGE_VERSION 2.
1008a1edd7dSLiu Hui-R64343An error is generated if more commands are found in the configuration file.
1018edcde5eSStefano Babic
1028edcde5eSStefano Babic3. All commands are optional to program.
1038edcde5eSStefano Babic
1048edcde5eSStefano BabicSetup a SD Card for booting
1058edcde5eSStefano Babic--------------------------------
1068edcde5eSStefano Babic
1078edcde5eSStefano BabicThe following example prepare a SD card with u-boot and a FAT partition
1088edcde5eSStefano Babicto be used to stored the kernel to be booted.
1098edcde5eSStefano BabicI will set the SD in the most compatible mode, setting it with
1108edcde5eSStefano Babic255 heads and 63 sectors, as suggested from several documentation and
1118edcde5eSStefano Babichowto on line (I took as reference the preparation of a SD Card for the
1128edcde5eSStefano BabicBeagleboard, running u-boot as bootloader).
1138edcde5eSStefano Babic
1148edcde5eSStefano BabicYou should start clearing the partitions table on the SD card. Because
1158edcde5eSStefano Babicthe u-boot image must be stored at the offset 0x400, it must be assured
1168edcde5eSStefano Babicthat there is no partition at that address. A new SD card is already
1178edcde5eSStefano Babicformatted with FAT filesystem and the partition starts from the first
1188edcde5eSStefano Babiccylinder, so we need to change it.
1198edcde5eSStefano Babic
1208edcde5eSStefano BabicYou can do all steps with fdisk. If the device for the SD card is
1218edcde5eSStefano Babic/dev/mmcblk0, the following commands make the job:
1228edcde5eSStefano Babic
1238edcde5eSStefano Babic1. Start the fdisk utility (as superuser)
1248edcde5eSStefano Babic	fdisk /dev/mmcblk0
1258edcde5eSStefano Babic
1268edcde5eSStefano Babic2. Clear the actual partition
1278edcde5eSStefano Babic
1288edcde5eSStefano BabicCommand (m for help): o
1298edcde5eSStefano Babic
1308edcde5eSStefano Babic3. Print card info:
1318edcde5eSStefano Babic
1328edcde5eSStefano BabicCommand (m for help): p
1338edcde5eSStefano BabicDisk /dev/mmcblk0: 1981 MB, 1981284352 bytes
1348edcde5eSStefano Babic
1358edcde5eSStefano BabicIn my case, I have a 2 GB card. I need the size to set later the correct value
1368edcde5eSStefano Babicfor the cylinders.
1378edcde5eSStefano Babic
1388edcde5eSStefano Babic4. Go to expert mode:
1398edcde5eSStefano Babic
1408edcde5eSStefano BabicCommand (m for help): x
1418edcde5eSStefano Babic
1428edcde5eSStefano Babic5. Set card geometry
1438edcde5eSStefano Babic
1448edcde5eSStefano BabicExpert command (m for help): h
1458edcde5eSStefano BabicNumber of heads (1-256, default 4): 255
1468edcde5eSStefano Babic
1478edcde5eSStefano BabicExpert command (m for help): s
1488edcde5eSStefano BabicNumber of sectors (1-63, default 16): 63
1498edcde5eSStefano BabicWarning: setting sector offset for DOS compatiblity
1508edcde5eSStefano Babic
1518edcde5eSStefano BabicWe have set 255 heads, 63 sector. We have to set the cylinder.
1528edcde5eSStefano BabicThe value to be set can be calculated with:
1538edcde5eSStefano Babic
1548edcde5eSStefano Babic	cilynder = <total size> / <heads> / <sectors> / <blocksize>
1558edcde5eSStefano Babic
1568edcde5eSStefano Babicin this example,
1578edcde5eSStefano Babic	1981284352 / 255 / 63 / 512 = 239.x = 239
1588edcde5eSStefano Babic
1598edcde5eSStefano Babic
1608edcde5eSStefano BabicExpert command (m for help): c
1618edcde5eSStefano BabicNumber of cylinders (1-1048576, default 60032): 239
1628edcde5eSStefano Babic
1638edcde5eSStefano Babic6. Leave the expert mode
1648edcde5eSStefano BabicExpert command (m for help): r
1658edcde5eSStefano Babic
1668edcde5eSStefano Babic7. Set up a partition
1678edcde5eSStefano Babic
1688edcde5eSStefano BabicNow set a partition table to store the kernel or whatever you want. Of course,
1698edcde5eSStefano Babicyou can set additional partitions to store rootfs, data, etc.
1708edcde5eSStefano BabicIn my example I want to set a single partition. I must take care
1718edcde5eSStefano Babicto not overwrite the space where I will put u-boot.
1728edcde5eSStefano Babic
1738edcde5eSStefano BabicCommand (m for help): n
1748edcde5eSStefano BabicCommand action
1758edcde5eSStefano Babic   e   extended
1768edcde5eSStefano Babic   p   primary partition (1-4)
1778edcde5eSStefano Babicp
1788edcde5eSStefano BabicPartition number (1-4): 1
1798edcde5eSStefano BabicFirst cylinder (1-239, default 1): 3
1808edcde5eSStefano BabicLast cylinder, +cylinders or +size{K,M,G} (3-239, default 239): +100M
1818edcde5eSStefano Babic
1828edcde5eSStefano BabicCommand (m for help): p
1838edcde5eSStefano Babic
1848edcde5eSStefano BabicDisk /dev/mmcblk0: 1967 MB, 1967128576 bytes
1858edcde5eSStefano Babic255 heads, 63 sectors/track, 239 cylinders
1868edcde5eSStefano BabicUnits = cylinders of 16065 * 512 = 8225280 bytes
1878edcde5eSStefano BabicDisk identifier: 0xb712a870
1888edcde5eSStefano Babic
1898edcde5eSStefano Babic	Device Boot	 Start	       End	Blocks	 Id  System
1908edcde5eSStefano Babic/dev/mmcblk0p1		     3		16	112455	 83  Linux
1918edcde5eSStefano Babic
1928edcde5eSStefano BabicI have set 100MB, leaving the first 2 sectors free. I will copy u-boot
1938edcde5eSStefano Babicthere.
1948edcde5eSStefano Babic
1958edcde5eSStefano Babic8. Write the partition table and exit.
1968edcde5eSStefano Babic
1978edcde5eSStefano BabicCommand (m for help): w
1988edcde5eSStefano BabicThe partition table has been altered!
1998edcde5eSStefano Babic
2008edcde5eSStefano BabicCalling ioctl() to re-read partition table.
2018edcde5eSStefano Babic
2028edcde5eSStefano Babic9. Copy u-boot.imx on the SD card
2038edcde5eSStefano Babic
2048edcde5eSStefano BabicI use dd:
2058edcde5eSStefano Babic
2068edcde5eSStefano Babicdd if=u-boot.imx of=/dev/mmcblk0 bs=512 seek=2
2078edcde5eSStefano Babic
2088edcde5eSStefano BabicThis command copies the u-boot image at the address 0x400, as required
2098edcde5eSStefano Babicby the processor.
2108edcde5eSStefano Babic
2118edcde5eSStefano BabicNow remove your card from the PC and go to the target. If evrything went right,
2128edcde5eSStefano Babicthe u-boot prompt should come after power on.
2138edcde5eSStefano Babic
2148edcde5eSStefano Babic------------------------------------------------
2158edcde5eSStefano BabicAuthor: Stefano babic <sbabic@denx.de>
216