blob: 802eb90f1de6b352dc383f69cdc234b0b64cccd9 [file] [log] [blame]
Stefano Babic8edcde52010-01-20 18:19:10 +01001---------------------------------------------
2Imximage Boot Image generation using mkimage
3---------------------------------------------
4
Dirk Behme19b409c2012-01-11 23:28:31 +00005This document describes how to set up a U-Boot image that can be booted
6by Freescale MX25, MX35, MX51, MX53 and MX6 processors via internal boot
7mode.
Stefano Babic8edcde52010-01-20 18:19:10 +01008
9These processors can boot directly from NAND, SPI flash and SD card flash
Dirk Behme19b409c2012-01-11 23:28:31 +000010using its internal boot ROM support. MX6 processors additionally support
11boot from NOR flash and SATA disks. All processors can boot from an internal
Stefano Babic8edcde52010-01-20 18:19:10 +010012UART, if booting from device media fails.
13Booting from NOR flash does not require to use this image type.
14
15For more details refer Chapter 2 - System Boot and section 2.14
16(flash header description) of the processor's manual.
17
18This implementation does not use at the moment the secure boot feature
19of the processor. The image is generated disabling all security fields.
20
21Command syntax:
22--------------
23./tools/mkimage -l <mx u-boot_file>
24 to list the imx image file details
25
26./tools/mkimage -T imximage \
27 -n <board specific configuration file> \
28 -e <execution address> -d <u-boot binary> <output image file>
29
30For example, for the mx51evk board:
31./tools/mkimage -n ./board/freescale/mx51evk/imximage.cfg \
32 -T imximage -e 0x97800000 \
33 -d u-boot.bin u-boot.imx
34
35You can generate directly the image when you compile u-boot with:
36
37$ make u-boot.imx
38
39The output image can be flashed on the board SPI flash or on a SD card.
40In both cases, you have to copy the image at the offset required for the
41chosen media devices (0x400 for both SPI flash or SD card).
42
43Please check Freescale documentation for further details.
44
45Board specific configuration file specifications:
46-------------------------------------------------
471. This file must present in the $(BOARDDIR) and the name should be
48 imximage.cfg (since this is used in Makefile).
492. This file can have empty lines and lines starting with "#" as first
50 character to put comments.
513. This file can have configuration command lines as mentioned below,
52 any other information in this file is treated as invalid.
53
54Configuration command line syntax:
55---------------------------------
561. Each command line is must have two strings, first one command or address
57 and second one data string
582. Following are the valid command strings and associated data strings:-
59 Command string data string
60 -------------- -----------
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000061 IMXIMAGE_VERSION 1/2
62 1 is for mx25/mx35/mx51 compatible,
Dirk Behme19b409c2012-01-11 23:28:31 +000063 2 is for mx53/mx6 compatible,
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000064 others is invalid and error is generated.
65 This command need appear the fist before
66 other valid commands in configuration file.
67
Marek Vasut6cb83822013-04-25 10:16:02 +000068 BOOT_OFFSET value
69
70 This command is parallel to BOOT_FROM and
71 is preferred over BOOT_FROM.
72
73 value: Offset of the image header, this
74 value shall be set to one of the
75 values found in the file:
76 arch/arm/include/asm/\
77 imx-common/imximage.cfg
78 Example:
79 BOOT_OFFSET FLASH_OFFSET_STANDARD
80
Dirk Behme19b409c2012-01-11 23:28:31 +000081 BOOT_FROM nand/spi/sd/onenand/nor/sata
Marek Vasut6cb83822013-04-25 10:16:02 +000082
83 This command is parallel to BOOT_OFFSET and
84 is to be deprecated in favor of BOOT_OFFSET.
85
Stefano Babic8edcde52010-01-20 18:19:10 +010086 Example:
87 BOOT_FROM spi
Marek Vasut6cb83822013-04-25 10:16:02 +000088
Stefano Babic8edcde52010-01-20 18:19:10 +010089 DATA type address value
90
91 type: word=4, halfword=2, byte=1
92 address: physycal register address
93 value: value to be set in register
94 All values are in in hexadecimal.
95 Example (write to IOMUXC):
96 DATA 4 0x73FA88a0 0x200
97
Liu Hui-R643438a1edd72011-01-19 09:40:26 +000098The processor support up to 60 register programming commands for IMXIMAGE_VERSION 1
99and 121 register programming commands for IMXIMAGE_VERSION 2.
100An error is generated if more commands are found in the configuration file.
Stefano Babic8edcde52010-01-20 18:19:10 +0100101
1023. All commands are optional to program.
103
104Setup a SD Card for booting
105--------------------------------
106
107The following example prepare a SD card with u-boot and a FAT partition
108to be used to stored the kernel to be booted.
109I will set the SD in the most compatible mode, setting it with
110255 heads and 63 sectors, as suggested from several documentation and
111howto on line (I took as reference the preparation of a SD Card for the
112Beagleboard, running u-boot as bootloader).
113
114You should start clearing the partitions table on the SD card. Because
115the u-boot image must be stored at the offset 0x400, it must be assured
116that there is no partition at that address. A new SD card is already
117formatted with FAT filesystem and the partition starts from the first
118cylinder, so we need to change it.
119
120You can do all steps with fdisk. If the device for the SD card is
121/dev/mmcblk0, the following commands make the job:
122
1231. Start the fdisk utility (as superuser)
124 fdisk /dev/mmcblk0
125
1262. Clear the actual partition
127
128Command (m for help): o
129
1303. Print card info:
131
132Command (m for help): p
133Disk /dev/mmcblk0: 1981 MB, 1981284352 bytes
134
135In my case, I have a 2 GB card. I need the size to set later the correct value
136for the cylinders.
137
1384. Go to expert mode:
139
140Command (m for help): x
141
1425. Set card geometry
143
144Expert command (m for help): h
145Number of heads (1-256, default 4): 255
146
147Expert command (m for help): s
148Number of sectors (1-63, default 16): 63
149Warning: setting sector offset for DOS compatiblity
150
151We have set 255 heads, 63 sector. We have to set the cylinder.
152The value to be set can be calculated with:
153
154 cilynder = <total size> / <heads> / <sectors> / <blocksize>
155
156in this example,
157 1981284352 / 255 / 63 / 512 = 239.x = 239
158
159
160Expert command (m for help): c
161Number of cylinders (1-1048576, default 60032): 239
162
1636. Leave the expert mode
164Expert command (m for help): r
165
1667. Set up a partition
167
168Now set a partition table to store the kernel or whatever you want. Of course,
169you can set additional partitions to store rootfs, data, etc.
170In my example I want to set a single partition. I must take care
171to not overwrite the space where I will put u-boot.
172
173Command (m for help): n
174Command action
175 e extended
176 p primary partition (1-4)
177p
178Partition number (1-4): 1
179First cylinder (1-239, default 1): 3
180Last cylinder, +cylinders or +size{K,M,G} (3-239, default 239): +100M
181
182Command (m for help): p
183
184Disk /dev/mmcblk0: 1967 MB, 1967128576 bytes
185255 heads, 63 sectors/track, 239 cylinders
186Units = cylinders of 16065 * 512 = 8225280 bytes
187Disk identifier: 0xb712a870
188
Wolfgang Denk93910ed2010-03-12 23:06:04 +0100189 Device Boot Start End Blocks Id System
190/dev/mmcblk0p1 3 16 112455 83 Linux
Stefano Babic8edcde52010-01-20 18:19:10 +0100191
192I have set 100MB, leaving the first 2 sectors free. I will copy u-boot
193there.
194
1958. Write the partition table and exit.
196
197Command (m for help): w
198The partition table has been altered!
199
200Calling ioctl() to re-read partition table.
201
2029. Copy u-boot.imx on the SD card
203
204I use dd:
205
206dd if=u-boot.imx of=/dev/mmcblk0 bs=512 seek=2
207
208This command copies the u-boot image at the address 0x400, as required
209by the processor.
210
211Now remove your card from the PC and go to the target. If evrything went right,
212the u-boot prompt should come after power on.
213
214------------------------------------------------
215Author: Stefano babic <sbabic@denx.de>