blob: bba2440922b80861d60fdfbcdebabf86bf402ac7 [file] [log] [blame]
Fabio Estevam419ea2d2012-03-24 12:42:21 +00001Booting U-boot on a MX28 processor
2==================================
3
4This document describes the MX28 U-Boot port. This document mostly
5covers topics related to making the module/board bootable.
6
7Terminology
8-----------
9
10The dollar symbol ($) introduces a snipped of shell code. This shall be typed
11into the unix command prompt in U-Boot source code root directory.
12
13The (=>) introduces a snipped of code that should by typed into U-Boot command
14prompt
15
16Contents
17--------
18
191) Prerequisites
202) Compiling U-Boot for a MX28 based board
213) Installation of U-Boot for a MX28 based board to SD card
Fabio Estevame9fd0a02012-06-18 05:51:49 +0000224) Installation of U-Boot into NAND flash
Fabio Estevam419ea2d2012-03-24 12:42:21 +000023
241) Prerequisites
25----------------
26
27To make a MX28 based board bootable, some tools are necessary. The first one
28is the "elftosb" tool distributed by Freescale Semiconductor. The other one
29is the "mxsboot" tool found in U-Boot source tree.
30
31Firstly, obtain the elftosb archive from the following location:
32
Anatolij Gustschin9de1c222012-06-27 04:14:29 +000033 ftp://ftp.denx.de/pub/tools/elftosb-10.12.01.tar.gz
Fabio Estevam419ea2d2012-03-24 12:42:21 +000034
35We use a $VER variable here to denote the current version. At the time of
36writing of this document, that is "10.12.01". To obtain the file from command
37line, use:
38
39 $ VER="10.12.01"
Anatolij Gustschin9de1c222012-06-27 04:14:29 +000040 $ wget ftp://ftp.denx.de/pub/tools/elftosb-${VER}.tar.gz
Fabio Estevam419ea2d2012-03-24 12:42:21 +000041
42Extract the file:
43
44 $ tar xzf elftosb-${VER}.tar.gz
45
46Compile the file. We need to manually tell the linker to use also libm:
47
48 $ cd elftosb-${VER}/
49 $ make LIBS="-lstdc++ -lm" elftosb
50
51Optionally, remove debugging symbols from elftosb:
52
53 $ strip bld/linux/elftosb
54
55Finally, install the "elftosb" binary. The "install" target is missing, so just
56copy the binary by hand:
57
58 $ sudo cp bld/linux/elftosb /usr/local/bin/
59
60Make sure the "elftosb" binary can be found in your $PATH, in this case this
61means "/usr/local/bin/" has to be in your $PATH.
62
632) Compiling U-Boot for a MX28 based board
64-------------------------------------------
65
Fabio Estevam84286c22013-05-03 15:07:57 -030066Compiling the U-Boot for a MX28 board is straightforward and done as compiling
67U-Boot for any other ARM device. For cross-compiler setup, please refer to
68ELDK5.0 documentation. First, clean up the source code:
Fabio Estevam419ea2d2012-03-24 12:42:21 +000069
70 $ make mrproper
71
72Next, configure U-Boot for a MX28 based board
73
74 $ make <mx28_based_board_name>_config
75
76Examples:
77
781. For building U-boot for Denx M28EVK board:
79
80 $ make m28evk_config
81
822. For building U-boot for Freescale MX28EVK board:
83
84 $ make mx28evk_config
85
86Lastly, compile U-Boot and prepare a "BootStream". The "BootStream" is a special
87type of file, which the i.MX28 CPU can boot. This is handled by the following
88command:
89
90 $ make u-boot.sb
91
92HINT: To speed-up the build process, you can add -j<N>, where N is number of
93 compiler instances that'll run in parallel.
94
95The code produces "u-boot.sb" file. This file needs to be augmented with a
96proper header to allow successful boot from SD or NAND. Adding the header is
97discussed in the following chapters.
98
993) Installation of U-Boot for a MX28 based board to SD card
100-----------------------------------------------------------
101
102To boot a MX28 based board from SD, set the boot mode DIP switches according
Fabio Estevam3f5e2e22013-05-03 15:07:58 -0300103to i.MX28 manual chapter 12.2.1 (Table 12-2).
Fabio Estevam419ea2d2012-03-24 12:42:21 +0000104
105An SD card the i.MX28 CPU can use to boot U-Boot must contain a DOS partition
106table, which in turn carries a partition of special type and which contains a
107special header. The rest of partitions in the DOS partition table can be used
108by the user.
109
110To prepare such partition, use your favourite partitioning tool. The partition
111must have the following parameters:
112
113 * Start sector .......... sector 2048
114 * Partition size ........ at least 1024 kb
115 * Partition type ........ 0x53 (sometimes "OnTrack DM6 Aux3")
116
117For example in Linux fdisk, the sequence for a clear card follows. Be sure to
118run fdisk with the option "-u=sectors" to set units to sectors:
119
120 * o ..................... create a clear partition table
121 * n ..................... create new partition
122 * p ............. primary partition
123 * 1 ............. first partition
124 * 2048 .......... first sector is 2048
125 * +1M ........... make the partition 1Mb big
126 * t 1 ................... change first partition ID
127 * 53 ............ change the ID to 0x53 (OnTrack DM6 Aux3)
128 * <create other partitions>
129 * w ..................... write partition table to disk
130
131The partition layout is ready, next the special partition must be filled with
132proper contents. The contents is generated by running the following command
133(see chapter 2)):
134
135 $ ./tools/mxsboot sd u-boot.sb u-boot.sd
136
137The resulting file, "u-boot.sd", shall then be written to the partition. In this
138case, we assume the first partition of the SD card is /dev/mmcblk0p1:
139
140 $ dd if=u-boot.sd of=/dev/mmcblk0p1
141
142Last step is to insert the card into MX28 based board and boot.
143
144NOTE: If the user needs to adjust the start sector, the "mxsboot" tool contains
145 a "-p" switch for that purpose. The "-p" switch takes the sector number as
146 an argument.
147
Fabio Estevame9fd0a02012-06-18 05:51:49 +00001484) Installation of U-Boot into NAND flash
149-----------------------------------------
Fabio Estevam419ea2d2012-03-24 12:42:21 +0000150
Fabio Estevam84286c22013-05-03 15:07:57 -0300151To boot a MX28 based board from NAND, set the boot mode DIP switches according
152to i.MX28 manual chapter 12.2.1 (Table 12-2), PORT=GPMI, NAND 1.8 V.
Fabio Estevam419ea2d2012-03-24 12:42:21 +0000153
154There are two possibilities when preparing an image writable to NAND flash.
155
156 I) The NAND wasn't written at all yet or the BCB is broken
157 ----------------------------------------------------------
158 In this case, both BCB (FCB and DBBT) and firmware needs to be
159 written to NAND. To generate NAND image containing all these,
160 there is a tool called "mxsboot" in the "tools/" directory. The tool
161 is invoked on "u-boot.sb" file from chapter 2):
162
163 $ ./tools/mxsboot nand u-boot.sb u-boot.nand
164
165 NOTE: The above invokation works for NAND flash with geometry of
166 2048b per page, 64b OOB data, 128kb erase size. If your chip
167 has a different geometry, please use:
168
169 -w <size> change page size (default 2048 b)
170 -o <size> change oob size (default 64 b)
171 -e <size> change erase size (default 131072 b)
172
173 The geometry information can be obtained from running U-Boot
174 on the MX28 board by issuing the "nand info" command.
175
176 The resulting file, "u-boot.nand" can be written directly to NAND
177 from the U-Boot prompt. To simplify the process, the U-Boot default
178 environment contains script "update_nand_full" to update the system.
179
180 This script expects a working TFTP server containing the file
181 "u-boot.nand" in it's root directory. This can be changed by
182 adjusting the "update_nand_full_filename" varible.
183
184 To update the system, run the following in U-Boot prompt:
185
186 => run update_nand_full
187
188 In case you would only need to update the bootloader in future,
189 see II) below.
190
191 II) The NAND was already written with a good BCB
192 ------------------------------------------------
193 This part applies after the part I) above was done at least once.
194
195 If part I) above was done correctly already, there is no need to
196 write the FCB and DBBT parts of NAND again. It's possible to upgrade
197 only the bootloader image.
198
199 To simplify the process of firmware update, the U-Boot default
200 environment contains script "update_nand_firmware" to update only
201 the firmware, without rewriting FCB and DBBT.
202
203 This script expects a working TFTP server containing the file
204 "u-boot.sb" in it's root directory. This can be changed by
205 adjusting the "update_nand_firmware_filename" varible.
206
207 To update the system, run the following in U-Boot prompt:
208
209 => run update_nand_firmware
210
211 III) Special settings for the update scripts
212 --------------------------------------------
213 There is a slight possibility of the user wanting to adjust the
214 STRIDE and COUNT options of the NAND boot. For description of these,
215 see i.MX28 manual section 12.12.1.2 and 12.12.1.3.
216
217 The update scripts take this possibility into account. In case the
218 user changes STRIDE by blowing fuses, the user also has to change
219 "update_nand_stride" variable. In case the user changes COUNT by
220 blowing fuses, the user also has to change "update_nand_count"
221 variable for the update scripts to work correctly.
222
223 In case the user needs to boot a firmware image bigger than 1Mb, the
224 user has to adjust the "update_nand_firmware_maxsz" variable for the
225 update scripts to work properly.