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