summaryrefslogtreecommitdiff
path: root/board/st/stm32mp1/README
blob: 1c3e865e20d4954e29837eb0608e6701ac627215 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
#
# Copyright (C) 2018 STMicroelectronics - All Rights Reserved
#

U-Boot on STMicroelectronics STM32MP1
======================================

1. Summary
==========
This is a quick instruction for setup stm32mp1 boards.

2. Supported devices
====================
U-Boot supports one STMP32MP1 SoCs: STM32MP157

The STM32MP157 is a Cortex-A MPU aimed at various applications.
It features:
- Dual core Cortex-A7 application core
- 2D/3D image composition with GPU
- Standard memories interface support
- Standard connectivity, widely inherited from the STM32 MCU family
- Comprehensive security support

Everything is supported in Linux but U-Boot is limited to:
1. UART
2. SDCard/MMC controller (SDMMC)

And the necessary drivers
1. I2C
2. STPMU1 (PMIC and regulator)
3. Clock, Reset, Sysreset
4. Fuse

Currently the following boards are supported:
+ stm32mp157c-ev1
+ stm32mp157c-ed1

3. Boot Sequences
=================

BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)

with FSBL = First Stage Bootloader
     SSBL = Second Stage Bootloader

2 boot configurations are supported:

1) The "Trusted" boot chain (defconfig_file : stm32mp15_trusted_defconfig)
   BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
   TF-A performs a full initialization of Secure peripherals and installs a
   secure monitor.
   U-Boot is running in normal world and uses TF-A monitor
   to access to secure resources

2) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
   BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
   SPL has limited security initialisation
   U-Boot is running in secure mode and provide a secure monitor to the kernel
   with only PSCI support (Power State Coordination Interface defined by ARM)

All the STM32MP1 boards supported by U-Boot use the same generic board
stm32mp1 which support all the bootable devices.

Each board is configurated only with the associated device tree.

4. Device Tree Selection
========================

You need to select the appropriate device tree for your board,
the supported device trees for stm32mp157 are:

+ ev1: eval board with pmic stpmu1 (ev1 = mother board + daughter ed1)
  dts: stm32mp157c-ev1

+ ed1: daughter board with pmic stpmu1
  dts: stm32mp157c-ed1

5. Build Procedure
==================

1. Install required tools for U-Boot

   + install package needed in U-Boot makefile
     (libssl-dev, swig, libpython-dev...)
   + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
     from SDK for STM32MP1, or any crosstoolchains from your distribution)

2. Set the cross compiler:

	# export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
	(you can use any gcc cross compiler compatible with U-Boot)

3. Select the output directory (optional)

	# export KBUILD_OUTPUT=/path/to/output

	for example: use one output directory for each configuration
	# export KBUILD_OUTPUT=stm32mp15_trusted
	# export KBUILD_OUTPUT=stm32mp15_basic

4. Configure U-Boot:

	# make <defconfig_file>

	- For trusted boot mode : "stm32mp15_trusted_defconfig"
	- For basic boot mode: "stm32mp15_basic_defconfig"

5. Configure the device-tree and build the U-Boot image:

	# make DEVICE_TREE=<name> all


  example:
  a) trusted boot on ev1
	# export KBUILD_OUTPUT=stm32mp15_trusted
	# make stm32mp15_trusted_defconfig
	# make DEVICE_TREE=stm32mp157c-ev1 all

  b) basic boot on ev1
	# export KBUILD_OUTPUT=stm32mp15_basic
	# make stm32mp15_basic_defconfig
	# make DEVICE_TREE=stm32mp157c-ev1 all

  c) basic boot on ed1
	# export KBUILD_OUTPUT=stm32mp15_basic
	# make stm32mp15_basic_defconfig
	# make DEVICE_TREE=stm32mp157c-ed1 all

6. Output files

  BootRom and TF-A expect binaries with STM32 image header
  SPL expects file with U-Boot uImage header

  So in the output directory (selected by KBUILD_OUTPUT),
  you can found the needed files:

  a) For Trusted boot
   + FSBL = tf-a.stm32 (provided by TF-A compilation)
   + SSBL = u-boot.stm32

  b) For Basic boot
   + FSBL = spl/u-boot-spl.stm32
   + SSBL = u-boot.img

6. Switch Setting for Boot Mode
===============================

