xref: /openbmc/u-boot/board/st/stm32mp1/README (revision e4061556)
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
322. STPMU1 (PMIC and regulator)
333. Clock, Reset, Sysreset
344. Fuse
35
36Currently the following boards are supported:
37+ stm32mp157c-ev1
38+ stm32mp157c-ed1
39
403. Boot Sequences
41=================
42
43BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
44
45with FSBL = First Stage Bootloader
46     SSBL = Second Stage Bootloader
47
48One boot configuration is supported:
49
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)
55
56All the STM32MP1 board supported by U-Boot use the same generic board
57stm32mp1 which support all the bootable devices.
58
59Each board is configurated only with the associated device tree.
60
614. Device Tree Selection
62========================
63
64You need to select the appropriate device tree for your board,
65the supported device trees for stm32mp157 are:
66
67+ ev1: eval board with pmic stpmu1 (ev1 = mother board + daughter ed1)
68  dts: stm32mp157c-ev1
69
70+ ed1: daughter board with pmic stpmu1
71  dts: stm32mp157c-ed1
72
735. Build Procedure
74==================
75
761. Install required tools for U-Boot
77
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)
82
832. Set the cross compiler:
84
85	# export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
86	(you can use any gcc cross compiler compatible with U-Boot)
87
883. Select the output directory (optional)
89
90	# export KBUILD_OUTPUT=/path/to/output
91
92	for example: use one output directory for each configuration
93	# export KBUILD_OUTPUT=stm32mp15_basic
94
954. Configure the U-Boot:
96
97	# make <defconfig_file>
98
99	- For basic boot mode: "stm32mp15_basic_defconfig"
100
1015. Configure the device-tree and build the U-Boot image:
102
103	# make DEVICE_TREE=<name> all
104
105
106  example:
107     basic boot on ev1
108	# export KBUILD_OUTPUT=stm32mp15_basic
109	# make stm32mp15_basic_defconfig
110	# make DEVICE_TREE=stm32mp157c-ev1 all
111
112     basic boot on ed1
113	# export KBUILD_OUTPUT=stm32mp15_basic
114	# make stm32mp15_basic_defconfig
115	# make DEVICE_TREE=stm32mp157c-ed1 all
116
1176. Output files
118
119  BootRom and TF-A expect binaries with STM32 image header
120  SPL expects file with U-Boot uImage header
121
122  So in the output directory (selected by KBUILD_OUTPUT),
123  you can found the needed files:
124
125   + FSBL = spl/u-boot-spl.stm32
126   + SSBL = u-boot.img
127
1286. Switch Setting for Boot Mode
129===============================
130
131You can select the boot mode, on the board ed1 with the switch SW1
132
133 -----------------------------------
134  Boot Mode   BOOT2   BOOT1   BOOT0
135 -----------------------------------
136  Reserved	0	0	0
137  NOR		0	0	1
138  SD-Card	1	1	1
139  SD-Card	1	0	1
140  eMMC		0	1	0
141  NAND		0	1	1
142  Recovery	1	1	0
143  Recovery	0	0	0
144
145Recovery is a boot from serial link (UART/USB) and it is used with
146STM32CubeProgrammer tool to load executable in RAM and to update the flash
147devices available on the board (NOR/NAND/eMMC/SDCARD).
148The 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)
151
1527. Prepare an SDCard
153===================
154
155The 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
159
160Then 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   ----- ------- --------- -------------
169
170(*) add bootable partition for extlinux.conf
171    following Generic Distribution
172    (doc/README.distro for use)
173
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
177
178for example: with gpt table with 128 entries
179
180  a) remove previous formatting
181	# sgdisk -o /dev/<SDCard dev>
182
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 \
188		-p /dev/<SDCard dev>
189
190	you can add other partitions for kernel
191	one partition rootfs for example:
192		-n 3:5154:		-c 4:rootfs
193
194  c) copy the FSBL (2 times) and SSBL file on the correct partition.
195     in this example in partition 1 to 3
196
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
201
202To boot from SDCard, select BootPinMode = 1 1 1 and reset.
203
2048. Prepare eMMC
205===============
206You can use U-Boot to copy binary in eMMC.
207
208In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
209are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
210
211To boot from SDCard, select BootPinMode = 1 1 1 and reset.
212
213Then you update the eMMC with the next U-Boot command :
214
215a) prepare GPT on eMMC,
216	example with 2 partitions, bootfs and roots:
217
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}
220
221b) copy SPL on eMMC on firts boot partition
222	(SPL max size is 256kB, with LBA 512, 0x200)
223
224	# ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
225	# mmc dev 1
226	# mmc partconf 1 1 1 1
227	# mmc write ${fileaddr} 0 200
228	# mmc partconf 1 1 1 0
229
230b) copy U-Boot in first GPT partition of eMMC
231
232	# ext4load mmc 0:4 0xC0000000 u-boot.img
233	# mmc dev 1
234	# part start mmc 1 1 partstart
235	# part size mmc 1 1 partsize
236	# mmc write ${fileaddr} ${partstart} ${partsize}
237
238To boot from eMMC, select BootPinMode = 0 1 0 and reset.
239
2409. MAC Address
241==============
242
243Please read doc/README.enetaddr for the implementation guidelines for mac id
244usage. Basically, environment has precedence over board specific storage.
245
246Mac 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]
249
250To program a MAC address on virgin OTP words above, you can use the fuse command
251on bank 0 to access to internal OTP:
252
253    example to set mac address "12:34:56:78:9a:bc"
254
255    1- Write OTP
256       STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a
257
258    2- Read OTP
259       STM32MP> fuse sense 0 57 2
260       Sensing bank 0:
261       Word 0x00000039: 78563412 0000bc9a
262
263    3- next REBOOT :
264       ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"
265
266    4 check env update
267       STM32MP> print ethaddr
268       ethaddr=12:34:56:78:9a:bc
269