blob: b0c83250612d316de0b3be2a8b48afddab1398e5 [file] [log] [blame]
Tom Rini4549e782018-05-06 18:27:01 -04001SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
Patrick Delaunayf8598d92018-03-12 10:46:18 +01002#
3# Copyright (C) 2018 STMicroelectronics - All Rights Reserved
4#
Patrick Delaunayf8598d92018-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 Delaunay42f01aa2019-02-04 11:26:17 +0100312. STPMIC1 (PMIC and regulator)
Patrick Delaunay5f16f652018-07-09 15:17:22 +0200323. Clock, Reset, Sysreset
334. Fuse
Patrick Delaunayf8598d92018-03-12 10:46:18 +010034
35Currently the following boards are supported:
Patrick Delaunay5f16f652018-07-09 15:17:22 +020036+ stm32mp157c-ev1
Patrick Delaunayf8598d92018-03-12 10:46:18 +010037+ stm32mp157c-ed1
Patrice Chotard39110482019-02-12 16:50:39 +010038+ stm32mp157a-dk1
39+ stm32mp157c-dk2
Manivannan Sadhasivam93ffa2b2019-05-02 13:26:44 +053040+ stm32mp157a-avenger96
Patrick Delaunayf8598d92018-03-12 10:46:18 +010041
423. Boot Sequences
43=================
44
45BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
46
47with FSBL = First Stage Bootloader
48 SSBL = Second Stage Bootloader
49
Patrick Delaunayabf26782019-02-12 11:44:39 +0100502 boot configurations are supported:
Patrick Delaunayf8598d92018-03-12 10:46:18 +010051
Patrick Delaunayabf26782019-02-12 11:44:39 +0100521) The "Trusted" boot chain (defconfig_file : stm32mp15_trusted_defconfig)
53 BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
54 TF-A performs a full initialization of Secure peripherals and installs a
55 secure monitor.
56 U-Boot is running in normal world and uses TF-A monitor
57 to access to secure resources
58
592) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
Patrick Delaunayf8598d92018-03-12 10:46:18 +010060 BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
61 SPL has limited security initialisation
62 U-Boot is running in secure mode and provide a secure monitor to the kernel
63 with only PSCI support (Power State Coordination Interface defined by ARM)
64
Patrick Delaunayabf26782019-02-12 11:44:39 +010065All the STM32MP1 boards supported by U-Boot use the same generic board
Patrick Delaunayf8598d92018-03-12 10:46:18 +010066stm32mp1 which support all the bootable devices.
67
68Each board is configurated only with the associated device tree.
69
704. Device Tree Selection
71========================
72
73You need to select the appropriate device tree for your board,
74the supported device trees for stm32mp157 are:
75
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010076+ ev1: eval board with pmic stpmic1 (ev1 = mother board + daughter ed1)
Patrick Delaunay5f16f652018-07-09 15:17:22 +020077 dts: stm32mp157c-ev1
78
Patrick Delaunay42f01aa2019-02-04 11:26:17 +010079+ ed1: daughter board with pmic stpmic1
Patrick Delaunayf8598d92018-03-12 10:46:18 +010080 dts: stm32mp157c-ed1
81
Patrice Chotard39110482019-02-12 16:50:39 +010082+ dk1: Discovery board
83 dts: stm32mp157a-dk1
84
85+ dk2: Discovery board = dk1 with a BT/WiFI combo and a DSI panel
86 dts: stm32mp157c-dk2
87
Manivannan Sadhasivam93ffa2b2019-05-02 13:26:44 +053088+ avenger96: Avenger96 board from Arrow Electronics
89 dts: stm32mp157a-avenger96
90
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100915. Build Procedure
92==================
93
941. Install required tools for U-Boot
95
96 + install package needed in U-Boot makefile
97 (libssl-dev, swig, libpython-dev...)
98 + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
99 from SDK for STM32MP1, or any crosstoolchains from your distribution)
100
1012. Set the cross compiler:
102
103 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
104 (you can use any gcc cross compiler compatible with U-Boot)
105
1063. Select the output directory (optional)
107
108 # export KBUILD_OUTPUT=/path/to/output
109
110 for example: use one output directory for each configuration
Patrick Delaunayabf26782019-02-12 11:44:39 +0100111 # export KBUILD_OUTPUT=stm32mp15_trusted
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100112 # export KBUILD_OUTPUT=stm32mp15_basic
113
Patrick Delaunayabf26782019-02-12 11:44:39 +01001144. Configure U-Boot:
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100115
116 # make <defconfig_file>
117
Patrick Delaunayabf26782019-02-12 11:44:39 +0100118 - For trusted boot mode : "stm32mp15_trusted_defconfig"
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100119 - For basic boot mode: "stm32mp15_basic_defconfig"
120
1215. Configure the device-tree and build the U-Boot image:
122
123 # make DEVICE_TREE=<name> all
124
125
126 example:
Patrick Delaunayabf26782019-02-12 11:44:39 +0100127 a) trusted boot on ev1
128 # export KBUILD_OUTPUT=stm32mp15_trusted
129 # make stm32mp15_trusted_defconfig
130 # make DEVICE_TREE=stm32mp157c-ev1 all
131
132 b) basic boot on ev1
Patrick Delaunay5f16f652018-07-09 15:17:22 +0200133 # export KBUILD_OUTPUT=stm32mp15_basic
134 # make stm32mp15_basic_defconfig
135 # make DEVICE_TREE=stm32mp157c-ev1 all
136
Patrick Delaunayabf26782019-02-12 11:44:39 +0100137 c) basic boot on ed1
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100138 # export KBUILD_OUTPUT=stm32mp15_basic
139 # make stm32mp15_basic_defconfig
140 # make DEVICE_TREE=stm32mp157c-ed1 all
141
Patrice Chotard39110482019-02-12 16:50:39 +0100142 d) basic boot on dk2
143 # export KBUILD_OUTPUT=stm32mp15_basic
144 # make stm32mp15_basic_defconfig
145 # make DEVICE_TREE=stm32mp157c-dk2 all
146
Manivannan Sadhasivam93ffa2b2019-05-02 13:26:44 +0530147 d) basic boot on avenger96
148 # export KBUILD_OUTPUT=stm32mp15_basic
149 # make stm32mp15_basic_defconfig
150 # make DEVICE_TREE=stm32mp157a-avenger96 all
151
Patrick Delaunayf8598d92018-03-12 10:46:18 +01001526. Output files
153
Patrick Delaunay5f16f652018-07-09 15:17:22 +0200154 BootRom and TF-A expect binaries with STM32 image header
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100155 SPL expects file with U-Boot uImage header
156
157 So in the output directory (selected by KBUILD_OUTPUT),
158 you can found the needed files:
159
Patrick Delaunayabf26782019-02-12 11:44:39 +0100160 a) For Trusted boot
161 + FSBL = tf-a.stm32 (provided by TF-A compilation)
162 + SSBL = u-boot.stm32
163
164 b) For Basic boot
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100165 + FSBL = spl/u-boot-spl.stm32
166 + SSBL = u-boot.img
167
Patrick Delaunay0ed232b2018-03-20 10:54:52 +01001686. Switch Setting for Boot Mode
169===============================
170
171You can select the boot mode, on the board ed1 with the switch SW1
172
173 -----------------------------------
174 Boot Mode BOOT2 BOOT1 BOOT0
175 -----------------------------------
176 Reserved 0 0 0
177 NOR 0 0 1
Patrick Delaunay0ed232b2018-03-20 10:54:52 +0100178 SD-Card 1 0 1
179 eMMC 0 1 0
180 NAND 0 1 1
181 Recovery 1 1 0
182 Recovery 0 0 0
183
Patrice Chotard39110482019-02-12 16:50:39 +0100184- on board DK1/DK2 with the switch SW1 : BOOT0, BOOT2
185 (BOOT1 forced to 0, NOR not supported)
186
187 --------------------------
188 Boot Mode BOOT2 BOOT0
189 --------------------------
190 Reserved 1 0
191 SD-Card 1 1
192 Recovery 0 0
193
Manivannan Sadhasivam93ffa2b2019-05-02 13:26:44 +0530194- Boot mode of Avenger96 can be selected using switch S3
195
196 -----------------------------------
197 Boot Mode BOOT2 BOOT1 BOOT0
198 -----------------------------------
199 Recovery 0 0 0
200 NOR 0 0 1
201 SD-Card 1 0 1
202 eMMC 0 1 0
203 NAND 0 1 1
204 Reserved 1 0 0
205 Recovery 1 1 0
206 SD-Card 1 1 1
207
Patrick Delaunay0ed232b2018-03-20 10:54:52 +0100208Recovery is a boot from serial link (UART/USB) and it is used with
209STM32CubeProgrammer tool to load executable in RAM and to update the flash
210devices available on the board (NOR/NAND/eMMC/SDCARD).
211The communication between HOST and board is based on
212- for UARTs : the uart protocol used with all MCU STM32
213- for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
214
2157. Prepare an SDCard
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100216===================
217
218The minimal requirements for STMP32MP1 boot up to U-Boot are:
219- GPT partitioning (with gdisk or with sgdisk)
220- 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
221- one ssbl partition for U-Boot
222
223Then the minimal GPT partition is:
Patrick Delaunayabf26782019-02-12 11:44:39 +0100224 ----- ------- --------- --------------
225 | Num | Name | Size | Content |
226 ----- ------- -------- ---------------
Patrick Delaunay5f16f652018-07-09 15:17:22 +0200227 | 1 | fsbl1 | 256 KiB | TF-A or SPL |
228 | 2 | fsbl2 | 256 KiB | TF-A or SPL |
Patrick Delaunayabf26782019-02-12 11:44:39 +0100229 | 3 | ssbl | enought | U-Boot |
230 | * | - | - | Boot/Rootfs |
231 ----- ------- --------- --------------
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100232
233(*) add bootable partition for extlinux.conf
234 following Generic Distribution
235 (doc/README.distro for use)
236
237 according the used card reader select the block device
238 (/dev/sdx or /dev/mmcblk0)
239 in the next example I use /dev/mmcblk0
240
241for example: with gpt table with 128 entries
242
243 a) remove previous formatting
244 # sgdisk -o /dev/<SDCard dev>
245
246 b) create minimal image
Patrick Delaunay0ed232b2018-03-20 10:54:52 +0100247 # sgdisk --resize-table=128 -a 1 \
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100248 -n 1:34:545 -c 1:fsbl1 \
249 -n 2:546:1057 -c 2:fsbl2 \
250 -n 3:1058:5153 -c 3:ssbl \
251 -p /dev/<SDCard dev>
252
Patrick Delaunay5f16f652018-07-09 15:17:22 +0200253 you can add other partitions for kernel
254 one partition rootfs for example:
Patrick Delaunayabf26782019-02-12 11:44:39 +0100255 -n 4:5154: -c 4:rootfs \
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100256
257 c) copy the FSBL (2 times) and SSBL file on the correct partition.
258 in this example in partition 1 to 3
259
260 for basic boot mode : <SDCard dev> = /dev/mmcblk0
261 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
262 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
263 # dd if=u-boot.img of=/dev/mmcblk0p3
264
Patrick Delaunayabf26782019-02-12 11:44:39 +0100265 for trusted boot mode :
266 # dd if=tf-a.stm32 of=/dev/mmcblk0p1
267 # dd if=tf-a.stm32 of=/dev/mmcblk0p2
268 # dd if=u-boot.stm32 of=/dev/mmcblk0p3
269
Patrick Delaunay0ed232b2018-03-20 10:54:52 +0100270To boot from SDCard, select BootPinMode = 1 1 1 and reset.
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100271
Patrick Delaunay0ed232b2018-03-20 10:54:52 +01002728. Prepare eMMC
273===============
274You can use U-Boot to copy binary in eMMC.
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100275
Patrick Delaunay0ed232b2018-03-20 10:54:52 +0100276In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
277are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100278
Patrick Delaunayabf26782019-02-12 11:44:39 +0100279To boot from SDCard, select BootPinMode = 1 0 1 and reset.
Patrick Delaunayf8598d92018-03-12 10:46:18 +0100280
Patrick Delaunay0ed232b2018-03-20 10:54:52 +0100281Then you update the eMMC with the next U-Boot command :
282
283a) prepare GPT on eMMC,
284 example with 2 partitions, bootfs and roots:
285
286 # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
287 # gpt write mmc 1 ${emmc_part}
288
289b) copy SPL on eMMC on firts boot partition
290 (SPL max size is 256kB, with LBA 512, 0x200)
291
292 # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
293 # mmc dev 1
294 # mmc partconf 1 1 1 1
295 # mmc write ${fileaddr} 0 200
296 # mmc partconf 1 1 1 0
297
Patrick Delaunayabf26782019-02-12 11:44:39 +0100298c) copy U-Boot in first GPT partition of eMMC
Patrick Delaunay0ed232b2018-03-20 10:54:52 +0100299
300 # ext4load mmc 0:4 0xC0000000 u-boot.img
301 # mmc dev 1
302 # part start mmc 1 1 partstart
303 # part size mmc 1 1 partsize
304 # mmc write ${fileaddr} ${partstart} ${partsize}
305
306To boot from eMMC, select BootPinMode = 0 1 0 and reset.
Patrick Delaunay5f16f652018-07-09 15:17:22 +0200307
3089. MAC Address
309==============
310
311Please read doc/README.enetaddr for the implementation guidelines for mac id
312usage. Basically, environment has precedence over board specific storage.
313
314Mac id storage and retrieval in stm32mp otp :
315- OTP_57[31:0] = MAC_ADDR[31:0]
316- OTP_58[15:0] = MAC_ADDR[47:32]
317
318To program a MAC address on virgin OTP words above, you can use the fuse command
319on bank 0 to access to internal OTP:
320
321 example to set mac address "12:34:56:78:9a:bc"
322
323 1- Write OTP
324 STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a
325
326 2- Read OTP
327 STM32MP> fuse sense 0 57 2
328 Sensing bank 0:
329 Word 0x00000039: 78563412 0000bc9a
330
331 3- next REBOOT :
332 ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"
333
334 4 check env update
335 STM32MP> print ethaddr
336 ethaddr=12:34:56:78:9a:bc