blob: 42bb94148d9d4e0dc66970b92b77d29b5e065742 [file] [log] [blame]
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +01001.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
Patrice Chotard90e82782021-01-04 17:00:56 +01002.. sectionauthor:: Patrick Delaunay <patrick.delaunay@foss.st.com>
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +01003
4STM32MP15x boards
5=================
6
7This is a quick instruction for setup STM32MP15x boards.
8
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +02009Futher information can be found in STMicrolectronics STM32 WIKI_.
10
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +010011Supported devices
12-----------------
13
14U-Boot supports STMP32MP15x SoCs:
15
16 - STM32MP157
17 - STM32MP153
18 - STM32MP151
19
20The STM32MP15x is a Cortex-A MPU aimed at various applications.
21
22It features:
23
24 - Dual core Cortex-A7 application core (Single on STM32MP151)
25 - 2D/3D image composition with GPU (only on STM32MP157)
26 - Standard memories interface support
27 - Standard connectivity, widely inherited from the STM32 MCU family
28 - Comprehensive security support
29
Patrick Delaunaydb33b0e2020-02-26 11:26:43 +010030Each line comes with a security option (cryptography & secure boot) and
31a Cortex-A frequency option:
32
33 - A : Cortex-A7 @ 650 MHz
34 - C : Secure Boot + HW Crypto + Cortex-A7 @ 650 MHz
35 - D : Cortex-A7 @ 800 MHz
36 - F : Secure Boot + HW Crypto + Cortex-A7 @ 800 MHz
37
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +010038Everything is supported in Linux but U-Boot is limited to:
39
40 1. UART
41 2. SD card/MMC controller (SDMMC)
42 3. NAND controller (FMC)
43 4. NOR controller (QSPI)
44 5. USB controller (OTG DWC2)
45 6. Ethernet controller
46
47And the necessary drivers
48
49 1. I2C
50 2. STPMIC1 (PMIC and regulator)
51 3. Clock, Reset, Sysreset
52 4. Fuse
53
54Currently the following boards are supported:
55
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +010056 + stm32mp157a-dk1.dts
57 + stm32mp157c-dk2.dts
58 + stm32mp157c-ed1.dts
59 + stm32mp157c-ev1.dts
Marek Vasut526c9512020-03-31 19:51:36 +020060 + stm32mp15xx-dhcor-avenger96.dts
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +010061
62Boot Sequences
63--------------
64
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200652 boot configurations are supported with:
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +010066
67+----------+------------------------+-------------------------+--------------+
68| **ROM** | **FSBL** | **SSBL** | **OS** |
69+ **code** +------------------------+-------------------------+--------------+
70| | First Stage Bootloader | Second Stage Bootloader | Linux Kernel |
71+ +------------------------+-------------------------+--------------+
72| | embedded RAM | DDR |
73+----------+------------------------+-------------------------+--------------+
74
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +020075The **Trusted** boot chain with TF-A_
76`````````````````````````````````````
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +010077
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +020078defconfig_file :
79 + **stm32mp15_defconfig** (for TF-A_ with FIP support)
80 + **stm32mp15_trusted_defconfig** (for TF-A_ without FIP support)
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +010081
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +020082 +-------------+--------------------------+------------+-------+
83 | ROM code | FSBL | SSBL | OS |
84 + +--------------------------+------------+-------+
85 | |Trusted Firmware-A (TF-A_)| U-Boot | Linux |
86 +-------------+--------------------------+------------+-------+
87 | TrustZone |secure monitor = SPMin or OP-TEE_ |
88 +-------------+--------------------------+------------+-------+
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +010089
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +020090TF-A_ and OP-TEE_ are 2 separate projects, with their git repository;
91they are compiled separately.
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +010092
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +020093TF-A_ (BL2) initialize the DDR and loads the next stage binaries from a FIP file:
94 + BL32: a secure monitor BL32 = SPMin provided by TF-A_ or OP-TEE_ :
95 performs a full initialization of Secure peripherals and provides service
96 to normal world
97 + BL33: a non-trusted firmware = U-Boot, running in normal world and uses
98 the secure monitor to access to secure resources.
99 + HW_CONFIG: The hardware configuration file = the U-Boot device tree
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100100
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200101The **Basic** boot chain with SPL
102`````````````````````````````````
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100103
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200104defconfig_file :
105 + **stm32mp15_basic_defconfig**
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100106
107 +-------------+------------+------------+-------+
108 | ROM code | FSBL | SSBL | OS |
109 + +------------+------------+-------+
110 | |U-Boot SPL | U-Boot | Linux |
111 +-------------+------------+------------+-------+
112 | TrustZone | | PSCI from U-Boot |
113 +-------------+------------+------------+-------+
114
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200115SPL has limited security initialization.
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100116
117U-Boot is running in secure mode and provide a secure monitor to the kernel
118with only PSCI support (Power State Coordination Interface defined by ARM).
119
120All the STM32MP15x boards supported by U-Boot use the same generic board
121stm32mp1 which support all the bootable devices.
122
123Each board is configured only with the associated device tree.
124
125Device Tree Selection
126---------------------
127
128You need to select the appropriate device tree for your board,
129the supported device trees for STM32MP15x are:
130
131+ ev1: eval board with pmic stpmic1 (ev1 = mother board + daughter ed1)
132
133 + stm32mp157c-ev1
134
135+ ed1: daughter board with pmic stpmic1
136
137 + stm32mp157c-ed1
138
139+ dk1: Discovery board
140
141 + stm32mp157a-dk1
142
143+ dk2: Discovery board = dk1 with a BT/WiFI combo and a DSI panel
144
145 + stm32mp157c-dk2
146
Marek Vasut526c9512020-03-31 19:51:36 +0200147+ avenger96: Avenger96 board from Arrow Electronics based on DH Elec. DHCOR SoM
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100148
Marek Vasut526c9512020-03-31 19:51:36 +0200149 + stm32mp15xx-dhcor-avenger96
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100150
151Build Procedure
152---------------
153
1541. Install the required tools for U-Boot
155
156 * install package needed in U-Boot makefile
157 (libssl-dev, swig, libpython-dev...)
158
159 * install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
160 from SDK for STM32MP15x, or any crosstoolchains from your distribution)
161 (you can use any gcc cross compiler compatible with U-Boot)
162
1632. Set the cross compiler::
164
165 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
166
1673. Select the output directory (optional)::
168
169 # export KBUILD_OUTPUT=/path/to/output
170
171 for example: use one output directory for each configuration::
172
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200173 # export KBUILD_OUTPUT=stm32mp15
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100174 # export KBUILD_OUTPUT=stm32mp15_trusted
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100175 # export KBUILD_OUTPUT=stm32mp15_basic
176
177 you can build outside of code directory::
178
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200179 # export KBUILD_OUTPUT=../build/stm32mp15
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100180
1814. Configure U-Boot::
182
183 # make <defconfig_file>
184
185 with <defconfig_file>:
186
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200187 - For **trusted** boot mode : **stm32mp15_defconfig** or
188 stm32mp15_trusted_defconfig
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100189 - For basic boot mode: stm32mp15_basic_defconfig
190
1915. Configure the device-tree and build the U-Boot image::
192
193 # make DEVICE_TREE=<name> all
194
195 Examples:
196
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200197 a) trusted boot with FIP on ev1::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100198
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200199 # export KBUILD_OUTPUT=stm32mp15
200 # make stm32mp15_defconfig
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100201 # make DEVICE_TREE=stm32mp157c-ev1 all
202
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200203 b) trusted boot without FIP on dk2::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100204
Patrick Delaunay6557aa82020-03-18 09:22:51 +0100205 # export KBUILD_OUTPUT=stm32mp15_trusted
206 # make stm32mp15_trusted_defconfig
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100207 # make DEVICE_TREE=stm32mp157c-dk2 all
208
209 c) basic boot on ev1::
210
211 # export KBUILD_OUTPUT=stm32mp15_basic
212 # make stm32mp15_basic_defconfig
213 # make DEVICE_TREE=stm32mp157c-ev1 all
214
215 d) basic boot on ed1::
216
217 # export KBUILD_OUTPUT=stm32mp15_basic
218 # make stm32mp15_basic_defconfig
219 # make DEVICE_TREE=stm32mp157c-ed1 all
220
221 e) basic boot on dk1::
222
223 # export KBUILD_OUTPUT=stm32mp15_basic
224 # make stm32mp15_basic_defconfig
225 # make DEVICE_TREE=stm32mp157a-dk1 all
226
227 f) basic boot on avenger96::
228
229 # export KBUILD_OUTPUT=stm32mp15_basic
230 # make stm32mp15_basic_defconfig
Marek Vasut526c9512020-03-31 19:51:36 +0200231 # make DEVICE_TREE=stm32mp15xx-dhcor-avenger96 all
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100232
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +02002336. U-Boot Output files
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100234
235 So in the output directory (selected by KBUILD_OUTPUT),
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200236 you can found the needed U-Boot files:
237
238 - stm32mp15_defconfig = **u-boot-nodtb.bin** and **u-boot.dtb**
239
240 - stm32mp15_trusted_defconfig = u-boot.stm32
241
242 - stm32mp15_basic_defconfig
243
244 - FSBL = spl/u-boot-spl.stm32
245
246 - SSBL = u-boot.img (without CONFIG_SPL_LOAD_FIT) or
247 u-boot.itb (with CONFIG_SPL_LOAD_FIT=y)
248
2497. TF-A_ compilation
250
251 This step is required only for **Trusted** boot (stm32mp15_defconfig and
252 stm32mp15_trusted_defconfig); see OP-TEE_ and TF-A_ documentation for build
253 commands.
254
255 - For TF-A_ with FIP support: **stm32mp15_defconfig**
256
257 - with OP-TEE_ support, compile the OP-TEE to generate the binary included
258 in FIP
259
260 - after TF-A compilation, the used files are:
261
262 - TF-A_ BL2 => FSBL = **tf-a.stm32**
263
264 - FIP => **fip.bin**
265
266 FIP file includes the 2 files given in arguments of TF-A_ compilation:
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100267
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200268 - BL33=u-boot-nodtb.bin
269 - BL33_CFG=u-boot.dtb
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100270
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200271 You can also update a existing FIP after U-boot compilation with fiptool,
272 a tool provided by TF-A_::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100273
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200274 # fiptool update --nt-fw u-boot-nodtb.bin --hw-config u-boot.dtb fip-stm32mp157c-ev1.bin
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100275
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200276 - For TF-A_ without FIP support : **stm32mp15_trusted_defconfig**
277 SPMin is used and the used files are:
278
279 - FSBL = **tf-a.stm32** (provided by TF-A_ compilation, contening BL2 and
280 BL32 = SPMin)
281
282 - SSBL = **u-boot.stm32** used instead of fip.bin in next chapters
283
2848. The bootloaders files
285
286+ The **ROM code** expects FSBL binaries with STM32 image header =
287 tf-a.stm32 or u-boot-spl.stm32
288
289According the FSBL / the boot mode:
290
291+ **TF-A** expect a FIP binary = fip.bin, including the OS monitor (SPMin or
292 OP-TEE_) and the U-Boot binary + device tree
293
294 or, without FIP support, binaries with STM32 image header: U-Boot
295 = u-boot.stm32 and eventually OP-TEE files (tee-header.stm32, tee-pageable.stm32,
296 tee-pager.stm32)
297
298+ **SPL** expects SSBL = U-Boot with uImage header = u-boot.img
299 or FIT = u-boot.itb.
300
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100301
302Switch Setting for Boot Mode
303----------------------------
304
305You can select the boot mode, on the board with one switch, to select
306the boot pin values = BOOT0, BOOT1, BOOT2
307
308 +-------------+---------+---------+---------+
309 |*Boot Mode* | *BOOT2* | *BOOT1* | *BOOT0* |
310 +=============+=========+=========+=========+
311 | Recovery | 0 | 0 | 0 |
312 +-------------+---------+---------+---------+
313 | NOR | 0 | 0 | 1 |
314 +-------------+---------+---------+---------+
315 | eMMC | 0 | 1 | 0 |
316 +-------------+---------+---------+---------+
317 | NAND | 0 | 1 | 1 |
318 +-------------+---------+---------+---------+
319 | Reserved | 1 | 0 | 0 |
320 +-------------+---------+---------+---------+
321 | SD-Card | 1 | 0 | 1 |
322 +-------------+---------+---------+---------+
323 | Recovery | 1 | 1 | 0 |
324 +-------------+---------+---------+---------+
325 | SPI-NAND | 1 | 1 | 1 |
326 +-------------+---------+---------+---------+
327
328- on the **daugther board ed1 = MB1263** with the switch SW1
329- on **Avenger96** with switch S3 (NOR and SPI-NAND are not applicable)
330- on board **DK1/DK2** with the switch SW1 = BOOT0, BOOT2
331 with only 2 pins available (BOOT1 is forced to 0 and NOR not supported),
332 the possible value becomes:
333
334 +-------------+---------+---------+
335 |*Boot Mode* | *BOOT2* | *BOOT0* |
336 +=============+=========+=========+
337 | Recovery | 0 | 0 |
338 +-------------+---------+---------+
339 | NOR (NA)| 0 | 1 |
340 +-------------+---------+---------+
341 | Reserved | 1 | 0 |
342 +-------------+---------+---------+
343 | SD-Card | 1 | 1 |
344 +-------------+---------+---------+
345
346Recovery is a boot from serial link (UART/USB) and it is used with
347STM32CubeProgrammer tool to load executable in RAM and to update the flash
348devices available on the board (NOR/NAND/eMMC/SD card).
349
350The communication between HOST and board is based on
351
352 - for UARTs : the uart protocol used with all MCU STM32
353 - for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
354
355Prepare an SD card
356------------------
357
358The minimal requirements for STMP32MP15x boot up to U-Boot are:
359
360- GPT partitioning (with gdisk or with sgdisk)
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200361- 2 fsbl partitions, named "fsbl1" and "fsbl2", size at least 256KiB
362- one partition named "fip" for FIP or U-Boot (TF-A_ search the "fip"
363 partition and SPL search the 3th partition, because
364 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=3)
365
366The 2 fsbl partitions have the same content and are present to guarantee a
367fail-safe update of FSBL; fsbl2 can be omitted if this ROM code feature is
368not required.
369
370Without FIP support in TF-A_, the 3rd partition "fip" for u-boot.stm32 must
371be named "ssbl".
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100372
373Then the minimal GPT partition is:
374
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200375For TF-A_ with FIP support:
376
377 +-------+--------+---------+------------------------+
378 | *Num* | *Name* | *Size* | *Content* |
379 +=======+========+=========+========================+
380 | 1 | fsbl1 | 256 KiB | TF-A_ BL2 (tf-a.stm32) |
381 +-------+--------+---------+------------------------+
382 | 2 | fsbl2 | 256 KiB | TF-A_ BL2 (tf-a.stm32) |
383 +-------+--------+---------+------------------------+
384 | 3 | fip | 4MB | fip.bin |
385 +-------+--------+---------+------------------------+
386 | 4 | <any> | <any> | Rootfs |
387 +-------+--------+---------+------------------------+
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100388
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200389or:
390
391 +-------+--------+---------+------------------------+------------------------+
392 | *Num* | *Name* | *Size* | *Trusted boot content* | *Basic boot content* |
393 +=======+========+=========+========================+========================+
394 | 1 | fsbl1 | 256 KiB | TF-A_ BL2 (tf-a.stm32) | SPL (u-boot-spl.stm32) |
395 +-------+--------+---------+------------------------+------------------------+
396 | 2 | fsbl2 | 256 KiB | TF-A_ BL2 (tf-a.stm32) | SPL (u-boot-spl.stm32) |
397 +-------+--------+---------+------------------------+------------------------+
398 | 3 | ssbl | 2MB | U-Boot (u-boot.stm32) | U-Boot (u-boot.img) |
399 +-------+--------+---------+------------------------+------------------------+
400 | 4 | <any> | <any> | Rootfs |
401 +-------+--------+---------+------------------------+------------------------+
402
403And the 4th partition (Rootfs) is marked bootable with a file extlinux.conf
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100404following the Generic Distribution feature (doc/README.distro for use).
405
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200406The size of fip or ssbl partition must be enough for the associated binary file,
4074MB and 2MB are default values.
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100408
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200409According the used card reader select the correct block device
410(for example /dev/sdx or /dev/mmcblk0), in the next example, it is /dev/mmcblk0
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100411
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200412For example:
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100413
414a) remove previous formatting::
415
416 # sgdisk -o /dev/<SD card dev>
417
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200418b) create minimal image for FIP
419
420 For FIP support in TF-A_::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100421
422 # sgdisk --resize-table=128 -a 1 \
423 -n 1:34:545 -c 1:fsbl1 \
424 -n 2:546:1057 -c 2:fsbl2 \
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200425 -n 3:1058:9249 -c 3:fip \
426 -n 4:9250: -c 4:rootfs -A 4:set:2 \
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100427 -p /dev/<SD card dev>
428
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200429 With gpt table with 128 entries an the partition 4 marked bootable (bit 2).
430
431 For basic boot mode or without FIP support in TF-A_::
432
433 # sgdisk --resize-table=128 -a 1 \
434 -n 1:34:545 -c 1:fsbl1 \
435 -n 2:546:1057 -c 2:fsbl2 \
436 -n 3:1058:5153 -c 3:ssbl \
437 -n 4:5154: -c 4:rootfs -A 4:set:2 \
438 -p /dev/<SD card dev>
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100439
440c) copy the FSBL (2 times) and SSBL file on the correct partition.
441 in this example in partition 1 to 3
442
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200443 for trusted boot: ::
444
445 # dd if=tf-a.stm32 of=/dev/mmcblk0p1
446 # dd if=tf-a.stm32 of=/dev/mmcblk0p2
447 # dd if=fip.bin of=/dev/mmcblk0p3
448 OR
449 dd if=u-boot.stm32 of=/dev/mmcblk0p3 # Without FIT support
450
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100451 for basic boot mode : <SD card dev> = /dev/mmcblk0::
452
453 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
454 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
Marek Vasutdb4374f2021-03-06 21:44:17 +0100455 # dd if=u-boot.img of=/dev/mmcblk0p3 # Without CONFIG_SPL_LOAD_FIT
456 OR
457 dd if=u-boot.itb of=/dev/mmcblk0p3 # With CONFIG_SPL_LOAD_FIT=y
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100458
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100459To boot from SD card, select BootPinMode = 1 0 1 and reset.
460
461Prepare eMMC
462------------
463
464You can use U-Boot to copy binary in eMMC.
465
466In the next example, you need to boot from SD card and the images
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200467(tf-a.stm32, fip.bin / u-boot-spl.stm32, u-boot.img for systems without
468CONFIG_SPL_LOAD_FIT or u-boot.itb for systems with CONFIG_SPL_LOAD_FIT=y) are
469presents on SD card (mmc 0) in ext4 partition 4 (bootfs)
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100470
471To boot from SD card, select BootPinMode = 1 0 1 and reset.
472
473Then you update the eMMC with the next U-Boot command :
474
475a) prepare GPT on eMMC,
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200476 example with 3 partitions, fip, bootfs and roots::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100477
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200478 # setenv emmc_part "name=fip,size=4MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100479 # gpt write mmc 1 ${emmc_part}
480
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200481b) copy FSBL, TF-A_ or SPL, on first eMMC boot partition
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100482 (SPL max size is 256kB, with LBA 512, 0x200)::
483
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200484 # ext4load mmc 0:4 0xC0000000 tf-a.stm32
485 or
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100486 # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200487
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100488 # mmc dev 1
489 # mmc partconf 1 1 1 1
490 # mmc write ${fileaddr} 0 200
491 # mmc partconf 1 1 1 0
492
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200493c) copy SSBL, FIP or U-Boot binary, in first GPT partition of eMMC::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100494
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200495 # ext4load mmc 0:4 0xC0000000 fip.bin
496 or
Marek Vasutdb4374f2021-03-06 21:44:17 +0100497 # ext4load mmc 0:4 0xC0000000 u-boot.img # Without CONFIG_SPL_LOAD_FIT
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200498 or
499 # ext4load mmc 0:4 0xC0000000 u-boot.itb # With CONFIG_SPL_LOAD_FIT=y
500
501
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100502 # mmc dev 1
503 # part start mmc 1 1 partstart
504 # mmc write ${fileaddr} ${partstart} ${filesize}
505
506To boot from eMMC, select BootPinMode = 0 1 0 and reset.
507
508MAC Address
509-----------
510
511Please read doc/README.enetaddr for the implementation guidelines for mac id
512usage. Basically, environment has precedence over board specific storage.
513
514For STMicroelectonics board, it is retrieved in STM32MP15x OTP :
515
516 - OTP_57[31:0] = MAC_ADDR[31:0]
517 - OTP_58[15:0] = MAC_ADDR[47:32]
518
519To program a MAC address on virgin OTP words above, you can use the fuse command
Patrick Delaunayb10cddf2020-02-12 19:37:38 +0100520on bank 0 to access to internal OTP and lock them:
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100521
522Prerequisite: check if a MAC address isn't yet programmed in OTP
523
Patrick Delaunayb10cddf2020-02-12 19:37:38 +01005241) check OTP: their value must be equal to 0::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100525
Patrick Delaunayb10cddf2020-02-12 19:37:38 +0100526 STM32MP> fuse sense 0 57 2
527 Sensing bank 0:
528 Word 0x00000039: 00000000 00000000
529
5302) check environment variable::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100531
Patrick Delaunayb10cddf2020-02-12 19:37:38 +0100532 STM32MP> env print ethaddr
533 ## Error: "ethaddr" not defined
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100534
Patrick Delaunayb10cddf2020-02-12 19:37:38 +01005353) check lock status of fuse 57 & 58 (at 0x39, 0=unlocked, 1=locked)::
536
537 STM32MP> fuse sense 0 0x10000039 2
538 Sensing bank 0:
539 Word 0x10000039: 00000000 00000000
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100540
541Example to set mac address "12:34:56:78:9a:bc"
542
5431) Write OTP::
544
545 STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a
546
5472) Read OTP::
548
549 STM32MP> fuse sense 0 57 2
550 Sensing bank 0:
551 Word 0x00000039: 78563412 0000bc9a
552
Patrick Delaunayb10cddf2020-02-12 19:37:38 +01005533) Lock OTP::
554
555 STM32MP> fuse prog 0 0x10000039 1 1
556
557 STM32MP> fuse sense 0 0x10000039 2
558 Sensing bank 0:
559 Word 0x10000039: 00000001 00000001
560
5614) next REBOOT, in the trace::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100562
563 ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"
564
Patrick Delaunayb10cddf2020-02-12 19:37:38 +01005655) check env update::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100566
567 STM32MP> env print ethaddr
568 ethaddr=12:34:56:78:9a:bc
569
570.. warning:: This command can't be executed twice on the same board as
571 OTP are protected. It is already done for the board
572 provided by STMicroelectronics.
573
574Coprocessor firmware
575--------------------
576
577U-Boot can boot the coprocessor before the kernel (coprocessor early boot).
578
579a) Manuallly by using rproc commands (update the bootcmd)
580
581 Configurations::
582
583 # env set name_copro "rproc-m4-fw.elf"
584 # env set dev_copro 0
585 # env set loadaddr_copro 0xC1000000
586
587 Load binary from bootfs partition (number 4) on SD card (mmc 0)::
588
589 # ext4load mmc 0:4 ${loadaddr_copro} ${name_copro}
590
591 => ${filesize} variable is updated with the size of the loaded file.
592
593 Start M4 firmware with remote proc command::
594
595 # rproc init
596 # rproc load ${dev_copro} ${loadaddr_copro} ${filesize}
597 # rproc start ${dev_copro}"00270033
598
599b) Automatically by using FIT feature and generic DISTRO bootcmd
600
601 see examples in the board stm32mp1 directory: fit_copro_kernel_dtb.its
602
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200603 Generate FIT including kernel + device tree + M4 firmware with cfg with M4
604 boot::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100605
606 $> mkimage -f fit_copro_kernel_dtb.its fit_copro_kernel_dtb.itb
607
608 Then using DISTRO configuration file: see extlinux.conf to select the correct
609 configuration:
610
611 - stm32mp157c-ev1-m4
612 - stm32mp157c-dk2-m4
613
614DFU support
615-----------
616
617The DFU is supported on ST board.
618
619The env variable dfu_alt_info is automatically build, and all
620the memory present on the ST boards are exported.
621
622The dfu mode is started by the command::
623
624 STM32MP> dfu 0
625
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200626On EV1 board, booting from SD card, without OP-TEE_::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100627
628 STM32MP> dfu 0 list
629 DFU alt settings list:
630 dev: RAM alt: 0 name: uImage layout: RAM_ADDR
631 dev: RAM alt: 1 name: devicetree.dtb layout: RAM_ADDR
632 dev: RAM alt: 2 name: uramdisk.image.gz layout: RAM_ADDR
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100633 dev: eMMC alt: 3 name: mmc0_fsbl1 layout: RAW_ADDR
634 dev: eMMC alt: 4 name: mmc0_fsbl2 layout: RAW_ADDR
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200635 dev: eMMC alt: 5 name: mmc0_fip layout: RAW_ADDR
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100636 dev: eMMC alt: 6 name: mmc0_bootfs layout: RAW_ADDR
637 dev: eMMC alt: 7 name: mmc0_vendorfs layout: RAW_ADDR
638 dev: eMMC alt: 8 name: mmc0_rootfs layout: RAW_ADDR
639 dev: eMMC alt: 9 name: mmc0_userfs layout: RAW_ADDR
640 dev: eMMC alt: 10 name: mmc1_boot1 layout: RAW_ADDR
641 dev: eMMC alt: 11 name: mmc1_boot2 layout: RAW_ADDR
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200642 dev: eMMC alt: 12 name: mmc1_fip layout: RAW_ADDR
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100643 dev: eMMC alt: 13 name: mmc1_bootfs layout: RAW_ADDR
644 dev: eMMC alt: 14 name: mmc1_vendorfs layout: RAW_ADDR
645 dev: eMMC alt: 15 name: mmc1_rootfs layout: RAW_ADDR
646 dev: eMMC alt: 16 name: mmc1_userfs layout: RAW_ADDR
647 dev: MTD alt: 17 name: nor0 layout: RAW_ADDR
648 dev: MTD alt: 18 name: nand0 layout: RAW_ADDR
649 dev: VIRT alt: 19 name: OTP layout: RAW_ADDR
650 dev: VIRT alt: 20 name: PMIC layout: RAW_ADDR
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100651
652All the supported device are exported for dfu-util tool::
653
654 $> dfu-util -l
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100655 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=20, name="PMIC", serial="002700333338511934383330"
656 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=19, name="OTP", serial="002700333338511934383330"
657 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=18, name="nand0", serial="002700333338511934383330"
658 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=17, name="nor0", serial="002700333338511934383330"
659 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=16, name="mmc1_userfs", serial="002700333338511934383330"
660 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=15, name="mmc1_rootfs", serial="002700333338511934383330"
661 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=14, name="mmc1_vendorfs", serial="002700333338511934383330"
662 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=13, name="mmc1_bootfs", serial="002700333338511934383330"
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200663 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=12, name="mmc1_fip", serial="002700333338511934383330"
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100664 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=11, name="mmc1_boot2", serial="002700333338511934383330"
665 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=10, name="mmc1_boot1", serial="002700333338511934383330"
666 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=9, name="mmc0_userfs", serial="002700333338511934383330"
667 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=8, name="mmc0_rootfs", serial="002700333338511934383330"
668 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=7, name="mmc0_vendorfs", serial="002700333338511934383330"
669 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=6, name="mmc0_bootfs", serial="002700333338511934383330"
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200670 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=5, name="mmc0_fip", serial="002700333338511934383330"
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100671 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=4, name="mmc0_fsbl2", serial="002700333338511934383330"
672 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=3, name="mmc0_fsbl1", serial="002700333338511934383330"
673 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=2, name="uramdisk.image.gz", serial="002700333338511934383330"
674 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=1, name="devicetree.dtb", serial="002700333338511934383330"
675 Found DFU: [0483:df11] ver=9999, devnum=99, cfg=1, intf=0, alt=0, name="uImage", serial="002700333338511934383330"
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100676
677You can update the boot device:
678
679- SD card (mmc0) ::
680
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200681 $> dfu-util -d 0483:5720 -a 3 -D tf-a-stm32mp157c-ev1.stm32
682 $> dfu-util -d 0483:5720 -a 4 -D tf-a-stm32mp157c-ev1.stm32
683 $> dfu-util -d 0483:5720 -a 5 -D fip-stm32mp157c-ev1.bin
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100684 $> dfu-util -d 0483:5720 -a 6 -D st-image-bootfs-openstlinux-weston-stm32mp1.ext4
685 $> dfu-util -d 0483:5720 -a 7 -D st-image-vendorfs-openstlinux-weston-stm32mp1.ext4
686 $> dfu-util -d 0483:5720 -a 8 -D st-image-weston-openstlinux-weston-stm32mp1.ext4
687 $> dfu-util -d 0483:5720 -a 9 -D st-image-userfs-openstlinux-weston-stm32mp1.ext4
688
689- EMMC (mmc1)::
690
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200691 $> dfu-util -d 0483:5720 -a 10 -D tf-a-stm32mp157c-ev1.stm32
692 $> dfu-util -d 0483:5720 -a 11 -D tf-a-stm32mp157c-ev1.stm32
693 $> dfu-util -d 0483:5720 -a 12 -D fip-stm32mp157c-ev1.bin
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100694 $> dfu-util -d 0483:5720 -a 13 -D st-image-bootfs-openstlinux-weston-stm32mp1.ext4
695 $> dfu-util -d 0483:5720 -a 14 -D st-image-vendorfs-openstlinux-weston-stm32mp1.ext4
696 $> dfu-util -d 0483:5720 -a 15 -D st-image-weston-openstlinux-weston-stm32mp1.ext4
697 $> dfu-util -d 0483:5720 -a 16 -D st-image-userfs-openstlinux-weston-stm32mp1.ext4
698
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100699- you can also dump the OTP and the PMIC NVM with::
700
701 $> dfu-util -d 0483:5720 -a 19 -U otp.bin
702 $> dfu-util -d 0483:5720 -a 20 -U pmic.bin
703
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100704
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100705When the board is booting for nor0 or nand0,
706only the MTD partition on the boot devices are available, for example:
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100707
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100708- NOR (nor0 = alt 20) & NAND (nand0 = alt 26) ::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100709
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200710 $> dfu-util -d 0483:5720 -a 21 -D tf-a-stm32mp157c-ev1.stm32
711 $> dfu-util -d 0483:5720 -a 22 -D tf-a-stm32mp157c-ev1.stm32
712 $> dfu-util -d 0483:5720 -a 23 -D fip-stm32mp157c-ev1.bin
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100713 $> dfu-util -d 0483:5720 -a 27 -D st-image-weston-openstlinux-weston-stm32mp1_nand_4_256_multivolume.ubi
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100714
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100715- NAND (nand0 = alt 21)::
Patrick Delaunay5f6fdcc2020-02-25 19:04:14 +0100716
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200717 $> dfu-util -d 0483:5720 -a 22 -D tf-a-stm32mp157c-ev1.stm32
718 $> dfu-util -d 0483:5720 -a 23 -D fip-stm32mp157c-ev1.bin
719 $> dfu-util -d 0483:5720 -a 24 -D fip-stm32mp157c-ev1.bin
Patrick Delaunayccf64ef2020-03-18 09:22:54 +0100720 $> dfu-util -d 0483:5720 -a 25 -D st-image-weston-openstlinux-weston-stm32mp1_nand_4_256_multivolume.ubi
Patrick Delaunay3e70d3c2021-07-26 11:21:37 +0200721
722References
723----------
724
725.. _WIKI:
726
727STM32 Arm® Cortex®-based MPUs user guide
728
729 + https://wiki.st.com/
730 + https://wiki.st.com/stm32mpu/wiki/Main_Page
731
732.. _TF-A:
733
734TF-A = The Trusted Firmware-A project provides a reference implementation of
735secure world software for Armv7-A and Armv8-A class processors
736
737 + https://www.trustedfirmware.org/projects/tf-a/
738 + https://trustedfirmware-a.readthedocs.io/en/latest/
739 + https://trustedfirmware-a.readthedocs.io/en/latest/plat/stm32mp1.html
740 + https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/
741
742.. _OP-TEE:
743
744OP-TEE = an open source Trusted Execution Environment (TEE) implementing the
745Arm TrustZone technology
746
747 + https://www.op-tee.org/
748 + https://optee.readthedocs.io/en/latest/
749 + https://optee.readthedocs.io/en/latest/building/devices/stm32mp1.html
750 + https://github.com/OP-TEE/optee_os