xref: /openbmc/u-boot/board/st/stm32mp1/README (revision 9ab66d0d)
1SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2#
3# Copyright (C) 2018 STMicroelectronics - All Rights Reserved
4#
5
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
312. STPMU1
323. Clock, Reset
33
34Currently the following boards are supported:
35+ stm32mp157c-ed1
36
373. Boot Sequences
38=================
39
40BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
41
42with FSBL = First Stage Bootloader
43     SSBL = Second Stage Bootloader
44
45One boot configuration is supported:
46
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)
52
53All the STM32MP1 board supported by U-Boot use the same generic board
54stm32mp1 which support all the bootable devices.
55
56Each board is configurated only with the associated device tree.
57
584. Device Tree Selection
59========================
60
61You need to select the appropriate device tree for your board,
62the supported device trees for stm32mp157 are:
63
64+ ed1: daughter board with pmic stpmu1
65  dts: stm32mp157c-ed1
66
675. Build Procedure
68==================
69
701. Install required tools for U-Boot
71
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)
76
772. Set the cross compiler:
78
79	# export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
80	(you can use any gcc cross compiler compatible with U-Boot)
81
823. Select the output directory (optional)
83
84	# export KBUILD_OUTPUT=/path/to/output
85
86	for example: use one output directory for each configuration
87	# export KBUILD_OUTPUT=stm32mp15_basic
88
894. Configure the U-Boot:
90
91	# make <defconfig_file>
92
93	- For basic boot mode: "stm32mp15_basic_defconfig"
94
955. Configure the device-tree and build the U-Boot image:
96
97	# make DEVICE_TREE=<name> all
98
99
100  example:
101     basic boot on ed1
102	# export KBUILD_OUTPUT=stm32mp15_basic
103	# make stm32mp15_basic_defconfig
104	# make DEVICE_TREE=stm32mp157c-ed1 all
105
1066. Output files
107
108  BootRom and ATF expect binaries with STM32 image header
109  SPL expects file with U-Boot uImage header
110
111  So in the output directory (selected by KBUILD_OUTPUT),
112  you can found the needed files:
113
114   + FSBL = spl/u-boot-spl.stm32
115   + SSBL = u-boot.img
116
1176. Switch Setting for Boot Mode
118===============================
119
120You can select the boot mode, on the board ed1 with the switch SW1
121
122 -----------------------------------
123  Boot Mode   BOOT2   BOOT1   BOOT0
124 -----------------------------------
125  Reserved	0	0	0
126  NOR		0	0	1
127  SD-Card	1	1	1
128  SD-Card	1	0	1
129  eMMC		0	1	0
130  NAND		0	1	1
131  Recovery	1	1	0
132  Recovery	0	0	0
133
134Recovery is a boot from serial link (UART/USB) and it is used with
135STM32CubeProgrammer tool to load executable in RAM and to update the flash
136devices available on the board (NOR/NAND/eMMC/SDCARD).
137The 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)
140
1417. Prepare an SDCard
142===================
143
144The 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
148
149Then 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   ----- ------- --------- -------------
158
159(*) add bootable partition for extlinux.conf
160    following Generic Distribution
161    (doc/README.distro for use)
162
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
166
167for example: with gpt table with 128 entries
168
169  a) remove previous formatting
170	# sgdisk -o /dev/<SDCard dev>
171
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 \
177		-p /dev/<SDCard dev>
178
179	you can add other partition for kernel (rootfs for example)
180
181  c) copy the FSBL (2 times) and SSBL file on the correct partition.
182     in this example in partition 1 to 3
183
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
188
189To boot from SDCard, select BootPinMode = 1 1 1 and reset.
190
1918. Prepare eMMC
192===============
193You can use U-Boot to copy binary in eMMC.
194
195In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
196are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
197
198To boot from SDCard, select BootPinMode = 1 1 1 and reset.
199
200Then you update the eMMC with the next U-Boot command :
201
202a) prepare GPT on eMMC,
203	example with 2 partitions, bootfs and roots:
204
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}
207
208b) copy SPL on eMMC on firts boot partition
209	(SPL max size is 256kB, with LBA 512, 0x200)
210
211	# ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
212	# mmc dev 1
213	# mmc partconf 1 1 1 1
214	# mmc write ${fileaddr} 0 200
215	# mmc partconf 1 1 1 0
216
217b) copy U-Boot in first GPT partition of eMMC
218
219	# ext4load mmc 0:4 0xC0000000 u-boot.img
220	# mmc dev 1
221	# part start mmc 1 1 partstart
222	# part size mmc 1 1 partsize
223	# mmc write ${fileaddr} ${partstart} ${partsize}
224
225To boot from eMMC, select BootPinMode = 0 1 0 and reset.
226