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
34 Currently the following boards are supported:
40 BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
42 with FSBL = First Stage Bootloader
43 SSBL = Second Stage Bootloader
45 One boot configuration is supported:
47 The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
48 BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
49 SPL has limited security initialisation
50 U-Boot is running in secure mode and provide a secure monitor to the kernel
51 with only PSCI support (Power State Coordination Interface defined by ARM)
53 All the STM32MP1 board supported by U-Boot use the same generic board
54 stm32mp1 which support all the bootable devices.
56 Each board is configurated only with the associated device tree.
58 4. Device Tree Selection
59 ========================
61 You need to select the appropriate device tree for your board,
62 the supported device trees for stm32mp157 are:
64 + ed1: daughter board with pmic stpmu1
70 1. Install required tools for U-Boot
72 + install package needed in U-Boot makefile
73 (libssl-dev, swig, libpython-dev...)
74 + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
75 from SDK for STM32MP1, or any crosstoolchains from your distribution)
77 2. Set the cross compiler:
79 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
80 (you can use any gcc cross compiler compatible with U-Boot)
82 3. Select the output directory (optional)
84 # export KBUILD_OUTPUT=/path/to/output
86 for example: use one output directory for each configuration
87 # export KBUILD_OUTPUT=stm32mp15_basic
89 4. Configure the U-Boot:
91 # make <defconfig_file>
93 - For basic boot mode: "stm32mp15_basic_defconfig"
95 5. Configure the device-tree and build the U-Boot image:
97 # make DEVICE_TREE=<name> all
102 # export KBUILD_OUTPUT=stm32mp15_basic
103 # make stm32mp15_basic_defconfig
104 # make DEVICE_TREE=stm32mp157c-ed1 all
108 BootRom and ATF expect binaries with STM32 image header
109 SPL expects file with U-Boot uImage header
111 So in the output directory (selected by KBUILD_OUTPUT),
112 you can found the needed files:
114 + FSBL = spl/u-boot-spl.stm32
117 6. Switch Setting for Boot Mode
118 ===============================
120 You can select the boot mode, on the board ed1 with the switch SW1
122 -----------------------------------
123 Boot Mode BOOT2 BOOT1 BOOT0
124 -----------------------------------
134 Recovery is a boot from serial link (UART/USB) and it is used with
135 STM32CubeProgrammer tool to load executable in RAM and to update the flash
136 devices available on the board (NOR/NAND/eMMC/SDCARD).
137 The communication between HOST and board is based on
138 - for UARTs : the uart protocol used with all MCU STM32
139 - for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
144 The minimal requirements for STMP32MP1 boot up to U-Boot are:
145 - GPT partitioning (with gdisk or with sgdisk)
146 - 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
147 - one ssbl partition for U-Boot
149 Then the minimal GPT partition is:
150 ----- ------- --------- -------------
151 | Num | Name | Size | Content |
152 ----- ------- -------- --------------
153 | 1 | fsbl1 | 256 KiB | ATF or SPL |
154 | 2 | fsbl2 | 256 KiB | ATF or SPL |
155 | 3 | ssbl | enought | U-Boot |
156 | * | - | - | Boot/Rootfs|
157 ----- ------- --------- -------------
159 (*) add bootable partition for extlinux.conf
160 following Generic Distribution
161 (doc/README.distro for use)
163 according the used card reader select the block device
164 (/dev/sdx or /dev/mmcblk0)
165 in the next example I use /dev/mmcblk0
167 for example: with gpt table with 128 entries
169 a) remove previous formatting
170 # sgdisk -o /dev/<SDCard dev>
172 b) create minimal image
173 # sgdisk --resize-table=128 -a 1 \
174 -n 1:34:545 -c 1:fsbl1 \
175 -n 2:546:1057 -c 2:fsbl2 \
176 -n 3:1058:5153 -c 3:ssbl \
179 you can add other partition for kernel (rootfs for example)
181 c) copy the FSBL (2 times) and SSBL file on the correct partition.
182 in this example in partition 1 to 3
184 for basic boot mode : <SDCard dev> = /dev/mmcblk0
185 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
186 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
187 # dd if=u-boot.img of=/dev/mmcblk0p3
189 To boot from SDCard, select BootPinMode = 1 1 1 and reset.
193 You can use U-Boot to copy binary in eMMC.
195 In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
196 are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
198 To boot from SDCard, select BootPinMode = 1 1 1 and reset.
200 Then you update the eMMC with the next U-Boot command :
202 a) prepare GPT on eMMC,
203 example with 2 partitions, bootfs and roots:
205 # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
206 # gpt write mmc 1 ${emmc_part}
208 b) copy SPL on eMMC on firts boot partition
209 (SPL max size is 256kB, with LBA 512, 0x200)
211 # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
213 # mmc partconf 1 1 1 1
214 # mmc write ${fileaddr} 0 200
215 # mmc partconf 1 1 1 0
217 b) copy U-Boot in first GPT partition of eMMC
219 # ext4load mmc 0:4 0xC0000000 u-boot.img
221 # part start mmc 1 1 partstart
222 # part size mmc 1 1 partsize
223 # mmc write ${fileaddr} ${partstart} ${partsize}
225 To boot from eMMC, select BootPinMode = 0 1 0 and reset.