1 SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
3 # Copyright (C) 2018 STMicroelectronics - All Rights Reserved
6 U-Boot on STMicroelectronics STM32MP1
7 ======================================
11 This is a quick instruction for setup stm32mp1 boards.
15 U-Boot supports one STMP32MP1 SoCs: STM32MP157
17 The STM32MP157 is a Cortex-A MPU aimed at various applications.
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
25 Everything is supported in Linux but U-Boot is limited to:
27 2. SDCard/MMC controller (SDMMC)
29 And the necessary drivers
31 2. STPMIC1 (PMIC and regulator)
32 3. Clock, Reset, Sysreset
35 Currently the following boards are supported:
44 BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
46 with FSBL = First Stage Bootloader
47 SSBL = Second Stage Bootloader
49 2 boot configurations are supported:
51 1) 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
55 U-Boot is running in normal world and uses TF-A monitor
56 to access to secure resources
58 2) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
59 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)
64 All the STM32MP1 boards supported by U-Boot use the same generic board
65 stm32mp1 which support all the bootable devices.
67 Each board is configurated only with the associated device tree.
69 4. Device Tree Selection
70 ========================
72 You need to select the appropriate device tree for your board,
73 the supported device trees for stm32mp157 are:
75 + ev1: eval board with pmic stpmic1 (ev1 = mother board + daughter ed1)
78 + ed1: daughter board with pmic stpmic1
81 + dk1: Discovery board
84 + dk2: Discovery board = dk1 with a BT/WiFI combo and a DSI panel
90 1. Install required tools for U-Boot
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)
97 2. Set the cross compiler:
99 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
100 (you can use any gcc cross compiler compatible with U-Boot)
102 3. Select the output directory (optional)
104 # export KBUILD_OUTPUT=/path/to/output
106 for example: use one output directory for each configuration
107 # export KBUILD_OUTPUT=stm32mp15_trusted
108 # export KBUILD_OUTPUT=stm32mp15_basic
112 # make <defconfig_file>
114 - For trusted boot mode : "stm32mp15_trusted_defconfig"
115 - For basic boot mode: "stm32mp15_basic_defconfig"
117 5. Configure the device-tree and build the U-Boot image:
119 # make DEVICE_TREE=<name> all
123 a) trusted boot on ev1
124 # export KBUILD_OUTPUT=stm32mp15_trusted
125 # make stm32mp15_trusted_defconfig
126 # make DEVICE_TREE=stm32mp157c-ev1 all
129 # export KBUILD_OUTPUT=stm32mp15_basic
130 # make stm32mp15_basic_defconfig
131 # make DEVICE_TREE=stm32mp157c-ev1 all
134 # export KBUILD_OUTPUT=stm32mp15_basic
135 # make stm32mp15_basic_defconfig
136 # make DEVICE_TREE=stm32mp157c-ed1 all
139 # export KBUILD_OUTPUT=stm32mp15_basic
140 # make stm32mp15_basic_defconfig
141 # make DEVICE_TREE=stm32mp157c-dk2 all
145 BootRom and TF-A expect binaries with STM32 image header
146 SPL expects file with U-Boot uImage header
148 So in the output directory (selected by KBUILD_OUTPUT),
149 you can found the needed files:
152 + FSBL = tf-a.stm32 (provided by TF-A compilation)
153 + SSBL = u-boot.stm32
156 + FSBL = spl/u-boot-spl.stm32
159 6. Switch Setting for Boot Mode
160 ===============================
162 You can select the boot mode, on the board ed1 with the switch SW1
164 -----------------------------------
165 Boot Mode BOOT2 BOOT1 BOOT0
166 -----------------------------------
175 - on board DK1/DK2 with the switch SW1 : BOOT0, BOOT2
176 (BOOT1 forced to 0, NOR not supported)
178 --------------------------
179 Boot Mode BOOT2 BOOT0
180 --------------------------
185 Recovery is a boot from serial link (UART/USB) and it is used with
186 STM32CubeProgrammer tool to load executable in RAM and to update the flash
187 devices available on the board (NOR/NAND/eMMC/SDCARD).
188 The 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)
195 The 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
200 Then the minimal GPT partition is:
201 ----- ------- --------- --------------
202 | Num | Name | Size | Content |
203 ----- ------- -------- ---------------
204 | 1 | fsbl1 | 256 KiB | TF-A or SPL |
205 | 2 | fsbl2 | 256 KiB | TF-A or SPL |
206 | 3 | ssbl | enought | U-Boot |
207 | * | - | - | Boot/Rootfs |
208 ----- ------- --------- --------------
210 (*) add bootable partition for extlinux.conf
211 following Generic Distribution
212 (doc/README.distro for use)
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
218 for example: with gpt table with 128 entries
220 a) remove previous formatting
221 # sgdisk -o /dev/<SDCard dev>
223 b) create minimal image
224 # sgdisk --resize-table=128 -a 1 \
225 -n 1:34:545 -c 1:fsbl1 \
226 -n 2:546:1057 -c 2:fsbl2 \
227 -n 3:1058:5153 -c 3:ssbl \
230 you can add other partitions for kernel
231 one partition rootfs for example:
232 -n 4:5154: -c 4:rootfs \
234 c) copy the FSBL (2 times) and SSBL file on the correct partition.
235 in this example in partition 1 to 3
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
242 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
247 To boot from SDCard, select BootPinMode = 1 1 1 and reset.
251 You can use U-Boot to copy binary in eMMC.
253 In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
254 are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
256 To boot from SDCard, select BootPinMode = 1 0 1 and reset.
258 Then you update the eMMC with the next U-Boot command :
260 a) prepare GPT on eMMC,
261 example with 2 partitions, bootfs and roots:
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}
266 b) copy SPL on eMMC on firts boot partition
267 (SPL max size is 256kB, with LBA 512, 0x200)
269 # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
271 # mmc partconf 1 1 1 1
272 # mmc write ${fileaddr} 0 200
273 # mmc partconf 1 1 1 0
275 c) copy U-Boot in first GPT partition of eMMC
277 # ext4load mmc 0:4 0xC0000000 u-boot.img
279 # part start mmc 1 1 partstart
280 # part size mmc 1 1 partsize
281 # mmc write ${fileaddr} ${partstart} ${partsize}
283 To boot from eMMC, select BootPinMode = 0 1 0 and reset.
288 Please read doc/README.enetaddr for the implementation guidelines for mac id
289 usage. Basically, environment has precedence over board specific storage.
291 Mac 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]
295 To program a MAC address on virgin OTP words above, you can use the fuse command
296 on bank 0 to access to internal OTP:
298 example to set mac address "12:34:56:78:9a:bc"
301 STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a
304 STM32MP> fuse sense 0 57 2
306 Word 0x00000039: 78563412 0000bc9a
309 ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"
312 STM32MP> print ethaddr
313 ethaddr=12:34:56:78:9a:bc