You can select the boot mode, on the board ed1 with the switch SW1

 -----------------------------------
  Boot Mode   BOOT2   BOOT1   BOOT0
 -----------------------------------
  Reserved	0	0	0
  NOR		0	0	1
  SD-Card	1	0	1
  eMMC		0	1	0
  NAND		0	1	1
  Recovery	1	1	0
  Recovery	0	0	0

Recovery is a boot from serial link (UART/USB) and it is used with
STM32CubeProgrammer tool to load executable in RAM and to update the flash
devices available on the board (NOR/NAND/eMMC/SDCARD).
The communication between HOST and board is based on
- for UARTs : the uart protocol used with all MCU STM32
- for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)

7. Prepare an SDCard
===================

The minimal requirements for STMP32MP1 boot up to U-Boot are:
- GPT partitioning (with gdisk or with sgdisk)
- 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
- one ssbl partition for U-Boot

Then the minimal GPT partition is:
   ----- ------- --------- --------------
  | Num | Name  | Size    |  Content     |
   ----- ------- -------- ---------------
  |  1  | fsbl1 | 256 KiB |  TF-A or SPL |
  |  2  | fsbl2 | 256 KiB |  TF-A or SPL |
  |  3  | ssbl  | enought |  U-Boot      |
  |  *  |  -    |  -      |  Boot/Rootfs |
   ----- ------- --------- --------------

(*) add bootable partition for extlinux.conf
    following Generic Distribution
    (doc/README.distro for use)

  according the used card reader select the block device
  (/dev/sdx or /dev/mmcblk0)
  in the next example I use /dev/mmcblk0

for example: with gpt table with 128 entries

  a) remove previous formatting
	# sgdisk -o /dev/<SDCard dev>

  b) create minimal image
	# sgdisk --resize-table=128 -a 1 \
		-n 1:34:545		-c 1:fsbl1 \
		-n 2:546:1057		-c 2:fsbl2 \
		-n 3:1058:5153		-c 3:ssbl \
		-p /dev/<SDCard dev>

	you can add other partitions for kernel
	one partition rootfs for example:
		-n 4:5154:		-c 4:rootfs \

  c) copy the FSBL (2 times) and SSBL file on the correct partition.
     in this example in partition 1 to 3

     for basic boot mode : <SDCard dev> = /dev/mmcblk0
	# dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
	# dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
	# dd if=u-boot.img of=/dev/mmcblk0p3

     for trusted boot mode :
	# dd if=tf-a.stm32 of=/dev/mmcblk0p1
	# dd if=tf-a.stm32 of=/dev/mmcblk0p2
	# dd if=u-boot.stm32 of=/dev/mmcblk0p3

To boot from SDCard, select BootPinMode = 1 1 1 and reset.

8. Prepare eMMC
===============
You can use U-Boot to copy binary in eMMC.

In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).

To boot from SDCard, select BootPinMode = 1 0 1 and reset.

Then you update the eMMC with the next U-Boot command :

a) prepare GPT on eMMC,
	example with 2 partitions, bootfs and roots:

	# setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
	# gpt write mmc 1 ${emmc_part}

b) copy SPL on eMMC on firts boot partition
	(SPL max size is 256kB, with LBA 512, 0x200)

	# ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
	# mmc dev 1
	# mmc partconf 1 1 1 1
	# mmc write ${fileaddr} 0 200
	# mmc partconf 1 1 1 0

c) copy U-Boot in first GPT partition of eMMC

	# ext4load mmc 0:4 0xC0000000 u-boot.img
	# mmc dev 1
	# part start mmc 1 1 partstart
	# part size mmc 1 1 partsize
	# mmc write ${fileaddr} ${partstart} ${partsize}

To boot from eMMC, select BootPinMode = 0 1 0 and reset.

9. MAC Address
==============

Please read doc/README.enetaddr for the implementation guidelines for mac id
usage. Basically, environment has precedence over board specific storage.

Mac id storage and retrieval in stm32mp otp :
- OTP_57[31:0] = MAC_ADDR[31:0]
- OTP_58[15:0] = MAC_ADDR[47:32]

To program a MAC address on virgin OTP words above, you can use the fuse command
on bank 0 to access to internal OTP:

    example to set mac address "12:34:56:78:9a:bc"

    1- Write OTP
       STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a

    2- Read OTP
       STM32MP> fuse sense 0 57 2
       Sensing bank 0:
       Word 0x00000039: 78563412 0000bc9a

    3- next REBOOT :
       ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"

    4 check env update
       STM32MP> print ethaddr
       ethaddr=12:34:56:78:9a:bc