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