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
32 2. STPMU1 (PMIC and regulator)
33 3. Clock, Reset, Sysreset
36 Currently the following boards are supported:
43 BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
45 with FSBL = First Stage Bootloader
46 SSBL = Second Stage Bootloader
48 One boot configuration is supported:
50 The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
51 BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
52 SPL has limited security initialisation
53 U-Boot is running in secure mode and provide a secure monitor to the kernel
54 with only PSCI support (Power State Coordination Interface defined by ARM)
56 All the STM32MP1 board supported by U-Boot use the same generic board
57 stm32mp1 which support all the bootable devices.
59 Each board is configurated only with the associated device tree.
61 4. Device Tree Selection
62 ========================
64 You need to select the appropriate device tree for your board,
65 the supported device trees for stm32mp157 are:
67 + ev1: eval board with pmic stpmu1 (ev1 = mother board + daughter ed1)
70 + ed1: daughter board with pmic stpmu1
76 1. Install required tools for U-Boot
78 + install package needed in U-Boot makefile
79 (libssl-dev, swig, libpython-dev...)
80 + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
81 from SDK for STM32MP1, or any crosstoolchains from your distribution)
83 2. Set the cross compiler:
85 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
86 (you can use any gcc cross compiler compatible with U-Boot)
88 3. Select the output directory (optional)
90 # export KBUILD_OUTPUT=/path/to/output
92 for example: use one output directory for each configuration
93 # export KBUILD_OUTPUT=stm32mp15_basic
95 4. Configure the U-Boot:
97 # make <defconfig_file>
99 - For basic boot mode: "stm32mp15_basic_defconfig"
101 5. Configure the device-tree and build the U-Boot image:
103 # make DEVICE_TREE=<name> all
108 # export KBUILD_OUTPUT=stm32mp15_basic
109 # make stm32mp15_basic_defconfig
110 # make DEVICE_TREE=stm32mp157c-ev1 all
113 # export KBUILD_OUTPUT=stm32mp15_basic
114 # make stm32mp15_basic_defconfig
115 # make DEVICE_TREE=stm32mp157c-ed1 all
119 BootRom and TF-A expect binaries with STM32 image header
120 SPL expects file with U-Boot uImage header
122 So in the output directory (selected by KBUILD_OUTPUT),
123 you can found the needed files:
125 + FSBL = spl/u-boot-spl.stm32
128 6. Switch Setting for Boot Mode
129 ===============================
131 You can select the boot mode, on the board ed1 with the switch SW1
133 -----------------------------------
134 Boot Mode BOOT2 BOOT1 BOOT0
135 -----------------------------------
145 Recovery is a boot from serial link (UART/USB) and it is used with
146 STM32CubeProgrammer tool to load executable in RAM and to update the flash
147 devices available on the board (NOR/NAND/eMMC/SDCARD).
148 The communication between HOST and board is based on
149 - for UARTs : the uart protocol used with all MCU STM32
150 - for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
155 The minimal requirements for STMP32MP1 boot up to U-Boot are:
156 - GPT partitioning (with gdisk or with sgdisk)
157 - 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
158 - one ssbl partition for U-Boot
160 Then the minimal GPT partition is:
161 ----- ------- --------- -------------
162 | Num | Name | Size | Content |
163 ----- ------- -------- --------------
164 | 1 | fsbl1 | 256 KiB | TF-A or SPL |
165 | 2 | fsbl2 | 256 KiB | TF-A or SPL |
166 | 3 | ssbl | enought | U-Boot |
167 | * | - | - | Boot/Rootfs|
168 ----- ------- --------- -------------
170 (*) add bootable partition for extlinux.conf
171 following Generic Distribution
172 (doc/README.distro for use)
174 according the used card reader select the block device
175 (/dev/sdx or /dev/mmcblk0)
176 in the next example I use /dev/mmcblk0
178 for example: with gpt table with 128 entries
180 a) remove previous formatting
181 # sgdisk -o /dev/<SDCard dev>
183 b) create minimal image
184 # sgdisk --resize-table=128 -a 1 \
185 -n 1:34:545 -c 1:fsbl1 \
186 -n 2:546:1057 -c 2:fsbl2 \
187 -n 3:1058:5153 -c 3:ssbl \
190 you can add other partitions for kernel
191 one partition rootfs for example:
192 -n 3:5154: -c 4:rootfs
194 c) copy the FSBL (2 times) and SSBL file on the correct partition.
195 in this example in partition 1 to 3
197 for basic boot mode : <SDCard dev> = /dev/mmcblk0
198 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
199 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
200 # dd if=u-boot.img of=/dev/mmcblk0p3
202 To boot from SDCard, select BootPinMode = 1 1 1 and reset.
206 You can use U-Boot to copy binary in eMMC.
208 In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
209 are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
211 To boot from SDCard, select BootPinMode = 1 1 1 and reset.
213 Then you update the eMMC with the next U-Boot command :
215 a) prepare GPT on eMMC,
216 example with 2 partitions, bootfs and roots:
218 # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
219 # gpt write mmc 1 ${emmc_part}
221 b) copy SPL on eMMC on firts boot partition
222 (SPL max size is 256kB, with LBA 512, 0x200)
224 # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
226 # mmc partconf 1 1 1 1
227 # mmc write ${fileaddr} 0 200
228 # mmc partconf 1 1 1 0
230 b) copy U-Boot in first GPT partition of eMMC
232 # ext4load mmc 0:4 0xC0000000 u-boot.img
234 # part start mmc 1 1 partstart
235 # part size mmc 1 1 partsize
236 # mmc write ${fileaddr} ${partstart} ${partsize}
238 To boot from eMMC, select BootPinMode = 0 1 0 and reset.
243 Please read doc/README.enetaddr for the implementation guidelines for mac id
244 usage. Basically, environment has precedence over board specific storage.
246 Mac id storage and retrieval in stm32mp otp :
247 - OTP_57[31:0] = MAC_ADDR[31:0]
248 - OTP_58[15:0] = MAC_ADDR[47:32]
250 To program a MAC address on virgin OTP words above, you can use the fuse command
251 on bank 0 to access to internal OTP:
253 example to set mac address "12:34:56:78:9a:bc"
256 STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a
259 STM32MP> fuse sense 0 57 2
261 Word 0x00000039: 78563412 0000bc9a
264 ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"
267 STM32MP> print ethaddr
268 ethaddr=12:34:56:78:9a:bc