blob: dc36a21bda3d871a35471ab3ca70e41bf7de46ca [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 Delaunay5d061412019-02-12 11:44:39 +0100542 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
632) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010064 BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
65 SPL has limited security initialisation
66 U-Boot is running in secure mode and provide a secure monitor to the kernel
Patrick Delaunay72e80f52019-07-05 17:20:18 +020067 with only PSCI support (Power State Coordination Interface defined by ARM).
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010068
Patrick Delaunay5d061412019-02-12 11:44:39 +010069All the STM32MP1 boards supported by U-Boot use the same generic board
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010070stm32mp1 which support all the bootable devices.
71
72Each board is configurated only with the associated device tree.
73
744. Device Tree Selection
75========================
76
77You need to select the appropriate device tree for your board,
78the supported device trees for stm32mp157 are:
79
Patrick Delaunayd79218f2019-02-04 11:26:17 +010080+ ev1: eval board with pmic stpmic1 (ev1 = mother board + daughter ed1)
Patrick Delaunaye7f435d2018-07-09 15:17:22 +020081 dts: stm32mp157c-ev1
82
Patrick Delaunayd79218f2019-02-04 11:26:17 +010083+ ed1: daughter board with pmic stpmic1
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010084 dts: stm32mp157c-ed1
85
Patrice Chotardfe5b5392019-02-12 16:50:39 +010086+ dk1: Discovery board
87 dts: stm32mp157a-dk1
88
89+ dk2: Discovery board = dk1 with a BT/WiFI combo and a DSI panel
90 dts: stm32mp157c-dk2
91
Manivannan Sadhasivamd1564072019-05-02 13:26:44 +053092+ avenger96: Avenger96 board from Arrow Electronics
93 dts: stm32mp157a-avenger96
94
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100955. Build Procedure
96==================
97
981. Install required tools for U-Boot
99
100 + install package needed in U-Boot makefile
101 (libssl-dev, swig, libpython-dev...)
102 + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
103 from SDK for STM32MP1, or any crosstoolchains from your distribution)
104
1052. Set the cross compiler:
106
107 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
108 (you can use any gcc cross compiler compatible with U-Boot)
109
1103. Select the output directory (optional)
111
112 # export KBUILD_OUTPUT=/path/to/output
113
114 for example: use one output directory for each configuration
Patrick Delaunay5d061412019-02-12 11:44:39 +0100115 # export KBUILD_OUTPUT=stm32mp15_trusted
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100116 # export KBUILD_OUTPUT=stm32mp15_basic
117
Patrick Delaunay72e80f52019-07-05 17:20:18 +0200118 you can build outside of code directory:
119 # export KBUILD_OUTPUT=../build/stm32mp15_trusted
120
Patrick Delaunay5d061412019-02-12 11:44:39 +01001214. Configure U-Boot:
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100122
123 # make <defconfig_file>
124
Patrick Delaunay5d061412019-02-12 11:44:39 +0100125 - For trusted boot mode : "stm32mp15_trusted_defconfig"
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100126 - For basic boot mode: "stm32mp15_basic_defconfig"
127
1285. Configure the device-tree and build the U-Boot image:
129
130 # make DEVICE_TREE=<name> all
131
132
133 example:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100134 a) trusted boot on ev1
135 # export KBUILD_OUTPUT=stm32mp15_trusted
136 # make stm32mp15_trusted_defconfig
137 # make DEVICE_TREE=stm32mp157c-ev1 all
138
139 b) basic boot on ev1
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200140 # export KBUILD_OUTPUT=stm32mp15_basic
141 # make stm32mp15_basic_defconfig
142 # make DEVICE_TREE=stm32mp157c-ev1 all
143
Patrick Delaunay5d061412019-02-12 11:44:39 +0100144 c) basic boot on ed1
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100145 # export KBUILD_OUTPUT=stm32mp15_basic
146 # make stm32mp15_basic_defconfig
147 # make DEVICE_TREE=stm32mp157c-ed1 all
148
Patrice Chotardfe5b5392019-02-12 16:50:39 +0100149 d) basic boot on dk2
150 # export KBUILD_OUTPUT=stm32mp15_basic
151 # make stm32mp15_basic_defconfig
152 # make DEVICE_TREE=stm32mp157c-dk2 all
153
Manivannan Sadhasivamd1564072019-05-02 13:26:44 +0530154 d) basic boot on avenger96
155 # export KBUILD_OUTPUT=stm32mp15_basic
156 # make stm32mp15_basic_defconfig
157 # make DEVICE_TREE=stm32mp157a-avenger96 all
158
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +01001596. Output files
160
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200161 BootRom and TF-A expect binaries with STM32 image header
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100162 SPL expects file with U-Boot uImage header
163
164 So in the output directory (selected by KBUILD_OUTPUT),
165 you can found the needed files:
166
Patrick Delaunay5d061412019-02-12 11:44:39 +0100167 a) For Trusted boot
168 + FSBL = tf-a.stm32 (provided by TF-A compilation)
169 + SSBL = u-boot.stm32
170
171 b) For Basic boot
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100172 + FSBL = spl/u-boot-spl.stm32
173 + SSBL = u-boot.img
174
Patrick Delaunay8d050102018-03-20 10:54:52 +01001756. Switch Setting for Boot Mode
176===============================
177
178You can select the boot mode, on the board ed1 with the switch SW1
179
Patrick Delaunay72e80f52019-07-05 17:20:18 +0200180- on the daugther board ed1 with the switch SW1 : BOOT0, BOOT1, BOOT2
181
Patrick Delaunay8d050102018-03-20 10:54:52 +0100182 -----------------------------------
183 Boot Mode BOOT2 BOOT1 BOOT0
184 -----------------------------------
185 Reserved 0 0 0
186 NOR 0 0 1
Patrick Delaunay8d050102018-03-20 10:54:52 +0100187 SD-Card 1 0 1
188 eMMC 0 1 0
189 NAND 0 1 1
190 Recovery 1 1 0
191 Recovery 0 0 0
192
Patrice Chotardfe5b5392019-02-12 16:50:39 +0100193- on board DK1/DK2 with the switch SW1 : BOOT0, BOOT2
194 (BOOT1 forced to 0, NOR not supported)
195
196 --------------------------
197 Boot Mode BOOT2 BOOT0
198 --------------------------
199 Reserved 1 0
200 SD-Card 1 1
201 Recovery 0 0
202
Manivannan Sadhasivamd1564072019-05-02 13:26:44 +0530203- Boot mode of Avenger96 can be selected using switch S3
204
205 -----------------------------------
206 Boot Mode BOOT2 BOOT1 BOOT0
207 -----------------------------------
208 Recovery 0 0 0
209 NOR 0 0 1
210 SD-Card 1 0 1
211 eMMC 0 1 0
212 NAND 0 1 1
213 Reserved 1 0 0
214 Recovery 1 1 0
215 SD-Card 1 1 1
216
Patrick Delaunay8d050102018-03-20 10:54:52 +0100217Recovery is a boot from serial link (UART/USB) and it is used with
218STM32CubeProgrammer tool to load executable in RAM and to update the flash
219devices available on the board (NOR/NAND/eMMC/SDCARD).
220The communication between HOST and board is based on
221- for UARTs : the uart protocol used with all MCU STM32
222- for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
223
2247. Prepare an SDCard
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100225===================
226
227The minimal requirements for STMP32MP1 boot up to U-Boot are:
228- GPT partitioning (with gdisk or with sgdisk)
229- 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
230- one ssbl partition for U-Boot
231
232Then the minimal GPT partition is:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100233 ----- ------- --------- --------------
234 | Num | Name | Size | Content |
235 ----- ------- -------- ---------------
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200236 | 1 | fsbl1 | 256 KiB | TF-A or SPL |
237 | 2 | fsbl2 | 256 KiB | TF-A or SPL |
Patrick Delaunay5d061412019-02-12 11:44:39 +0100238 | 3 | ssbl | enought | U-Boot |
239 | * | - | - | Boot/Rootfs |
240 ----- ------- --------- --------------
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100241
242(*) add bootable partition for extlinux.conf
243 following Generic Distribution
244 (doc/README.distro for use)
245
246 according the used card reader select the block device
247 (/dev/sdx or /dev/mmcblk0)
248 in the next example I use /dev/mmcblk0
249
250for example: with gpt table with 128 entries
251
252 a) remove previous formatting
253 # sgdisk -o /dev/<SDCard dev>
254
255 b) create minimal image
Patrick Delaunay8d050102018-03-20 10:54:52 +0100256 # sgdisk --resize-table=128 -a 1 \
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100257 -n 1:34:545 -c 1:fsbl1 \
258 -n 2:546:1057 -c 2:fsbl2 \
259 -n 3:1058:5153 -c 3:ssbl \
260 -p /dev/<SDCard dev>
261
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200262 you can add other partitions for kernel
263 one partition rootfs for example:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100264 -n 4:5154: -c 4:rootfs \
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100265
266 c) copy the FSBL (2 times) and SSBL file on the correct partition.
267 in this example in partition 1 to 3
268
269 for basic boot mode : <SDCard dev> = /dev/mmcblk0
270 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
271 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
272 # dd if=u-boot.img of=/dev/mmcblk0p3
273
Patrick Delaunay5d061412019-02-12 11:44:39 +0100274 for trusted boot mode :
275 # dd if=tf-a.stm32 of=/dev/mmcblk0p1
276 # dd if=tf-a.stm32 of=/dev/mmcblk0p2
277 # dd if=u-boot.stm32 of=/dev/mmcblk0p3
278
Patrick Delaunay72e80f52019-07-05 17:20:18 +0200279To boot from SDCard, select BootPinMode = 1 0 1 and reset.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100280
Patrick Delaunay8d050102018-03-20 10:54:52 +01002818. Prepare eMMC
282===============
283You can use U-Boot to copy binary in eMMC.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100284
Patrick Delaunay8d050102018-03-20 10:54:52 +0100285In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
286are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100287
Patrick Delaunay5d061412019-02-12 11:44:39 +0100288To boot from SDCard, select BootPinMode = 1 0 1 and reset.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100289
Patrick Delaunay8d050102018-03-20 10:54:52 +0100290Then you update the eMMC with the next U-Boot command :
291
292a) prepare GPT on eMMC,
293 example with 2 partitions, bootfs and roots:
294
295 # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
296 # gpt write mmc 1 ${emmc_part}
297
298b) copy SPL on eMMC on firts boot partition
299 (SPL max size is 256kB, with LBA 512, 0x200)
300
301 # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
302 # mmc dev 1
303 # mmc partconf 1 1 1 1
304 # mmc write ${fileaddr} 0 200
305 # mmc partconf 1 1 1 0
306
Patrick Delaunay5d061412019-02-12 11:44:39 +0100307c) copy U-Boot in first GPT partition of eMMC
Patrick Delaunay8d050102018-03-20 10:54:52 +0100308
309 # ext4load mmc 0:4 0xC0000000 u-boot.img
310 # mmc dev 1
311 # part start mmc 1 1 partstart
312 # part size mmc 1 1 partsize
313 # mmc write ${fileaddr} ${partstart} ${partsize}
314
315To boot from eMMC, select BootPinMode = 0 1 0 and reset.
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200316
3179. MAC Address
318==============
319
320Please read doc/README.enetaddr for the implementation guidelines for mac id
321usage. Basically, environment has precedence over board specific storage.
322
323Mac id storage and retrieval in stm32mp otp :
324- OTP_57[31:0] = MAC_ADDR[31:0]
325- OTP_58[15:0] = MAC_ADDR[47:32]
326
327To program a MAC address on virgin OTP words above, you can use the fuse command
328on bank 0 to access to internal OTP:
329
330 example to set mac address "12:34:56:78:9a:bc"
331
332 1- Write OTP
333 STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a
334
335 2- Read OTP
336 STM32MP> fuse sense 0 57 2
337 Sensing bank 0:
338 Word 0x00000039: 78563412 0000bc9a
339
340 3- next REBOOT :
341 ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"
342
343 4 check env update
344 STM32MP> print ethaddr
345 ethaddr=12:34:56:78:9a:bc