blob: 1c3e865e20d4954e29837eb0608e6701ac627215 [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 Delaunaye7f435d2018-07-09 15:17:22 +0200312. STPMU1 (PMIC and regulator)
323. 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
38
393. Boot Sequences
40=================
41
42BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
43
44with FSBL = First Stage Bootloader
45 SSBL = Second Stage Bootloader
46
Patrick Delaunay5d061412019-02-12 11:44:39 +0100472 boot configurations are supported:
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010048
Patrick Delaunay5d061412019-02-12 11:44:39 +0100491) The "Trusted" boot chain (defconfig_file : stm32mp15_trusted_defconfig)
50 BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
51 TF-A performs a full initialization of Secure peripherals and installs a
52 secure monitor.
53 U-Boot is running in normal world and uses TF-A monitor
54 to access to secure resources
55
562) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010057 BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
58 SPL has limited security initialisation
59 U-Boot is running in secure mode and provide a secure monitor to the kernel
60 with only PSCI support (Power State Coordination Interface defined by ARM)
61
Patrick Delaunay5d061412019-02-12 11:44:39 +010062All the STM32MP1 boards supported by U-Boot use the same generic board
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010063stm32mp1 which support all the bootable devices.
64
65Each board is configurated only with the associated device tree.
66
674. Device Tree Selection
68========================
69
70You need to select the appropriate device tree for your board,
71the supported device trees for stm32mp157 are:
72
Patrick Delaunaye7f435d2018-07-09 15:17:22 +020073+ ev1: eval board with pmic stpmu1 (ev1 = mother board + daughter ed1)
74 dts: stm32mp157c-ev1
75
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +010076+ ed1: daughter board with pmic stpmu1
77 dts: stm32mp157c-ed1
78
795. Build Procedure
80==================
81
821. Install required tools for U-Boot
83
84 + install package needed in U-Boot makefile
85 (libssl-dev, swig, libpython-dev...)
86 + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
87 from SDK for STM32MP1, or any crosstoolchains from your distribution)
88
892. Set the cross compiler:
90
91 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
92 (you can use any gcc cross compiler compatible with U-Boot)
93
943. Select the output directory (optional)
95
96 # export KBUILD_OUTPUT=/path/to/output
97
98 for example: use one output directory for each configuration
Patrick Delaunay5d061412019-02-12 11:44:39 +010099 # export KBUILD_OUTPUT=stm32mp15_trusted
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100100 # export KBUILD_OUTPUT=stm32mp15_basic
101
Patrick Delaunay5d061412019-02-12 11:44:39 +01001024. Configure U-Boot:
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100103
104 # make <defconfig_file>
105
Patrick Delaunay5d061412019-02-12 11:44:39 +0100106 - For trusted boot mode : "stm32mp15_trusted_defconfig"
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100107 - For basic boot mode: "stm32mp15_basic_defconfig"
108
1095. Configure the device-tree and build the U-Boot image:
110
111 # make DEVICE_TREE=<name> all
112
113
114 example:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100115 a) trusted boot on ev1
116 # export KBUILD_OUTPUT=stm32mp15_trusted
117 # make stm32mp15_trusted_defconfig
118 # make DEVICE_TREE=stm32mp157c-ev1 all
119
120 b) basic boot on ev1
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200121 # export KBUILD_OUTPUT=stm32mp15_basic
122 # make stm32mp15_basic_defconfig
123 # make DEVICE_TREE=stm32mp157c-ev1 all
124
Patrick Delaunay5d061412019-02-12 11:44:39 +0100125 c) basic boot on ed1
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100126 # export KBUILD_OUTPUT=stm32mp15_basic
127 # make stm32mp15_basic_defconfig
128 # make DEVICE_TREE=stm32mp157c-ed1 all
129
1306. Output files
131
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200132 BootRom and TF-A expect binaries with STM32 image header
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100133 SPL expects file with U-Boot uImage header
134
135 So in the output directory (selected by KBUILD_OUTPUT),
136 you can found the needed files:
137
Patrick Delaunay5d061412019-02-12 11:44:39 +0100138 a) For Trusted boot
139 + FSBL = tf-a.stm32 (provided by TF-A compilation)
140 + SSBL = u-boot.stm32
141
142 b) For Basic boot
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100143 + FSBL = spl/u-boot-spl.stm32
144 + SSBL = u-boot.img
145
Patrick Delaunay8d050102018-03-20 10:54:52 +01001466. Switch Setting for Boot Mode
147===============================
148
149You can select the boot mode, on the board ed1 with the switch SW1
150
151 -----------------------------------
152 Boot Mode BOOT2 BOOT1 BOOT0
153 -----------------------------------
154 Reserved 0 0 0
155 NOR 0 0 1
Patrick Delaunay8d050102018-03-20 10:54:52 +0100156 SD-Card 1 0 1
157 eMMC 0 1 0
158 NAND 0 1 1
159 Recovery 1 1 0
160 Recovery 0 0 0
161
162Recovery is a boot from serial link (UART/USB) and it is used with
163STM32CubeProgrammer tool to load executable in RAM and to update the flash
164devices available on the board (NOR/NAND/eMMC/SDCARD).
165The communication between HOST and board is based on
166- for UARTs : the uart protocol used with all MCU STM32
167- for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
168
1697. Prepare an SDCard
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100170===================
171
172The minimal requirements for STMP32MP1 boot up to U-Boot are:
173- GPT partitioning (with gdisk or with sgdisk)
174- 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
175- one ssbl partition for U-Boot
176
177Then the minimal GPT partition is:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100178 ----- ------- --------- --------------
179 | Num | Name | Size | Content |
180 ----- ------- -------- ---------------
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200181 | 1 | fsbl1 | 256 KiB | TF-A or SPL |
182 | 2 | fsbl2 | 256 KiB | TF-A or SPL |
Patrick Delaunay5d061412019-02-12 11:44:39 +0100183 | 3 | ssbl | enought | U-Boot |
184 | * | - | - | Boot/Rootfs |
185 ----- ------- --------- --------------
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100186
187(*) add bootable partition for extlinux.conf
188 following Generic Distribution
189 (doc/README.distro for use)
190
191 according the used card reader select the block device
192 (/dev/sdx or /dev/mmcblk0)
193 in the next example I use /dev/mmcblk0
194
195for example: with gpt table with 128 entries
196
197 a) remove previous formatting
198 # sgdisk -o /dev/<SDCard dev>
199
200 b) create minimal image
Patrick Delaunay8d050102018-03-20 10:54:52 +0100201 # sgdisk --resize-table=128 -a 1 \
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100202 -n 1:34:545 -c 1:fsbl1 \
203 -n 2:546:1057 -c 2:fsbl2 \
204 -n 3:1058:5153 -c 3:ssbl \
205 -p /dev/<SDCard dev>
206
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200207 you can add other partitions for kernel
208 one partition rootfs for example:
Patrick Delaunay5d061412019-02-12 11:44:39 +0100209 -n 4:5154: -c 4:rootfs \
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100210
211 c) copy the FSBL (2 times) and SSBL file on the correct partition.
212 in this example in partition 1 to 3
213
214 for basic boot mode : <SDCard dev> = /dev/mmcblk0
215 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
216 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
217 # dd if=u-boot.img of=/dev/mmcblk0p3
218
Patrick Delaunay5d061412019-02-12 11:44:39 +0100219 for trusted boot mode :
220 # dd if=tf-a.stm32 of=/dev/mmcblk0p1
221 # dd if=tf-a.stm32 of=/dev/mmcblk0p2
222 # dd if=u-boot.stm32 of=/dev/mmcblk0p3
223
Patrick Delaunay8d050102018-03-20 10:54:52 +0100224To boot from SDCard, select BootPinMode = 1 1 1 and reset.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100225
Patrick Delaunay8d050102018-03-20 10:54:52 +01002268. Prepare eMMC
227===============
228You can use U-Boot to copy binary in eMMC.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100229
Patrick Delaunay8d050102018-03-20 10:54:52 +0100230In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
231are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100232
Patrick Delaunay5d061412019-02-12 11:44:39 +0100233To boot from SDCard, select BootPinMode = 1 0 1 and reset.
Patrick Delaunay8eb3b1e2018-03-12 10:46:18 +0100234
Patrick Delaunay8d050102018-03-20 10:54:52 +0100235Then you update the eMMC with the next U-Boot command :
236
237a) prepare GPT on eMMC,
238 example with 2 partitions, bootfs and roots:
239
240 # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
241 # gpt write mmc 1 ${emmc_part}
242
243b) copy SPL on eMMC on firts boot partition
244 (SPL max size is 256kB, with LBA 512, 0x200)
245
246 # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
247 # mmc dev 1
248 # mmc partconf 1 1 1 1
249 # mmc write ${fileaddr} 0 200
250 # mmc partconf 1 1 1 0
251
Patrick Delaunay5d061412019-02-12 11:44:39 +0100252c) copy U-Boot in first GPT partition of eMMC
Patrick Delaunay8d050102018-03-20 10:54:52 +0100253
254 # ext4load mmc 0:4 0xC0000000 u-boot.img
255 # mmc dev 1
256 # part start mmc 1 1 partstart
257 # part size mmc 1 1 partsize
258 # mmc write ${fileaddr} ${partstart} ${partsize}
259
260To boot from eMMC, select BootPinMode = 0 1 0 and reset.
Patrick Delaunaye7f435d2018-07-09 15:17:22 +0200261
2629. MAC Address
263==============
264
265Please read doc/README.enetaddr for the implementation guidelines for mac id
266usage. Basically, environment has precedence over board specific storage.
267
268Mac id storage and retrieval in stm32mp otp :
269- OTP_57[31:0] = MAC_ADDR[31:0]
270- OTP_58[15:0] = MAC_ADDR[47:32]
271
272To program a MAC address on virgin OTP words above, you can use the fuse command
273on bank 0 to access to internal OTP:
274
275 example to set mac address "12:34:56:78:9a:bc"
276
277 1- Write OTP
278 STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a
279
280 2- Read OTP
281 STM32MP> fuse sense 0 57 2
282 Sensing bank 0:
283 Word 0x00000039: 78563412 0000bc9a
284
285 3- next REBOOT :
286 ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"
287
288 4 check env update
289 STM32MP> print ethaddr
290 ethaddr=12:34:56:78:9a:bc