xref: /openbmc/u-boot/board/st/stm32mp1/README (revision 0ed232b15386616d186b67a3689e149581dcf2b7)
1f8598d98SPatrick Delaunay#
2f8598d98SPatrick Delaunay# Copyright (C) 2018 STMicroelectronics - All Rights Reserved
3f8598d98SPatrick Delaunay#
4f8598d98SPatrick Delaunay# SPDX-License-Identifier:	GPL-2.0+	BSD-3-Clause
5f8598d98SPatrick Delaunay#
6f8598d98SPatrick Delaunay
7f8598d98SPatrick DelaunayU-Boot on STMicroelectronics STM32MP1
8f8598d98SPatrick Delaunay======================================
9f8598d98SPatrick Delaunay
10f8598d98SPatrick Delaunay1. Summary
11f8598d98SPatrick Delaunay==========
12f8598d98SPatrick DelaunayThis is a quick instruction for setup stm32mp1 boards.
13f8598d98SPatrick Delaunay
14f8598d98SPatrick Delaunay2. Supported devices
15f8598d98SPatrick Delaunay====================
16f8598d98SPatrick DelaunayU-Boot supports one STMP32MP1 SoCs: STM32MP157
17f8598d98SPatrick Delaunay
18f8598d98SPatrick DelaunayThe STM32MP157 is a Cortex-A MPU aimed at various applications.
19f8598d98SPatrick DelaunayIt features:
20f8598d98SPatrick Delaunay- Dual core Cortex-A7 application core
21f8598d98SPatrick Delaunay- 2D/3D image composition with GPU
22f8598d98SPatrick Delaunay- Standard memories interface support
23f8598d98SPatrick Delaunay- Standard connectivity, widely inherited from the STM32 MCU family
24f8598d98SPatrick Delaunay- Comprehensive security support
25f8598d98SPatrick Delaunay
26f8598d98SPatrick DelaunayEverything is supported in Linux but U-Boot is limited to:
27f8598d98SPatrick Delaunay1. UART
28f8598d98SPatrick Delaunay2. SDCard/MMC controller (SDMMC)
29f8598d98SPatrick Delaunay
30f8598d98SPatrick DelaunayAnd the necessary drivers
31f8598d98SPatrick Delaunay1. I2C
32f8598d98SPatrick Delaunay2. STPMU1
33f8598d98SPatrick Delaunay3. Clock, Reset
34f8598d98SPatrick Delaunay
35f8598d98SPatrick DelaunayCurrently the following boards are supported:
36f8598d98SPatrick Delaunay+ stm32mp157c-ed1
37f8598d98SPatrick Delaunay
38f8598d98SPatrick Delaunay3. Boot Sequences
39f8598d98SPatrick Delaunay=================
40f8598d98SPatrick Delaunay
41f8598d98SPatrick DelaunayBootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
42f8598d98SPatrick Delaunay
43f8598d98SPatrick Delaunaywith FSBL = First Stage Bootloader
44f8598d98SPatrick Delaunay     SSBL = Second Stage Bootloader
45f8598d98SPatrick Delaunay
46f8598d98SPatrick DelaunayOne boot configuration is supported:
47f8598d98SPatrick Delaunay
48f8598d98SPatrick Delaunay   The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
49f8598d98SPatrick Delaunay   BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
50f8598d98SPatrick Delaunay   SPL has limited security initialisation
51f8598d98SPatrick Delaunay   U-Boot is running in secure mode and provide a secure monitor to the kernel
52f8598d98SPatrick Delaunay   with only PSCI support (Power State Coordination Interface defined by ARM)
53f8598d98SPatrick Delaunay
54f8598d98SPatrick DelaunayAll the STM32MP1 board supported by U-Boot use the same generic board
55f8598d98SPatrick Delaunaystm32mp1 which support all the bootable devices.
56f8598d98SPatrick Delaunay
57f8598d98SPatrick DelaunayEach board is configurated only with the associated device tree.
58f8598d98SPatrick Delaunay
59f8598d98SPatrick Delaunay4. Device Tree Selection
60f8598d98SPatrick Delaunay========================
61f8598d98SPatrick Delaunay
62f8598d98SPatrick DelaunayYou need to select the appropriate device tree for your board,
63f8598d98SPatrick Delaunaythe supported device trees for stm32mp157 are:
64f8598d98SPatrick Delaunay
65f8598d98SPatrick Delaunay+ ed1: daughter board with pmic stpmu1
66f8598d98SPatrick Delaunay  dts: stm32mp157c-ed1
67f8598d98SPatrick Delaunay
68f8598d98SPatrick Delaunay5. Build Procedure
69f8598d98SPatrick Delaunay==================
70f8598d98SPatrick Delaunay
71f8598d98SPatrick Delaunay1. Install required tools for U-Boot
72f8598d98SPatrick Delaunay
73f8598d98SPatrick Delaunay   + install package needed in U-Boot makefile
74f8598d98SPatrick Delaunay     (libssl-dev, swig, libpython-dev...)
75f8598d98SPatrick Delaunay   + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
76f8598d98SPatrick Delaunay     from SDK for STM32MP1, or any crosstoolchains from your distribution)
77f8598d98SPatrick Delaunay
78f8598d98SPatrick Delaunay2. Set the cross compiler:
79f8598d98SPatrick Delaunay
80f8598d98SPatrick Delaunay	# export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
81f8598d98SPatrick Delaunay	(you can use any gcc cross compiler compatible with U-Boot)
82f8598d98SPatrick Delaunay
83f8598d98SPatrick Delaunay3. Select the output directory (optional)
84f8598d98SPatrick Delaunay
85f8598d98SPatrick Delaunay	# export KBUILD_OUTPUT=/path/to/output
86f8598d98SPatrick Delaunay
87f8598d98SPatrick Delaunay	for example: use one output directory for each configuration
88f8598d98SPatrick Delaunay	# export KBUILD_OUTPUT=stm32mp15_basic
89f8598d98SPatrick Delaunay
90f8598d98SPatrick Delaunay4. Configure the U-Boot:
91f8598d98SPatrick Delaunay
92f8598d98SPatrick Delaunay	# make <defconfig_file>
93f8598d98SPatrick Delaunay
94f8598d98SPatrick Delaunay	- For basic boot mode: "stm32mp15_basic_defconfig"
95f8598d98SPatrick Delaunay
96f8598d98SPatrick Delaunay5. Configure the device-tree and build the U-Boot image:
97f8598d98SPatrick Delaunay
98f8598d98SPatrick Delaunay	# make DEVICE_TREE=<name> all
99f8598d98SPatrick Delaunay
100f8598d98SPatrick Delaunay
101f8598d98SPatrick Delaunay  example:
102f8598d98SPatrick Delaunay     basic boot on ed1
103f8598d98SPatrick Delaunay	# export KBUILD_OUTPUT=stm32mp15_basic
104f8598d98SPatrick Delaunay	# make stm32mp15_basic_defconfig
105f8598d98SPatrick Delaunay	# make DEVICE_TREE=stm32mp157c-ed1 all
106f8598d98SPatrick Delaunay
107f8598d98SPatrick Delaunay6. Output files
108f8598d98SPatrick Delaunay
109f8598d98SPatrick Delaunay  BootRom and ATF expect binaries with STM32 image header
110f8598d98SPatrick Delaunay  SPL expects file with U-Boot uImage header
111f8598d98SPatrick Delaunay
112f8598d98SPatrick Delaunay  So in the output directory (selected by KBUILD_OUTPUT),
113f8598d98SPatrick Delaunay  you can found the needed files:
114f8598d98SPatrick Delaunay
115f8598d98SPatrick Delaunay   + FSBL = spl/u-boot-spl.stm32
116f8598d98SPatrick Delaunay   + SSBL = u-boot.img
117f8598d98SPatrick Delaunay
118*0ed232b1SPatrick Delaunay6. Switch Setting for Boot Mode
119*0ed232b1SPatrick Delaunay===============================
120*0ed232b1SPatrick Delaunay
121*0ed232b1SPatrick DelaunayYou can select the boot mode, on the board ed1 with the switch SW1
122*0ed232b1SPatrick Delaunay
123*0ed232b1SPatrick Delaunay -----------------------------------
124*0ed232b1SPatrick Delaunay  Boot Mode   BOOT2   BOOT1   BOOT0
125*0ed232b1SPatrick Delaunay -----------------------------------
126*0ed232b1SPatrick Delaunay  Reserved	0	0	0
127*0ed232b1SPatrick Delaunay  NOR		0	0	1
128*0ed232b1SPatrick Delaunay  SD-Card	1	1	1
129*0ed232b1SPatrick Delaunay  SD-Card	1	0	1
130*0ed232b1SPatrick Delaunay  eMMC		0	1	0
131*0ed232b1SPatrick Delaunay  NAND		0	1	1
132*0ed232b1SPatrick Delaunay  Recovery	1	1	0
133*0ed232b1SPatrick Delaunay  Recovery	0	0	0
134*0ed232b1SPatrick Delaunay
135*0ed232b1SPatrick DelaunayRecovery is a boot from serial link (UART/USB) and it is used with
136*0ed232b1SPatrick DelaunaySTM32CubeProgrammer tool to load executable in RAM and to update the flash
137*0ed232b1SPatrick Delaunaydevices available on the board (NOR/NAND/eMMC/SDCARD).
138*0ed232b1SPatrick DelaunayThe communication between HOST and board is based on
139*0ed232b1SPatrick Delaunay- for UARTs : the uart protocol used with all MCU STM32
140*0ed232b1SPatrick Delaunay- for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
141*0ed232b1SPatrick Delaunay
142*0ed232b1SPatrick Delaunay7. Prepare an SDCard
143f8598d98SPatrick Delaunay===================
144f8598d98SPatrick Delaunay
145f8598d98SPatrick DelaunayThe minimal requirements for STMP32MP1 boot up to U-Boot are:
146f8598d98SPatrick Delaunay- GPT partitioning (with gdisk or with sgdisk)
147f8598d98SPatrick Delaunay- 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
148f8598d98SPatrick Delaunay- one ssbl partition for U-Boot
149f8598d98SPatrick Delaunay
150f8598d98SPatrick DelaunayThen the minimal GPT partition is:
151f8598d98SPatrick Delaunay   ----- ------- --------- -------------
152f8598d98SPatrick Delaunay  | Num | Name  | Size    |  Content    |
153f8598d98SPatrick Delaunay   ----- ------- -------- --------------
154f8598d98SPatrick Delaunay  |  1  | fsbl1 | 256 KiB |  ATF or SPL |
155f8598d98SPatrick Delaunay  |  2  | fsbl2 | 256 KiB |  ATF or SPL |
156f8598d98SPatrick Delaunay  |  3  | ssbl  | enought |  U-Boot     |
157f8598d98SPatrick Delaunay  |  *  |  -    |  -      |  Boot/Rootfs|
158f8598d98SPatrick Delaunay   ----- ------- --------- -------------
159f8598d98SPatrick Delaunay
160f8598d98SPatrick Delaunay(*) add bootable partition for extlinux.conf
161f8598d98SPatrick Delaunay    following Generic Distribution
162f8598d98SPatrick Delaunay    (doc/README.distro for use)
163f8598d98SPatrick Delaunay
164f8598d98SPatrick Delaunay  according the used card reader select the block device
165f8598d98SPatrick Delaunay  (/dev/sdx or /dev/mmcblk0)
166f8598d98SPatrick Delaunay  in the next example I use /dev/mmcblk0
167f8598d98SPatrick Delaunay
168f8598d98SPatrick Delaunayfor example: with gpt table with 128 entries
169f8598d98SPatrick Delaunay
170f8598d98SPatrick Delaunay  a) remove previous formatting
171f8598d98SPatrick Delaunay	# sgdisk -o /dev/<SDCard dev>
172f8598d98SPatrick Delaunay
173f8598d98SPatrick Delaunay  b) create minimal image
174f8598d98SPatrick Delaunay	# sgdisk --resize-table=128 -a 1 \
175f8598d98SPatrick Delaunay		-n 1:34:545		-c 1:fsbl1 \
176f8598d98SPatrick Delaunay		-n 2:546:1057		-c 2:fsbl2 \
177f8598d98SPatrick Delaunay		-n 3:1058:5153		-c 3:ssbl \
178f8598d98SPatrick Delaunay		-p /dev/<SDCard dev>
179f8598d98SPatrick Delaunay
180*0ed232b1SPatrick Delaunay	you can add other partition for kernel (rootfs for example)
181f8598d98SPatrick Delaunay
182f8598d98SPatrick Delaunay  c) copy the FSBL (2 times) and SSBL file on the correct partition.
183f8598d98SPatrick Delaunay     in this example in partition 1 to 3
184f8598d98SPatrick Delaunay
185f8598d98SPatrick Delaunay     for basic boot mode : <SDCard dev> = /dev/mmcblk0
186f8598d98SPatrick Delaunay	# dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
187f8598d98SPatrick Delaunay	# dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
188f8598d98SPatrick Delaunay	# dd if=u-boot.img of=/dev/mmcblk0p3
189f8598d98SPatrick Delaunay
190*0ed232b1SPatrick DelaunayTo boot from SDCard, select BootPinMode = 1 1 1 and reset.
191f8598d98SPatrick Delaunay
192*0ed232b1SPatrick Delaunay8. Prepare eMMC
193*0ed232b1SPatrick Delaunay===============
194*0ed232b1SPatrick DelaunayYou can use U-Boot to copy binary in eMMC.
195f8598d98SPatrick Delaunay
196*0ed232b1SPatrick DelaunayIn the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
197*0ed232b1SPatrick Delaunayare presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
198f8598d98SPatrick Delaunay
199f8598d98SPatrick DelaunayTo boot from SDCard, select BootPinMode = 1 1 1 and reset.
200f8598d98SPatrick Delaunay
201*0ed232b1SPatrick DelaunayThen you update the eMMC with the next U-Boot command :
202*0ed232b1SPatrick Delaunay
203*0ed232b1SPatrick Delaunaya) prepare GPT on eMMC,
204*0ed232b1SPatrick Delaunay	example with 2 partitions, bootfs and roots:
205*0ed232b1SPatrick Delaunay
206*0ed232b1SPatrick Delaunay	# setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
207*0ed232b1SPatrick Delaunay	# gpt write mmc 1 ${emmc_part}
208*0ed232b1SPatrick Delaunay
209*0ed232b1SPatrick Delaunayb) copy SPL on eMMC on firts boot partition
210*0ed232b1SPatrick Delaunay	(SPL max size is 256kB, with LBA 512, 0x200)
211*0ed232b1SPatrick Delaunay
212*0ed232b1SPatrick Delaunay	# ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
213*0ed232b1SPatrick Delaunay	# mmc dev 1
214*0ed232b1SPatrick Delaunay	# mmc partconf 1 1 1 1
215*0ed232b1SPatrick Delaunay	# mmc write ${fileaddr} 0 200
216*0ed232b1SPatrick Delaunay	# mmc partconf 1 1 1 0
217*0ed232b1SPatrick Delaunay
218*0ed232b1SPatrick Delaunayb) copy U-Boot in first GPT partition of eMMC
219*0ed232b1SPatrick Delaunay
220*0ed232b1SPatrick Delaunay	# ext4load mmc 0:4 0xC0000000 u-boot.img
221*0ed232b1SPatrick Delaunay	# mmc dev 1
222*0ed232b1SPatrick Delaunay	# part start mmc 1 1 partstart
223*0ed232b1SPatrick Delaunay	# part size mmc 1 1 partsize
224*0ed232b1SPatrick Delaunay	# mmc write ${fileaddr} ${partstart} ${partsize}
225*0ed232b1SPatrick Delaunay
226*0ed232b1SPatrick DelaunayTo boot from eMMC, select BootPinMode = 0 1 0 and reset.
227