blob: 1cd3534ae4e7289a6dfaf4f8b9a15fc052f7a6a7 [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)
28
29And the necessary drivers
301. I2C
Patrick Delaunayd79218f2019-02-04 11:26:17 +0100312. STPMIC1 (PMIC and regulator)
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200323. Clock, Reset, Sysreset
334. Fuse
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010034
35Currently the following boards are supported:
Patrick Delaunaye7f435d2018-07-09 15:17:22 +020036+ stm32mp157c-ev1
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010037+ stm32mp157c-ed1
Patrice Chotardfe5b5392019-02-12 16:50:39 +010038+ stm32mp157a-dk1
39+ stm32mp157c-dk2
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010040
413. Boot Sequences
42=================
43
44BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
45
46with FSBL = First Stage Bootloader
47 SSBL = Second Stage Bootloader
48
Patrick Delaunay5d061412019-02-12 11:44:39 +0100492 boot configurations are supported:
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010050
Patrick Delaunay5d061412019-02-12 11:44:39 +0100511) The "Trusted" boot chain (defconfig_file : stm32mp15_trusted_defconfig)
52 BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
53 TF-A performs a full initialization of Secure peripherals and installs a
54 secure monitor.
55 U-Boot is running in normal world and uses TF-A monitor
56 to access to secure resources
57
582) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010059 BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
60 SPL has limited security initialisation
61 U-Boot is running in secure mode and provide a secure monitor to the kernel
62 with only PSCI support (Power State Coordination Interface defined by ARM)
63
Patrick Delaunay5d061412019-02-12 11:44:39 +010064All the STM32MP1 boards supported by U-Boot use the same generic board
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010065stm32mp1 which support all the bootable devices.
66
67Each board is configurated only with the associated device tree.
68
694. Device Tree Selection
70========================
71
72You need to select the appropriate device tree for your board,
73the supported device trees for stm32mp157 are:
74
Patrick Delaunayd79218f2019-02-04 11:26:17 +010075+ ev1: eval board with pmic stpmic1 (ev1 = mother board + daughter ed1)
Patrick Delaunaye7f435d2018-07-09 15:17:22 +020076 dts: stm32mp157c-ev1
77
Patrick Delaunayd79218f2019-02-04 11:26:17 +010078+ ed1: daughter board with pmic stpmic1
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010079 dts: stm32mp157c-ed1
80
Patrice Chotardfe5b5392019-02-12 16:50:39 +010081+ dk1: Discovery board
82 dts: stm32mp157a-dk1
83
84+ dk2: Discovery board = dk1 with a BT/WiFI combo and a DSI panel
85 dts: stm32mp157c-dk2
86
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100875. Build Procedure
88==================
89
901. Install required tools for U-Boot
91
92 + install package needed in U-Boot makefile
93 (libssl-dev, swig, libpython-dev...)
94 + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
95 from SDK for STM32MP1, or any crosstoolchains from your distribution)
96
972. Set the cross compiler:
98
99 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
100 (you can use any gcc cross compiler compatible with U-Boot)
101
1023. Select the output directory (optional)
103
104 # export KBUILD_OUTPUT=/path/to/output
105
106 for example: use one output directory for each configuration
Patrick Delaunay5d061412019-02-12 11:44:39 +0100107 # export KBUILD_OUTPUT=stm32mp15_trusted
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100108 # export KBUILD_OUTPUT=stm32mp15_basic
109
Patrick Delaunay5d061412019-02-12 11:44:39 +01001104. Configure U-Boot:
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100111
112 # make <defconfig_file>
113
Patrick Delaunay5d061412019-02-12 11:44:39 +0100114 - For trusted boot mode : "stm32mp15_trusted_defconfig"
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100115 - For basic boot mode: "stm32mp15_basic_defconfig"
116
1175. Configure the device-tree and build the U-Boot image:
118
119 # make DEVICE_TREE=<name> all
120
121
122 example:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100123 a) trusted boot on ev1
124 # export KBUILD_OUTPUT=stm32mp15_trusted
125 # make stm32mp15_trusted_defconfig
126 # make DEVICE_TREE=stm32mp157c-ev1 all
127
128 b) basic boot on ev1
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200129 # export KBUILD_OUTPUT=stm32mp15_basic
130 # make stm32mp15_basic_defconfig
131 # make DEVICE_TREE=stm32mp157c-ev1 all
132
Patrick Delaunay5d061412019-02-12 11:44:39 +0100133 c) basic boot on ed1
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100134 # export KBUILD_OUTPUT=stm32mp15_basic
135 # make stm32mp15_basic_defconfig
136 # make DEVICE_TREE=stm32mp157c-ed1 all
137
Patrice Chotardfe5b5392019-02-12 16:50:39 +0100138 d) basic boot on dk2
139 # export KBUILD_OUTPUT=stm32mp15_basic
140 # make stm32mp15_basic_defconfig
141 # make DEVICE_TREE=stm32mp157c-dk2 all
142
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +01001436. Output files
144
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200145 BootRom and TF-A expect binaries with STM32 image header
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100146 SPL expects file with U-Boot uImage header
147
148 So in the output directory (selected by KBUILD_OUTPUT),
149 you can found the needed files:
150
Patrick Delaunay5d061412019-02-12 11:44:39 +0100151 a) For Trusted boot
152 + FSBL = tf-a.stm32 (provided by TF-A compilation)
153 + SSBL = u-boot.stm32
154
155 b) For Basic boot
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100156 + FSBL = spl/u-boot-spl.stm32
157 + SSBL = u-boot.img
158
Patrick Delaunay8d050102018-03-20 10:54:52 +01001596. Switch Setting for Boot Mode
160===============================
161
162You can select the boot mode, on the board ed1 with the switch SW1
163
164 -----------------------------------
165 Boot Mode BOOT2 BOOT1 BOOT0
166 -----------------------------------
167 Reserved 0 0 0
168 NOR 0 0 1
Patrick Delaunay8d050102018-03-20 10:54:52 +0100169 SD-Card 1 0 1
170 eMMC 0 1 0
171 NAND 0 1 1
172 Recovery 1 1 0
173 Recovery 0 0 0
174
Patrice Chotardfe5b5392019-02-12 16:50:39 +0100175- on board DK1/DK2 with the switch SW1 : BOOT0, BOOT2
176 (BOOT1 forced to 0, NOR not supported)
177
178 --------------------------
179 Boot Mode BOOT2 BOOT0
180 --------------------------
181 Reserved 1 0
182 SD-Card 1 1
183 Recovery 0 0
184
Patrick Delaunay8d050102018-03-20 10:54:52 +0100185Recovery is a boot from serial link (UART/USB) and it is used with
186STM32CubeProgrammer tool to load executable in RAM and to update the flash
187devices available on the board (NOR/NAND/eMMC/SDCARD).
188The communication between HOST and board is based on
189- for UARTs : the uart protocol used with all MCU STM32
190- for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
191
1927. Prepare an SDCard
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100193===================
194
195The minimal requirements for STMP32MP1 boot up to U-Boot are:
196- GPT partitioning (with gdisk or with sgdisk)
197- 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
198- one ssbl partition for U-Boot
199
200Then the minimal GPT partition is:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100201 ----- ------- --------- --------------
202 | Num | Name | Size | Content |
203 ----- ------- -------- ---------------
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200204 | 1 | fsbl1 | 256 KiB | TF-A or SPL |
205 | 2 | fsbl2 | 256 KiB | TF-A or SPL |
Patrick Delaunay5d061412019-02-12 11:44:39 +0100206 | 3 | ssbl | enought | U-Boot |
207 | * | - | - | Boot/Rootfs |
208 ----- ------- --------- --------------
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100209
210(*) add bootable partition for extlinux.conf
211 following Generic Distribution
212 (doc/README.distro for use)
213
214 according the used card reader select the block device
215 (/dev/sdx or /dev/mmcblk0)
216 in the next example I use /dev/mmcblk0
217
218for example: with gpt table with 128 entries
219
220 a) remove previous formatting
221 # sgdisk -o /dev/<SDCard dev>
222
223 b) create minimal image
Patrick Delaunay8d050102018-03-20 10:54:52 +0100224 # sgdisk --resize-table=128 -a 1 \
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100225 -n 1:34:545 -c 1:fsbl1 \
226 -n 2:546:1057 -c 2:fsbl2 \
227 -n 3:1058:5153 -c 3:ssbl \
228 -p /dev/<SDCard dev>
229
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200230 you can add other partitions for kernel
231 one partition rootfs for example:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100232 -n 4:5154: -c 4:rootfs \
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100233
234 c) copy the FSBL (2 times) and SSBL file on the correct partition.
235 in this example in partition 1 to 3
236
237 for basic boot mode : <SDCard dev> = /dev/mmcblk0
238 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
239 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
240 # dd if=u-boot.img of=/dev/mmcblk0p3
241
Patrick Delaunay5d061412019-02-12 11:44:39 +0100242 for trusted boot mode :
243 # dd if=tf-a.stm32 of=/dev/mmcblk0p1
244 # dd if=tf-a.stm32 of=/dev/mmcblk0p2
245 # dd if=u-boot.stm32 of=/dev/mmcblk0p3
246
Patrick Delaunay8d050102018-03-20 10:54:52 +0100247To boot from SDCard, select BootPinMode = 1 1 1 and reset.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100248
Patrick Delaunay8d050102018-03-20 10:54:52 +01002498. Prepare eMMC
250===============
251You can use U-Boot to copy binary in eMMC.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100252
Patrick Delaunay8d050102018-03-20 10:54:52 +0100253In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
254are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100255
Patrick Delaunay5d061412019-02-12 11:44:39 +0100256To boot from SDCard, select BootPinMode = 1 0 1 and reset.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100257
Patrick Delaunay8d050102018-03-20 10:54:52 +0100258Then you update the eMMC with the next U-Boot command :
259
260a) prepare GPT on eMMC,
261 example with 2 partitions, bootfs and roots:
262
263 # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
264 # gpt write mmc 1 ${emmc_part}
265
266b) copy SPL on eMMC on firts boot partition
267 (SPL max size is 256kB, with LBA 512, 0x200)
268
269 # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
270 # mmc dev 1
271 # mmc partconf 1 1 1 1
272 # mmc write ${fileaddr} 0 200
273 # mmc partconf 1 1 1 0
274
Patrick Delaunay5d061412019-02-12 11:44:39 +0100275c) copy U-Boot in first GPT partition of eMMC
Patrick Delaunay8d050102018-03-20 10:54:52 +0100276
277 # ext4load mmc 0:4 0xC0000000 u-boot.img
278 # mmc dev 1
279 # part start mmc 1 1 partstart
280 # part size mmc 1 1 partsize
281 # mmc write ${fileaddr} ${partstart} ${partsize}
282
283To boot from eMMC, select BootPinMode = 0 1 0 and reset.
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200284
2859. MAC Address
286==============
287
288Please read doc/README.enetaddr for the implementation guidelines for mac id
289usage. Basically, environment has precedence over board specific storage.
290
291Mac id storage and retrieval in stm32mp otp :
292- OTP_57[31:0] = MAC_ADDR[31:0]
293- OTP_58[15:0] = MAC_ADDR[47:32]
294
295To program a MAC address on virgin OTP words above, you can use the fuse command
296on bank 0 to access to internal OTP:
297
298 example to set mac address "12:34:56:78:9a:bc"
299
300 1- Write OTP
301 STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a
302
303 2- Read OTP
304 STM32MP> fuse sense 0 57 2
305 Sensing bank 0:
306 Word 0x00000039: 78563412 0000bc9a
307
308 3- next REBOOT :
309 ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"
310
311 4 check env update
312 STM32MP> print ethaddr
313 ethaddr=12:34:56:78:9a:bc