blob: 428357cfa09623c96f56a8de3c5fb270de5a489e [file] [log] [blame]
Tom Rini8b0c8a12018-05-06 18:27:01 -04001SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +01002#
3# Copyright (C) 2018 STMicroelectronics - All Rights Reserved
4#
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +01005
6U-Boot on STMicroelectronics STM32MP1
7======================================
8
91. Summary
10==========
11This is a quick instruction for setup stm32mp1 boards.
12
132. Supported devices
14====================
15U-Boot supports one STMP32MP1 SoCs: STM32MP157
16
17The STM32MP157 is a Cortex-A MPU aimed at various applications.
18It features:
19- Dual core Cortex-A7 application core
20- 2D/3D image composition with GPU
21- Standard memories interface support
22- Standard connectivity, widely inherited from the STM32 MCU family
23- Comprehensive security support
24
25Everything is supported in Linux but U-Boot is limited to:
261. UART
272. SDCard/MMC controller (SDMMC)
Patrick Delaunay72e80f52019-07-05 17:20:18 +0200283. NAND controller (FMC)
294. NOR controller (QSPI)
305. USB controller (OTG DWC2)
316. Ethernet controller
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010032
33And the necessary drivers
341. I2C
Patrick Delaunayd79218f2019-02-04 11:26:17 +0100352. STPMIC1 (PMIC and regulator)
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200363. Clock, Reset, Sysreset
374. Fuse
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010038
39Currently the following boards are supported:
Patrick Delaunaye7f435d2018-07-09 15:17:22 +020040+ stm32mp157c-ev1
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010041+ stm32mp157c-ed1
Patrice Chotardfe5b5392019-02-12 16:50:39 +010042+ stm32mp157a-dk1
43+ stm32mp157c-dk2
Manivannan Sadhasivamd1564072019-05-02 13:26:44 +053044+ stm32mp157a-avenger96
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010045
463. Boot Sequences
47=================
48
49BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
50
51with FSBL = First Stage Bootloader
52 SSBL = Second Stage Bootloader
53
Patrick Delaunayff215a42019-07-02 13:26:06 +0200543 boot configurations are supported:
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010055
Patrick Delaunay5d061412019-02-12 11:44:39 +0100561) The "Trusted" boot chain (defconfig_file : stm32mp15_trusted_defconfig)
57 BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
58 TF-A performs a full initialization of Secure peripherals and installs a
59 secure monitor.
60 U-Boot is running in normal world and uses TF-A monitor
Patrick Delaunay72e80f52019-07-05 17:20:18 +020061 to access to secure resources.
Patrick Delaunay5d061412019-02-12 11:44:39 +010062
Patrick Delaunayff215a42019-07-02 13:26:06 +0200632) The "Trusted" boot chain with OP-TEE
64 (defconfig_file : stm32mp15_optee_defconfig)
65 BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
66 TF-A performs a full initialization of Secure peripherals and installs OP-TEE
67 from specific partitions (teeh, teed, teex).
68 U-Boot is running in normal world and uses OP-TEE monitor to access
69 to secure resources.
70
713) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010072 BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
73 SPL has limited security initialisation
74 U-Boot is running in secure mode and provide a secure monitor to the kernel
Patrick Delaunay72e80f52019-07-05 17:20:18 +020075 with only PSCI support (Power State Coordination Interface defined by ARM).
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010076
Patrick Delaunay5d061412019-02-12 11:44:39 +010077All the STM32MP1 boards supported by U-Boot use the same generic board
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010078stm32mp1 which support all the bootable devices.
79
80Each board is configurated only with the associated device tree.
81
824. Device Tree Selection
83========================
84
85You need to select the appropriate device tree for your board,
86the supported device trees for stm32mp157 are:
87
Patrick Delaunayd79218f2019-02-04 11:26:17 +010088+ ev1: eval board with pmic stpmic1 (ev1 = mother board + daughter ed1)
Patrick Delaunaye7f435d2018-07-09 15:17:22 +020089 dts: stm32mp157c-ev1
90
Patrick Delaunayd79218f2019-02-04 11:26:17 +010091+ ed1: daughter board with pmic stpmic1
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010092 dts: stm32mp157c-ed1
93
Patrice Chotardfe5b5392019-02-12 16:50:39 +010094+ dk1: Discovery board
95 dts: stm32mp157a-dk1
96
97+ dk2: Discovery board = dk1 with a BT/WiFI combo and a DSI panel
98 dts: stm32mp157c-dk2
99
Manivannan Sadhasivamd1564072019-05-02 13:26:44 +0530100+ avenger96: Avenger96 board from Arrow Electronics
101 dts: stm32mp157a-avenger96
102
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +01001035. Build Procedure
104==================
105
1061. Install required tools for U-Boot
107
108 + install package needed in U-Boot makefile
109 (libssl-dev, swig, libpython-dev...)
110 + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
111 from SDK for STM32MP1, or any crosstoolchains from your distribution)
112
1132. Set the cross compiler:
114
115 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
116 (you can use any gcc cross compiler compatible with U-Boot)
117
1183. Select the output directory (optional)
119
120 # export KBUILD_OUTPUT=/path/to/output
121
122 for example: use one output directory for each configuration
Patrick Delaunay5d061412019-02-12 11:44:39 +0100123 # export KBUILD_OUTPUT=stm32mp15_trusted
Patrick Delaunayff215a42019-07-02 13:26:06 +0200124 # export KBUILD_OUTPUT=stm32mp15_optee
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100125 # export KBUILD_OUTPUT=stm32mp15_basic
126
Patrick Delaunay72e80f52019-07-05 17:20:18 +0200127 you can build outside of code directory:
128 # export KBUILD_OUTPUT=../build/stm32mp15_trusted
129
Patrick Delaunay5d061412019-02-12 11:44:39 +01001304. Configure U-Boot:
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100131
132 # make <defconfig_file>
133
Patrick Delaunay5d061412019-02-12 11:44:39 +0100134 - For trusted boot mode : "stm32mp15_trusted_defconfig"
Patrick Delaunayff215a42019-07-02 13:26:06 +0200135 - For trusted with OP-TEE boot mode : "stm32mp15_optee_defconfig"
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100136 - For basic boot mode: "stm32mp15_basic_defconfig"
137
1385. Configure the device-tree and build the U-Boot image:
139
140 # make DEVICE_TREE=<name> all
141
142
143 example:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100144 a) trusted boot on ev1
145 # export KBUILD_OUTPUT=stm32mp15_trusted
146 # make stm32mp15_trusted_defconfig
147 # make DEVICE_TREE=stm32mp157c-ev1 all
148
Patrick Delaunayff215a42019-07-02 13:26:06 +0200149 b) trusted with OP-TEE boot on dk2
150 # export KBUILD_OUTPUT=stm32mp15_optee
151 # make stm32mp15_optee_defconfig
152 # make DEVICE_TREE=stm32mp157c-dk2 all
153
154 c) basic boot on ev1
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200155 # export KBUILD_OUTPUT=stm32mp15_basic
156 # make stm32mp15_basic_defconfig
157 # make DEVICE_TREE=stm32mp157c-ev1 all
158
Patrick Delaunayff215a42019-07-02 13:26:06 +0200159 d) basic boot on ed1
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100160 # export KBUILD_OUTPUT=stm32mp15_basic
161 # make stm32mp15_basic_defconfig
162 # make DEVICE_TREE=stm32mp157c-ed1 all
163
Patrick Delaunayff215a42019-07-02 13:26:06 +0200164 e) basic boot on dk1
Patrice Chotardfe5b5392019-02-12 16:50:39 +0100165 # export KBUILD_OUTPUT=stm32mp15_basic
166 # make stm32mp15_basic_defconfig
Patrick Delaunayff215a42019-07-02 13:26:06 +0200167 # make DEVICE_TREE=stm32mp157a-dk1 all
Patrice Chotardfe5b5392019-02-12 16:50:39 +0100168
Patrick Delaunayff215a42019-07-02 13:26:06 +0200169 f) basic boot on avenger96
Manivannan Sadhasivamd1564072019-05-02 13:26:44 +0530170 # export KBUILD_OUTPUT=stm32mp15_basic
171 # make stm32mp15_basic_defconfig
172 # make DEVICE_TREE=stm32mp157a-avenger96 all
173
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +01001746. Output files
175
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200176 BootRom and TF-A expect binaries with STM32 image header
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100177 SPL expects file with U-Boot uImage header
178
179 So in the output directory (selected by KBUILD_OUTPUT),
180 you can found the needed files:
181
Patrick Delaunayff215a42019-07-02 13:26:06 +0200182 a) For Trusted boot (with or without OP-TEE)
Patrick Delaunay5d061412019-02-12 11:44:39 +0100183 + FSBL = tf-a.stm32 (provided by TF-A compilation)
184 + SSBL = u-boot.stm32
185
186 b) For Basic boot
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100187 + FSBL = spl/u-boot-spl.stm32
188 + SSBL = u-boot.img
189
Patrick Delaunay8d050102018-03-20 10:54:52 +01001906. Switch Setting for Boot Mode
191===============================
192
193You can select the boot mode, on the board ed1 with the switch SW1
194
Patrick Delaunay72e80f52019-07-05 17:20:18 +0200195- on the daugther board ed1 with the switch SW1 : BOOT0, BOOT1, BOOT2
196
Patrick Delaunay8d050102018-03-20 10:54:52 +0100197 -----------------------------------
198 Boot Mode BOOT2 BOOT1 BOOT0
199 -----------------------------------
200 Reserved 0 0 0
201 NOR 0 0 1
Patrick Delaunay8d050102018-03-20 10:54:52 +0100202 SD-Card 1 0 1
203 eMMC 0 1 0
204 NAND 0 1 1
205 Recovery 1 1 0
206 Recovery 0 0 0
207
Patrice Chotardfe5b5392019-02-12 16:50:39 +0100208- on board DK1/DK2 with the switch SW1 : BOOT0, BOOT2
209 (BOOT1 forced to 0, NOR not supported)
210
211 --------------------------
212 Boot Mode BOOT2 BOOT0
213 --------------------------
214 Reserved 1 0
215 SD-Card 1 1
216 Recovery 0 0
217
Manivannan Sadhasivamd1564072019-05-02 13:26:44 +0530218- Boot mode of Avenger96 can be selected using switch S3
219
220 -----------------------------------
221 Boot Mode BOOT2 BOOT1 BOOT0
222 -----------------------------------
223 Recovery 0 0 0
224 NOR 0 0 1
225 SD-Card 1 0 1
226 eMMC 0 1 0
227 NAND 0 1 1
228 Reserved 1 0 0
229 Recovery 1 1 0
230 SD-Card 1 1 1
231
Patrick Delaunay8d050102018-03-20 10:54:52 +0100232Recovery is a boot from serial link (UART/USB) and it is used with
233STM32CubeProgrammer tool to load executable in RAM and to update the flash
234devices available on the board (NOR/NAND/eMMC/SDCARD).
235The communication between HOST and board is based on
236- for UARTs : the uart protocol used with all MCU STM32
237- for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
238
2397. Prepare an SDCard
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100240===================
241
242The minimal requirements for STMP32MP1 boot up to U-Boot are:
243- GPT partitioning (with gdisk or with sgdisk)
244- 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
245- one ssbl partition for U-Boot
246
247Then the minimal GPT partition is:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100248 ----- ------- --------- --------------
249 | Num | Name | Size | Content |
250 ----- ------- -------- ---------------
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200251 | 1 | fsbl1 | 256 KiB | TF-A or SPL |
252 | 2 | fsbl2 | 256 KiB | TF-A or SPL |
Patrick Delaunay5d061412019-02-12 11:44:39 +0100253 | 3 | ssbl | enought | U-Boot |
254 | * | - | - | Boot/Rootfs |
255 ----- ------- --------- --------------
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100256
257(*) add bootable partition for extlinux.conf
258 following Generic Distribution
259 (doc/README.distro for use)
260
261 according the used card reader select the block device
262 (/dev/sdx or /dev/mmcblk0)
263 in the next example I use /dev/mmcblk0
264
265for example: with gpt table with 128 entries
266
267 a) remove previous formatting
268 # sgdisk -o /dev/<SDCard dev>
269
270 b) create minimal image
Patrick Delaunay8d050102018-03-20 10:54:52 +0100271 # sgdisk --resize-table=128 -a 1 \
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100272 -n 1:34:545 -c 1:fsbl1 \
273 -n 2:546:1057 -c 2:fsbl2 \
274 -n 3:1058:5153 -c 3:ssbl \
275 -p /dev/<SDCard dev>
276
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200277 you can add other partitions for kernel
278 one partition rootfs for example:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100279 -n 4:5154: -c 4:rootfs \
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100280
281 c) copy the FSBL (2 times) and SSBL file on the correct partition.
282 in this example in partition 1 to 3
283
284 for basic boot mode : <SDCard dev> = /dev/mmcblk0
285 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
286 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
287 # dd if=u-boot.img of=/dev/mmcblk0p3
288
Patrick Delaunay5d061412019-02-12 11:44:39 +0100289 for trusted boot mode :
290 # dd if=tf-a.stm32 of=/dev/mmcblk0p1
291 # dd if=tf-a.stm32 of=/dev/mmcblk0p2
292 # dd if=u-boot.stm32 of=/dev/mmcblk0p3
293
Patrick Delaunay72e80f52019-07-05 17:20:18 +0200294To boot from SDCard, select BootPinMode = 1 0 1 and reset.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100295
Patrick Delaunay8d050102018-03-20 10:54:52 +01002968. Prepare eMMC
297===============
298You can use U-Boot to copy binary in eMMC.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100299
Patrick Delaunay8d050102018-03-20 10:54:52 +0100300In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
301are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100302
Patrick Delaunay5d061412019-02-12 11:44:39 +0100303To boot from SDCard, select BootPinMode = 1 0 1 and reset.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100304
Patrick Delaunay8d050102018-03-20 10:54:52 +0100305Then you update the eMMC with the next U-Boot command :
306
307a) prepare GPT on eMMC,
308 example with 2 partitions, bootfs and roots:
309
310 # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
311 # gpt write mmc 1 ${emmc_part}
312
313b) copy SPL on eMMC on firts boot partition
314 (SPL max size is 256kB, with LBA 512, 0x200)
315
316 # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
317 # mmc dev 1
318 # mmc partconf 1 1 1 1
319 # mmc write ${fileaddr} 0 200
320 # mmc partconf 1 1 1 0
321
Patrick Delaunay5d061412019-02-12 11:44:39 +0100322c) copy U-Boot in first GPT partition of eMMC
Patrick Delaunay8d050102018-03-20 10:54:52 +0100323
324 # ext4load mmc 0:4 0xC0000000 u-boot.img
325 # mmc dev 1
326 # part start mmc 1 1 partstart
327 # part size mmc 1 1 partsize
328 # mmc write ${fileaddr} ${partstart} ${partsize}
329
330To boot from eMMC, select BootPinMode = 0 1 0 and reset.
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200331
3329. MAC Address
333==============
334
335Please read doc/README.enetaddr for the implementation guidelines for mac id
336usage. Basically, environment has precedence over board specific storage.
337
338Mac id storage and retrieval in stm32mp otp :
339- OTP_57[31:0] = MAC_ADDR[31:0]
340- OTP_58[15:0] = MAC_ADDR[47:32]
341
342To program a MAC address on virgin OTP words above, you can use the fuse command
343on bank 0 to access to internal OTP:
344
345 example to set mac address "12:34:56:78:9a:bc"
346
347 1- Write OTP
348 STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a
349
350 2- Read OTP
351 STM32MP> fuse sense 0 57 2
352 Sensing bank 0:
353 Word 0x00000039: 78563412 0000bc9a
354
355 3- next REBOOT :
356 ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"
357
358 4 check env update
359 STM32MP> print ethaddr
360 ethaddr=12:34:56:78:9a:bc