2 # Copyright (C) 2018 STMicroelectronics - All Rights Reserved
4 # SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause
7 U-Boot on STMicroelectronics STM32MP1
8 ======================================
12 This is a quick instruction for setup stm32mp1 boards.
16 U-Boot supports one STMP32MP1 SoCs: STM32MP157
18 The STM32MP157 is a Cortex-A MPU aimed at various applications.
20 - Dual core Cortex-A7 application core
21 - 2D/3D image composition with GPU
22 - Standard memories interface support
23 - Standard connectivity, widely inherited from the STM32 MCU family
24 - Comprehensive security support
26 Everything is supported in Linux but U-Boot is limited to:
28 2. SDCard/MMC controller (SDMMC)
30 And the necessary drivers
35 Currently the following boards are supported:
41 BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
43 with FSBL = First Stage Bootloader
44 SSBL = Second Stage Bootloader
46 One boot configuration is supported:
48 The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
49 BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
50 SPL has limited security initialisation
51 U-Boot is running in secure mode and provide a secure monitor to the kernel
52 with only PSCI support (Power State Coordination Interface defined by ARM)
54 All the STM32MP1 board supported by U-Boot use the same generic board
55 stm32mp1 which support all the bootable devices.
57 Each board is configurated only with the associated device tree.
59 4. Device Tree Selection
60 ========================
62 You need to select the appropriate device tree for your board,
63 the supported device trees for stm32mp157 are:
65 + ed1: daughter board with pmic stpmu1
71 1. Install required tools for U-Boot
73 + install package needed in U-Boot makefile
74 (libssl-dev, swig, libpython-dev...)
75 + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
76 from SDK for STM32MP1, or any crosstoolchains from your distribution)
78 2. Set the cross compiler:
80 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
81 (you can use any gcc cross compiler compatible with U-Boot)
83 3. Select the output directory (optional)
85 # export KBUILD_OUTPUT=/path/to/output
87 for example: use one output directory for each configuration
88 # export KBUILD_OUTPUT=stm32mp15_basic
90 4. Configure the U-Boot:
92 # make <defconfig_file>
94 - For basic boot mode: "stm32mp15_basic_defconfig"
96 5. Configure the device-tree and build the U-Boot image:
98 # make DEVICE_TREE=<name> all
103 # export KBUILD_OUTPUT=stm32mp15_basic
104 # make stm32mp15_basic_defconfig
105 # make DEVICE_TREE=stm32mp157c-ed1 all
109 BootRom and ATF expect binaries with STM32 image header
110 SPL expects file with U-Boot uImage header
112 So in the output directory (selected by KBUILD_OUTPUT),
113 you can found the needed files:
115 + FSBL = spl/u-boot-spl.stm32
118 6. Switch Setting for Boot Mode
119 ===============================
121 You can select the boot mode, on the board ed1 with the switch SW1
123 -----------------------------------
124 Boot Mode BOOT2 BOOT1 BOOT0
125 -----------------------------------
135 Recovery is a boot from serial link (UART/USB) and it is used with
136 STM32CubeProgrammer tool to load executable in RAM and to update the flash
137 devices available on the board (NOR/NAND/eMMC/SDCARD).
138 The communication between HOST and board is based on
139 - for UARTs : the uart protocol used with all MCU STM32
140 - for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
145 The minimal requirements for STMP32MP1 boot up to U-Boot are:
146 - GPT partitioning (with gdisk or with sgdisk)
147 - 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
148 - one ssbl partition for U-Boot
150 Then the minimal GPT partition is:
151 ----- ------- --------- -------------
152 | Num | Name | Size | Content |
153 ----- ------- -------- --------------
154 | 1 | fsbl1 | 256 KiB | ATF or SPL |
155 | 2 | fsbl2 | 256 KiB | ATF or SPL |
156 | 3 | ssbl | enought | U-Boot |
157 | * | - | - | Boot/Rootfs|
158 ----- ------- --------- -------------
160 (*) add bootable partition for extlinux.conf
161 following Generic Distribution
162 (doc/README.distro for use)
164 according the used card reader select the block device
165 (/dev/sdx or /dev/mmcblk0)
166 in the next example I use /dev/mmcblk0
168 for example: with gpt table with 128 entries
170 a) remove previous formatting
171 # sgdisk -o /dev/<SDCard dev>
173 b) create minimal image
174 # sgdisk --resize-table=128 -a 1 \
175 -n 1:34:545 -c 1:fsbl1 \
176 -n 2:546:1057 -c 2:fsbl2 \
177 -n 3:1058:5153 -c 3:ssbl \
180 you can add other partition for kernel (rootfs for example)
182 c) copy the FSBL (2 times) and SSBL file on the correct partition.
183 in this example in partition 1 to 3
185 for basic boot mode : <SDCard dev> = /dev/mmcblk0
186 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
187 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
188 # dd if=u-boot.img of=/dev/mmcblk0p3
190 To boot from SDCard, select BootPinMode = 1 1 1 and reset.
194 You can use U-Boot to copy binary in eMMC.
196 In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
197 are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
199 To boot from SDCard, select BootPinMode = 1 1 1 and reset.
201 Then you update the eMMC with the next U-Boot command :
203 a) prepare GPT on eMMC,
204 example with 2 partitions, bootfs and roots:
206 # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
207 # gpt write mmc 1 ${emmc_part}
209 b) copy SPL on eMMC on firts boot partition
210 (SPL max size is 256kB, with LBA 512, 0x200)
212 # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
214 # mmc partconf 1 1 1 1
215 # mmc write ${fileaddr} 0 200
216 # mmc partconf 1 1 1 0
218 b) copy U-Boot in first GPT partition of eMMC
220 # ext4load mmc 0:4 0xC0000000 u-boot.img
222 # part start mmc 1 1 partstart
223 # part size mmc 1 1 partsize
224 # mmc write ${fileaddr} ${partstart} ${partsize}
226 To boot from eMMC, select BootPinMode = 0 1 0 and reset.