Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 1 | --------------------------------------------- |
| 2 | Imximage Boot Image generation using mkimage |
| 3 | --------------------------------------------- |
| 4 | |
Dirk Behme | 19b409c | 2012-01-11 23:28:31 +0000 | [diff] [blame] | 5 | This document describes how to set up a U-Boot image that can be booted |
| 6 | by Freescale MX25, MX35, MX51, MX53 and MX6 processors via internal boot |
| 7 | mode. |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 8 | |
| 9 | These processors can boot directly from NAND, SPI flash and SD card flash |
Dirk Behme | 19b409c | 2012-01-11 23:28:31 +0000 | [diff] [blame] | 10 | using its internal boot ROM support. MX6 processors additionally support |
| 11 | boot from NOR flash and SATA disks. All processors can boot from an internal |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 12 | UART, if booting from device media fails. |
| 13 | Booting from NOR flash does not require to use this image type. |
| 14 | |
| 15 | For more details refer Chapter 2 - System Boot and section 2.14 |
| 16 | (flash header description) of the processor's manual. |
| 17 | |
| 18 | This implementation does not use at the moment the secure boot feature |
| 19 | of the processor. The image is generated disabling all security fields. |
| 20 | |
| 21 | Command 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 | |
| 30 | For 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 | |
| 35 | You can generate directly the image when you compile u-boot with: |
| 36 | |
| 37 | $ make u-boot.imx |
| 38 | |
| 39 | The output image can be flashed on the board SPI flash or on a SD card. |
| 40 | In both cases, you have to copy the image at the offset required for the |
| 41 | chosen media devices (0x400 for both SPI flash or SD card). |
| 42 | |
| 43 | Please check Freescale documentation for further details. |
| 44 | |
| 45 | Board specific configuration file specifications: |
| 46 | ------------------------------------------------- |
| 47 | 1. This file must present in the $(BOARDDIR) and the name should be |
| 48 | imximage.cfg (since this is used in Makefile). |
| 49 | 2. This file can have empty lines and lines starting with "#" as first |
| 50 | character to put comments. |
| 51 | 3. This file can have configuration command lines as mentioned below, |
| 52 | any other information in this file is treated as invalid. |
| 53 | |
| 54 | Configuration command line syntax: |
| 55 | --------------------------------- |
| 56 | 1. Each command line is must have two strings, first one command or address |
| 57 | and second one data string |
| 58 | 2. Following are the valid command strings and associated data strings:- |
| 59 | Command string data string |
| 60 | -------------- ----------- |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 61 | IMXIMAGE_VERSION 1/2 |
| 62 | 1 is for mx25/mx35/mx51 compatible, |
Dirk Behme | 19b409c | 2012-01-11 23:28:31 +0000 | [diff] [blame] | 63 | 2 is for mx53/mx6 compatible, |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 64 | others is invalid and error is generated. |
| 65 | This command need appear the fist before |
| 66 | other valid commands in configuration file. |
| 67 | |
Dirk Behme | 19b409c | 2012-01-11 23:28:31 +0000 | [diff] [blame] | 68 | BOOT_FROM nand/spi/sd/onenand/nor/sata |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 69 | Example: |
| 70 | BOOT_FROM spi |
| 71 | DATA type address value |
| 72 | |
| 73 | type: word=4, halfword=2, byte=1 |
| 74 | address: physycal register address |
| 75 | value: value to be set in register |
| 76 | All values are in in hexadecimal. |
| 77 | Example (write to IOMUXC): |
| 78 | DATA 4 0x73FA88a0 0x200 |
| 79 | |
Liu Hui-R64343 | 8a1edd7 | 2011-01-19 09:40:26 +0000 | [diff] [blame] | 80 | The processor support up to 60 register programming commands for IMXIMAGE_VERSION 1 |
| 81 | and 121 register programming commands for IMXIMAGE_VERSION 2. |
| 82 | An error is generated if more commands are found in the configuration file. |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 83 | |
| 84 | 3. All commands are optional to program. |
| 85 | |
| 86 | Setup a SD Card for booting |
| 87 | -------------------------------- |
| 88 | |
| 89 | The following example prepare a SD card with u-boot and a FAT partition |
| 90 | to be used to stored the kernel to be booted. |
| 91 | I will set the SD in the most compatible mode, setting it with |
| 92 | 255 heads and 63 sectors, as suggested from several documentation and |
| 93 | howto on line (I took as reference the preparation of a SD Card for the |
| 94 | Beagleboard, running u-boot as bootloader). |
| 95 | |
| 96 | You should start clearing the partitions table on the SD card. Because |
| 97 | the u-boot image must be stored at the offset 0x400, it must be assured |
| 98 | that there is no partition at that address. A new SD card is already |
| 99 | formatted with FAT filesystem and the partition starts from the first |
| 100 | cylinder, so we need to change it. |
| 101 | |
| 102 | You can do all steps with fdisk. If the device for the SD card is |
| 103 | /dev/mmcblk0, the following commands make the job: |
| 104 | |
| 105 | 1. Start the fdisk utility (as superuser) |
| 106 | fdisk /dev/mmcblk0 |
| 107 | |
| 108 | 2. Clear the actual partition |
| 109 | |
| 110 | Command (m for help): o |
| 111 | |
| 112 | 3. Print card info: |
| 113 | |
| 114 | Command (m for help): p |
| 115 | Disk /dev/mmcblk0: 1981 MB, 1981284352 bytes |
| 116 | |
| 117 | In my case, I have a 2 GB card. I need the size to set later the correct value |
| 118 | for the cylinders. |
| 119 | |
| 120 | 4. Go to expert mode: |
| 121 | |
| 122 | Command (m for help): x |
| 123 | |
| 124 | 5. Set card geometry |
| 125 | |
| 126 | Expert command (m for help): h |
| 127 | Number of heads (1-256, default 4): 255 |
| 128 | |
| 129 | Expert command (m for help): s |
| 130 | Number of sectors (1-63, default 16): 63 |
| 131 | Warning: setting sector offset for DOS compatiblity |
| 132 | |
| 133 | We have set 255 heads, 63 sector. We have to set the cylinder. |
| 134 | The value to be set can be calculated with: |
| 135 | |
| 136 | cilynder = <total size> / <heads> / <sectors> / <blocksize> |
| 137 | |
| 138 | in this example, |
| 139 | 1981284352 / 255 / 63 / 512 = 239.x = 239 |
| 140 | |
| 141 | |
| 142 | Expert command (m for help): c |
| 143 | Number of cylinders (1-1048576, default 60032): 239 |
| 144 | |
| 145 | 6. Leave the expert mode |
| 146 | Expert command (m for help): r |
| 147 | |
| 148 | 7. Set up a partition |
| 149 | |
| 150 | Now set a partition table to store the kernel or whatever you want. Of course, |
| 151 | you can set additional partitions to store rootfs, data, etc. |
| 152 | In my example I want to set a single partition. I must take care |
| 153 | to not overwrite the space where I will put u-boot. |
| 154 | |
| 155 | Command (m for help): n |
| 156 | Command action |
| 157 | e extended |
| 158 | p primary partition (1-4) |
| 159 | p |
| 160 | Partition number (1-4): 1 |
| 161 | First cylinder (1-239, default 1): 3 |
| 162 | Last cylinder, +cylinders or +size{K,M,G} (3-239, default 239): +100M |
| 163 | |
| 164 | Command (m for help): p |
| 165 | |
| 166 | Disk /dev/mmcblk0: 1967 MB, 1967128576 bytes |
| 167 | 255 heads, 63 sectors/track, 239 cylinders |
| 168 | Units = cylinders of 16065 * 512 = 8225280 bytes |
| 169 | Disk identifier: 0xb712a870 |
| 170 | |
Wolfgang Denk | 93910ed | 2010-03-12 23:06:04 +0100 | [diff] [blame] | 171 | Device Boot Start End Blocks Id System |
| 172 | /dev/mmcblk0p1 3 16 112455 83 Linux |
Stefano Babic | 8edcde5 | 2010-01-20 18:19:10 +0100 | [diff] [blame] | 173 | |
| 174 | I have set 100MB, leaving the first 2 sectors free. I will copy u-boot |
| 175 | there. |
| 176 | |
| 177 | 8. Write the partition table and exit. |
| 178 | |
| 179 | Command (m for help): w |
| 180 | The partition table has been altered! |
| 181 | |
| 182 | Calling ioctl() to re-read partition table. |
| 183 | |
| 184 | 9. Copy u-boot.imx on the SD card |
| 185 | |
| 186 | I use dd: |
| 187 | |
| 188 | dd if=u-boot.imx of=/dev/mmcblk0 bs=512 seek=2 |
| 189 | |
| 190 | This command copies the u-boot image at the address 0x400, as required |
| 191 | by the processor. |
| 192 | |
| 193 | Now remove your card from the PC and go to the target. If evrything went right, |
| 194 | the u-boot prompt should come after power on. |
| 195 | |
| 196 | ------------------------------------------------ |
| 197 | Author: Stefano babic <sbabic@denx.de> |