xref: /openbmc/u-boot/doc/imx/common/mxs.txt (revision cf033e04da315ba949e804c127abae0134bda30f)
1*75e8ca6aSBreno Matheus LimaBooting U-Boot on a MXS processor
2*75e8ca6aSBreno Matheus Lima=================================
3*75e8ca6aSBreno Matheus Lima
4*75e8ca6aSBreno Matheus LimaThis document describes the MXS U-Boot port. This document mostly covers topics
5*75e8ca6aSBreno Matheus Limarelated to making the module/board bootable.
6*75e8ca6aSBreno Matheus Lima
7*75e8ca6aSBreno Matheus LimaTerminology
8*75e8ca6aSBreno Matheus Lima-----------
9*75e8ca6aSBreno Matheus Lima
10*75e8ca6aSBreno Matheus LimaThe term "MXS" refers to a family of Freescale SoCs that is composed by MX23
11*75e8ca6aSBreno Matheus Limaand MX28.
12*75e8ca6aSBreno Matheus Lima
13*75e8ca6aSBreno Matheus LimaThe dollar symbol ($) introduces a snipped of shell code. This shall be typed
14*75e8ca6aSBreno Matheus Limainto the unix command prompt in U-Boot source code root directory.
15*75e8ca6aSBreno Matheus Lima
16*75e8ca6aSBreno Matheus LimaThe (=>) introduces a snipped of code that should by typed into U-Boot command
17*75e8ca6aSBreno Matheus Limaprompt
18*75e8ca6aSBreno Matheus Lima
19*75e8ca6aSBreno Matheus LimaContents
20*75e8ca6aSBreno Matheus Lima--------
21*75e8ca6aSBreno Matheus Lima
22*75e8ca6aSBreno Matheus Lima1) Prerequisites
23*75e8ca6aSBreno Matheus Lima2) Compiling U-Boot for a MXS based board
24*75e8ca6aSBreno Matheus Lima3) Installation of U-Boot for a MXS based board to SD card
25*75e8ca6aSBreno Matheus Lima4) Installation of U-Boot into NAND flash on a MX28 based board
26*75e8ca6aSBreno Matheus Lima5) Installation of U-Boot into SPI NOR flash on a MX28 based board
27*75e8ca6aSBreno Matheus Lima
28*75e8ca6aSBreno Matheus Lima1) Prerequisites
29*75e8ca6aSBreno Matheus Lima----------------
30*75e8ca6aSBreno Matheus Lima
31*75e8ca6aSBreno Matheus LimaTo make a MXS based board bootable, some tools are necessary. The only
32*75e8ca6aSBreno Matheus Limamandatory tool is the "mxsboot" tool found in U-Boot source tree. The
33*75e8ca6aSBreno Matheus Limatool is built automatically when compiling U-Boot for i.MX23 or i.MX28.
34*75e8ca6aSBreno Matheus Lima
35*75e8ca6aSBreno Matheus LimaThe production of BootStream image is handled via "mkimage", which is
36*75e8ca6aSBreno Matheus Limaalso part of the U-Boot source tree. The "mkimage" requires OpenSSL
37*75e8ca6aSBreno Matheus Limadevelopment libraries to be installed. In case of Debian and derivates,
38*75e8ca6aSBreno Matheus Limathis is installed by running:
39*75e8ca6aSBreno Matheus Lima
40*75e8ca6aSBreno Matheus Lima	$ sudo apt-get install libssl-dev
41*75e8ca6aSBreno Matheus Lima
42*75e8ca6aSBreno Matheus LimaNOTE: The "elftosb" tool distributed by Freescale Semiconductor is no
43*75e8ca6aSBreno Matheus Lima      longer necessary for general use of U-Boot on i.MX23 and i.MX28.
44*75e8ca6aSBreno Matheus Lima      The mkimage supports generation of BootStream images encrypted
45*75e8ca6aSBreno Matheus Lima      with a zero key, which is the vast majority of use-cases. In
46*75e8ca6aSBreno Matheus Lima      case you do need to produce image encrypted with non-zero key
47*75e8ca6aSBreno Matheus Lima      or other special features, please use the "elftosb" tool,
48*75e8ca6aSBreno Matheus Lima      otherwise continue to section 2). The installation procedure of
49*75e8ca6aSBreno Matheus Lima      the "elftosb" is outlined below:
50*75e8ca6aSBreno Matheus Lima
51*75e8ca6aSBreno Matheus LimaFirstly, obtain the elftosb archive from the following location:
52*75e8ca6aSBreno Matheus Lima
53*75e8ca6aSBreno Matheus Lima	ftp://ftp.denx.de/pub/tools/elftosb-10.12.01.tar.gz
54*75e8ca6aSBreno Matheus Lima
55*75e8ca6aSBreno Matheus LimaWe use a $VER variable here to denote the current version. At the time of
56*75e8ca6aSBreno Matheus Limawriting of this document, that is "10.12.01". To obtain the file from command
57*75e8ca6aSBreno Matheus Limaline, use:
58*75e8ca6aSBreno Matheus Lima
59*75e8ca6aSBreno Matheus Lima	$ VER="10.12.01"
60*75e8ca6aSBreno Matheus Lima	$ wget ftp://ftp.denx.de/pub/tools/elftosb-${VER}.tar.gz
61*75e8ca6aSBreno Matheus Lima
62*75e8ca6aSBreno Matheus LimaExtract the file:
63*75e8ca6aSBreno Matheus Lima
64*75e8ca6aSBreno Matheus Lima	$ tar xzf elftosb-${VER}.tar.gz
65*75e8ca6aSBreno Matheus Lima
66*75e8ca6aSBreno Matheus LimaCompile the file. We need to manually tell the linker to use also libm:
67*75e8ca6aSBreno Matheus Lima
68*75e8ca6aSBreno Matheus Lima	$ cd elftosb-${VER}/
69*75e8ca6aSBreno Matheus Lima	$ make LIBS="-lstdc++ -lm" elftosb
70*75e8ca6aSBreno Matheus Lima
71*75e8ca6aSBreno Matheus LimaOptionally, remove debugging symbols from elftosb:
72*75e8ca6aSBreno Matheus Lima
73*75e8ca6aSBreno Matheus Lima	$ strip bld/linux/elftosb
74*75e8ca6aSBreno Matheus Lima
75*75e8ca6aSBreno Matheus LimaFinally, install the "elftosb" binary. The "install" target is missing, so just
76*75e8ca6aSBreno Matheus Limacopy the binary by hand:
77*75e8ca6aSBreno Matheus Lima
78*75e8ca6aSBreno Matheus Lima	$ sudo cp bld/linux/elftosb /usr/local/bin/
79*75e8ca6aSBreno Matheus Lima
80*75e8ca6aSBreno Matheus LimaMake sure the "elftosb" binary can be found in your $PATH, in this case this
81*75e8ca6aSBreno Matheus Limameans "/usr/local/bin/" has to be in your $PATH.
82*75e8ca6aSBreno Matheus Lima
83*75e8ca6aSBreno Matheus Lima2) Compiling U-Boot for a MXS based board
84*75e8ca6aSBreno Matheus Lima-------------------------------------------
85*75e8ca6aSBreno Matheus Lima
86*75e8ca6aSBreno Matheus LimaCompiling the U-Boot for a MXS board is straightforward and done as compiling
87*75e8ca6aSBreno Matheus LimaU-Boot for any other ARM device. For cross-compiler setup, please refer to
88*75e8ca6aSBreno Matheus LimaELDK5.0 documentation. First, clean up the source code:
89*75e8ca6aSBreno Matheus Lima
90*75e8ca6aSBreno Matheus Lima	$ make mrproper
91*75e8ca6aSBreno Matheus Lima
92*75e8ca6aSBreno Matheus LimaNext, configure U-Boot for a MXS based board
93*75e8ca6aSBreno Matheus Lima
94*75e8ca6aSBreno Matheus Lima	$ make <mxs_based_board_name>_config
95*75e8ca6aSBreno Matheus Lima
96*75e8ca6aSBreno Matheus LimaExamples:
97*75e8ca6aSBreno Matheus Lima
98*75e8ca6aSBreno Matheus Lima1. For building U-Boot for Aries M28EVK board:
99*75e8ca6aSBreno Matheus Lima
100*75e8ca6aSBreno Matheus Lima	$ make m28evk_config
101*75e8ca6aSBreno Matheus Lima
102*75e8ca6aSBreno Matheus Lima2. For building U-Boot for Freescale MX28EVK board:
103*75e8ca6aSBreno Matheus Lima
104*75e8ca6aSBreno Matheus Lima	$ make mx28evk_config
105*75e8ca6aSBreno Matheus Lima
106*75e8ca6aSBreno Matheus Lima3. For building U-Boot for Freescale MX23EVK board:
107*75e8ca6aSBreno Matheus Lima
108*75e8ca6aSBreno Matheus Lima	$ make mx23evk_config
109*75e8ca6aSBreno Matheus Lima
110*75e8ca6aSBreno Matheus Lima4. For building U-Boot for Olimex MX23 Olinuxino board:
111*75e8ca6aSBreno Matheus Lima
112*75e8ca6aSBreno Matheus Lima	$ make mx23_olinuxino_config
113*75e8ca6aSBreno Matheus Lima
114*75e8ca6aSBreno Matheus LimaLastly, compile U-Boot and prepare a "BootStream". The "BootStream" is a special
115*75e8ca6aSBreno Matheus Limatype of file, which MXS CPUs can boot. This is handled by the following
116*75e8ca6aSBreno Matheus Limacommand:
117*75e8ca6aSBreno Matheus Lima
118*75e8ca6aSBreno Matheus Lima	$ make u-boot.sb
119*75e8ca6aSBreno Matheus Lima
120*75e8ca6aSBreno Matheus LimaHINT: To speed-up the build process, you can add -j<N>, where N is number of
121*75e8ca6aSBreno Matheus Lima      compiler instances that'll run in parallel.
122*75e8ca6aSBreno Matheus Lima
123*75e8ca6aSBreno Matheus LimaThe code produces "u-boot.sb" file. This file needs to be augmented with a
124*75e8ca6aSBreno Matheus Limaproper header to allow successful boot from SD or NAND. Adding the header is
125*75e8ca6aSBreno Matheus Limadiscussed in the following chapters.
126*75e8ca6aSBreno Matheus Lima
127*75e8ca6aSBreno Matheus LimaNOTE: The process that produces u-boot.sb uses the mkimage to generate the
128*75e8ca6aSBreno Matheus Lima      BootStream. The BootStream is encrypted with zero key. In case you need
129*75e8ca6aSBreno Matheus Lima      some special features of the BootStream and plan on using the "elftosb"
130*75e8ca6aSBreno Matheus Lima      tool instead, the invocation to produce a compatible BootStream with the
131*75e8ca6aSBreno Matheus Lima      one produced by mkimage is outlined below. For further details, refer to
132*75e8ca6aSBreno Matheus Lima      the documentation bundled with the "elftosb" package.
133*75e8ca6aSBreno Matheus Lima
134*75e8ca6aSBreno Matheus Lima	$ elftosb -zf imx23 -c arch/arm/cpu/arm926ejs/mxs/u-boot-imx23.bd \
135*75e8ca6aSBreno Matheus Lima		-o u-boot.sb
136*75e8ca6aSBreno Matheus Lima	$ elftosb -zf imx28 -c arch/arm/cpu/arm926ejs/mxs/u-boot-imx28.bd \
137*75e8ca6aSBreno Matheus Lima		-o u-boot.sb
138*75e8ca6aSBreno Matheus Lima
139*75e8ca6aSBreno Matheus Lima3) Installation of U-Boot for a MXS based board to SD card
140*75e8ca6aSBreno Matheus Lima----------------------------------------------------------
141*75e8ca6aSBreno Matheus Lima
142*75e8ca6aSBreno Matheus LimaTo boot a MXS based board from SD, set the boot mode DIP switches according to
143*75e8ca6aSBreno Matheus Limato MX28 manual, section 12.2.1 (Table 12-2) or MX23 manual, section 35.1.2
144*75e8ca6aSBreno Matheus Lima(Table 35-3).
145*75e8ca6aSBreno Matheus Lima
146*75e8ca6aSBreno Matheus LimaThe SD card used to boot U-Boot must contain a DOS partition table, which in
147*75e8ca6aSBreno Matheus Limaturn carries a partition of special type and which contains a special header.
148*75e8ca6aSBreno Matheus LimaThe rest of partitions in the DOS partition table can be used by the user.
149*75e8ca6aSBreno Matheus Lima
150*75e8ca6aSBreno Matheus LimaTo prepare such partition, use your favourite partitioning tool. The partition
151*75e8ca6aSBreno Matheus Limamust have the following parameters:
152*75e8ca6aSBreno Matheus Lima
153*75e8ca6aSBreno Matheus Lima	* Start sector .......... sector 2048
154*75e8ca6aSBreno Matheus Lima	* Partition size ........ at least 1024 kb
155*75e8ca6aSBreno Matheus Lima	* Partition type ........ 0x53 (sometimes "OnTrack DM6 Aux3")
156*75e8ca6aSBreno Matheus Lima
157*75e8ca6aSBreno Matheus LimaFor example in Linux fdisk, the sequence for a clear card follows. Be sure to
158*75e8ca6aSBreno Matheus Limarun fdisk with the option "-u=sectors" to set units to sectors:
159*75e8ca6aSBreno Matheus Lima
160*75e8ca6aSBreno Matheus Lima	* o ..................... create a clear partition table
161*75e8ca6aSBreno Matheus Lima	* n ..................... create new partition
162*75e8ca6aSBreno Matheus Lima		* p ............. primary partition
163*75e8ca6aSBreno Matheus Lima		* 1 ............. first partition
164*75e8ca6aSBreno Matheus Lima		* 2048 .......... first sector is 2048
165*75e8ca6aSBreno Matheus Lima		* +1M ........... make the partition 1Mb big
166*75e8ca6aSBreno Matheus Lima	* t 1 ................... change first partition ID
167*75e8ca6aSBreno Matheus Lima		* 53 ............ change the ID to 0x53 (OnTrack DM6 Aux3)
168*75e8ca6aSBreno Matheus Lima	* <create other partitions>
169*75e8ca6aSBreno Matheus Lima	* w ..................... write partition table to disk
170*75e8ca6aSBreno Matheus Lima
171*75e8ca6aSBreno Matheus LimaThe partition layout is ready, next the special partition must be filled with
172*75e8ca6aSBreno Matheus Limaproper contents. The contents is generated by running the following command
173*75e8ca6aSBreno Matheus Lima(see chapter 2)):
174*75e8ca6aSBreno Matheus Lima
175*75e8ca6aSBreno Matheus Lima	$ ./tools/mxsboot sd u-boot.sb u-boot.sd
176*75e8ca6aSBreno Matheus Lima
177*75e8ca6aSBreno Matheus LimaThe resulting file, "u-boot.sd", shall then be written to the partition. In this
178*75e8ca6aSBreno Matheus Limacase, we assume the first partition of the SD card is /dev/mmcblk0p1:
179*75e8ca6aSBreno Matheus Lima
180*75e8ca6aSBreno Matheus Lima	$ dd if=u-boot.sd of=/dev/mmcblk0p1
181*75e8ca6aSBreno Matheus Lima
182*75e8ca6aSBreno Matheus LimaLast step is to insert the card into the MXS based board and boot.
183*75e8ca6aSBreno Matheus Lima
184*75e8ca6aSBreno Matheus LimaNOTE: If the user needs to adjust the start sector, the "mxsboot" tool contains
185*75e8ca6aSBreno Matheus Lima      a "-p" switch for that purpose. The "-p" switch takes the sector number as
186*75e8ca6aSBreno Matheus Lima      an argument.
187*75e8ca6aSBreno Matheus Lima
188*75e8ca6aSBreno Matheus Lima4) Installation of U-Boot into NAND flash on a MX28 based board
189*75e8ca6aSBreno Matheus Lima---------------------------------------------------------------
190*75e8ca6aSBreno Matheus Lima
191*75e8ca6aSBreno Matheus LimaTo boot a MX28 based board from NAND, set the boot mode DIP switches according
192*75e8ca6aSBreno Matheus Limato MX28 manual section 12.2.1 (Table 12-2), PORT=GPMI, NAND 1.8 V.
193*75e8ca6aSBreno Matheus Lima
194*75e8ca6aSBreno Matheus LimaThere are two possibilities when preparing an image writable to NAND flash.
195*75e8ca6aSBreno Matheus Lima
196*75e8ca6aSBreno Matheus Lima	I) The NAND wasn't written at all yet or the BCB is broken
197*75e8ca6aSBreno Matheus Lima	----------------------------------------------------------
198*75e8ca6aSBreno Matheus Lima	   In this case, both BCB (FCB and DBBT) and firmware needs to be
199*75e8ca6aSBreno Matheus Lima	   written to NAND. To generate NAND image containing all these,
200*75e8ca6aSBreno Matheus Lima	   there is a tool called "mxsboot" in the "tools/" directory. The tool
201*75e8ca6aSBreno Matheus Lima	   is invoked on "u-boot.sb" file from chapter 2):
202*75e8ca6aSBreno Matheus Lima
203*75e8ca6aSBreno Matheus Lima		 $ ./tools/mxsboot nand u-boot.sb u-boot.nand
204*75e8ca6aSBreno Matheus Lima
205*75e8ca6aSBreno Matheus Lima	   NOTE: The above invokation works for NAND flash with geometry of
206*75e8ca6aSBreno Matheus Lima		 2048b per page, 64b OOB data, 128kb erase size. If your chip
207*75e8ca6aSBreno Matheus Lima		 has a different geometry, please use:
208*75e8ca6aSBreno Matheus Lima
209*75e8ca6aSBreno Matheus Lima		 -w <size>	change page size (default 2048 b)
210*75e8ca6aSBreno Matheus Lima		 -o <size>	change oob size (default 64 b)
211*75e8ca6aSBreno Matheus Lima		 -e <size>	change erase size (default 131072 b)
212*75e8ca6aSBreno Matheus Lima
213*75e8ca6aSBreno Matheus Lima		 The geometry information can be obtained from running U-Boot
214*75e8ca6aSBreno Matheus Lima		 on the MX28 board by issuing the "nand info" command.
215*75e8ca6aSBreno Matheus Lima
216*75e8ca6aSBreno Matheus Lima	   The resulting file, "u-boot.nand" can be written directly to NAND
217*75e8ca6aSBreno Matheus Lima	   from the U-Boot prompt. To simplify the process, the U-Boot default
218*75e8ca6aSBreno Matheus Lima	   environment contains script "update_nand_full" to update the system.
219*75e8ca6aSBreno Matheus Lima
220*75e8ca6aSBreno Matheus Lima	   This script expects a working TFTP server containing the file
221*75e8ca6aSBreno Matheus Lima	   "u-boot.nand" in it's root directory. This can be changed by
222*75e8ca6aSBreno Matheus Lima	   adjusting the "update_nand_full_filename" variable.
223*75e8ca6aSBreno Matheus Lima
224*75e8ca6aSBreno Matheus Lima	   To update the system, run the following in U-Boot prompt:
225*75e8ca6aSBreno Matheus Lima
226*75e8ca6aSBreno Matheus Lima		 => run update_nand_full
227*75e8ca6aSBreno Matheus Lima
228*75e8ca6aSBreno Matheus Lima	   In case you would only need to update the bootloader in future,
229*75e8ca6aSBreno Matheus Lima	   see II) below.
230*75e8ca6aSBreno Matheus Lima
231*75e8ca6aSBreno Matheus Lima	II) The NAND was already written with a good BCB
232*75e8ca6aSBreno Matheus Lima	------------------------------------------------
233*75e8ca6aSBreno Matheus Lima	   This part applies after the part I) above was done at least once.
234*75e8ca6aSBreno Matheus Lima
235*75e8ca6aSBreno Matheus Lima	   If part I) above was done correctly already, there is no need to
236*75e8ca6aSBreno Matheus Lima	   write the FCB and DBBT parts of NAND again. It's possible to upgrade
237*75e8ca6aSBreno Matheus Lima	   only the bootloader image.
238*75e8ca6aSBreno Matheus Lima
239*75e8ca6aSBreno Matheus Lima	   To simplify the process of firmware update, the U-Boot default
240*75e8ca6aSBreno Matheus Lima	   environment contains script "update_nand_firmware" to update only
241*75e8ca6aSBreno Matheus Lima	   the firmware, without rewriting FCB and DBBT.
242*75e8ca6aSBreno Matheus Lima
243*75e8ca6aSBreno Matheus Lima	   This script expects a working TFTP server containing the file
244*75e8ca6aSBreno Matheus Lima	   "u-boot.sb" in it's root directory. This can be changed by
245*75e8ca6aSBreno Matheus Lima	   adjusting the "update_nand_firmware_filename" variable.
246*75e8ca6aSBreno Matheus Lima
247*75e8ca6aSBreno Matheus Lima	   To update the system, run the following in U-Boot prompt:
248*75e8ca6aSBreno Matheus Lima
249*75e8ca6aSBreno Matheus Lima		 => run update_nand_firmware
250*75e8ca6aSBreno Matheus Lima
251*75e8ca6aSBreno Matheus Lima	III) Special settings for the update scripts
252*75e8ca6aSBreno Matheus Lima	--------------------------------------------
253*75e8ca6aSBreno Matheus Lima	   There is a slight possibility of the user wanting to adjust the
254*75e8ca6aSBreno Matheus Lima	   STRIDE and COUNT options of the NAND boot. For description of these,
255*75e8ca6aSBreno Matheus Lima	   see MX28 manual section 12.12.1.2 and 12.12.1.3.
256*75e8ca6aSBreno Matheus Lima
257*75e8ca6aSBreno Matheus Lima	   The update scripts take this possibility into account. In case the
258*75e8ca6aSBreno Matheus Lima	   user changes STRIDE by blowing fuses, the user also has to change
259*75e8ca6aSBreno Matheus Lima	   "update_nand_stride" variable. In case the user changes COUNT by
260*75e8ca6aSBreno Matheus Lima	   blowing fuses, the user also has to change "update_nand_count"
261*75e8ca6aSBreno Matheus Lima	   variable for the update scripts to work correctly.
262*75e8ca6aSBreno Matheus Lima
263*75e8ca6aSBreno Matheus Lima	   In case the user needs to boot a firmware image bigger than 1Mb, the
264*75e8ca6aSBreno Matheus Lima	   user has to adjust the "update_nand_firmware_maxsz" variable for the
265*75e8ca6aSBreno Matheus Lima	   update scripts to work properly.
266*75e8ca6aSBreno Matheus Lima
267*75e8ca6aSBreno Matheus Lima5) Installation of U-Boot into SPI NOR flash on a MX28 based board
268*75e8ca6aSBreno Matheus Lima------------------------------------------------------------------
269*75e8ca6aSBreno Matheus Lima
270*75e8ca6aSBreno Matheus LimaThe u-boot.sb file can be directly written to SPI NOR from U-Boot prompt.
271*75e8ca6aSBreno Matheus Lima
272*75e8ca6aSBreno Matheus LimaLoad u-boot.sb into RAM, this can be done in several ways and one way is to use
273*75e8ca6aSBreno Matheus Limatftp:
274*75e8ca6aSBreno Matheus Lima       => tftp u-boot.sb 0x42000000
275*75e8ca6aSBreno Matheus Lima
276*75e8ca6aSBreno Matheus LimaProbe the SPI NOR flash:
277*75e8ca6aSBreno Matheus Lima       => sf probe
278*75e8ca6aSBreno Matheus Lima
279*75e8ca6aSBreno Matheus Lima(SPI NOR should be succesfully detected in this step)
280*75e8ca6aSBreno Matheus Lima
281*75e8ca6aSBreno Matheus LimaErase the blocks where U-Boot binary will be written to:
282*75e8ca6aSBreno Matheus Lima       => sf erase 0x0 0x80000
283*75e8ca6aSBreno Matheus Lima
284*75e8ca6aSBreno Matheus LimaWrite u-boot.sb to SPI NOR:
285*75e8ca6aSBreno Matheus Lima       => sf write 0x42000000 0 0x80000
286*75e8ca6aSBreno Matheus Lima
287*75e8ca6aSBreno Matheus LimaPower off the board and set the boot mode DIP switches to boot from the SPI NOR
288*75e8ca6aSBreno Matheus Limaaccording to MX28 manual section 12.2.1 (Table 12-2)
289*75e8ca6aSBreno Matheus Lima
290*75e8ca6aSBreno Matheus LimaLast step is to power up the board and U-Boot should start from SPI NOR.
291