power: rename stpmu1 to official name stpmic1
[oweals/u-boot.git] / board / st / stm32mp1 / README
1 SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2 #
3 # Copyright (C) 2018 STMicroelectronics - All Rights Reserved
4 #
5
6 U-Boot on STMicroelectronics STM32MP1
7 ======================================
8
9 1. Summary
10 ==========
11 This is a quick instruction for setup stm32mp1 boards.
12
13 2. Supported devices
14 ====================
15 U-Boot supports one STMP32MP1 SoCs: STM32MP157
16
17 The STM32MP157 is a Cortex-A MPU aimed at various applications.
18 It 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
25 Everything is supported in Linux but U-Boot is limited to:
26 1. UART
27 2. SDCard/MMC controller (SDMMC)
28
29 And the necessary drivers
30 1. I2C
31 2. STPMIC1 (PMIC and regulator)
32 3. Clock, Reset, Sysreset
33 4. Fuse
34
35 Currently the following boards are supported:
36 + stm32mp157c-ev1
37 + stm32mp157c-ed1
38
39 3. Boot Sequences
40 =================
41
42 BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
43
44 with FSBL = First Stage Bootloader
45      SSBL = Second Stage Bootloader
46
47 2 boot configurations are supported:
48
49 1) The "Trusted" boot chain (defconfig_file : stm32mp15_trusted_defconfig)
50    BootRom => FSBL = Trusted Firmware-A (TF-A) => SSBL = U-Boot
51    TF-A performs a full initialization of Secure peripherals and installs a
52    secure monitor.
53    U-Boot is running in normal world and uses TF-A monitor
54    to access to secure resources
55
56 2) The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig)
57    BootRom => FSBL = U-Boot SPL => SSBL = U-Boot
58    SPL has limited security initialisation
59    U-Boot is running in secure mode and provide a secure monitor to the kernel
60    with only PSCI support (Power State Coordination Interface defined by ARM)
61
62 All the STM32MP1 boards supported by U-Boot use the same generic board
63 stm32mp1 which support all the bootable devices.
64
65 Each board is configurated only with the associated device tree.
66
67 4. Device Tree Selection
68 ========================
69
70 You need to select the appropriate device tree for your board,
71 the supported device trees for stm32mp157 are:
72
73 + ev1: eval board with pmic stpmic1 (ev1 = mother board + daughter ed1)
74   dts: stm32mp157c-ev1
75
76 + ed1: daughter board with pmic stpmic1
77   dts: stm32mp157c-ed1
78
79 5. Build Procedure
80 ==================
81
82 1. Install required tools for U-Boot
83
84    + install package needed in U-Boot makefile
85      (libssl-dev, swig, libpython-dev...)
86    + install ARMv7 toolchain for 32bit Cortex-A (from Linaro,
87      from SDK for STM32MP1, or any crosstoolchains from your distribution)
88
89 2. Set the cross compiler:
90
91         # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi-
92         (you can use any gcc cross compiler compatible with U-Boot)
93
94 3. Select the output directory (optional)
95
96         # export KBUILD_OUTPUT=/path/to/output
97
98         for example: use one output directory for each configuration
99         # export KBUILD_OUTPUT=stm32mp15_trusted
100         # export KBUILD_OUTPUT=stm32mp15_basic
101
102 4. Configure U-Boot:
103
104         # make <defconfig_file>
105
106         - For trusted boot mode : "stm32mp15_trusted_defconfig"
107         - For basic boot mode: "stm32mp15_basic_defconfig"
108
109 5. Configure the device-tree and build the U-Boot image:
110
111         # make DEVICE_TREE=<name> all
112
113
114   example:
115   a) trusted boot on ev1
116         # export KBUILD_OUTPUT=stm32mp15_trusted
117         # make stm32mp15_trusted_defconfig
118         # make DEVICE_TREE=stm32mp157c-ev1 all
119
120   b) basic boot on ev1
121         # export KBUILD_OUTPUT=stm32mp15_basic
122         # make stm32mp15_basic_defconfig
123         # make DEVICE_TREE=stm32mp157c-ev1 all
124
125   c) basic boot on ed1
126         # export KBUILD_OUTPUT=stm32mp15_basic
127         # make stm32mp15_basic_defconfig
128         # make DEVICE_TREE=stm32mp157c-ed1 all
129
130 6. Output files
131
132   BootRom and TF-A expect binaries with STM32 image header
133   SPL expects file with U-Boot uImage header
134
135   So in the output directory (selected by KBUILD_OUTPUT),
136   you can found the needed files:
137
138   a) For Trusted boot
139    + FSBL = tf-a.stm32 (provided by TF-A compilation)
140    + SSBL = u-boot.stm32
141
142   b) For Basic boot
143    + FSBL = spl/u-boot-spl.stm32
144    + SSBL = u-boot.img
145
146 6. Switch Setting for Boot Mode
147 ===============================
148
149 You can select the boot mode, on the board ed1 with the switch SW1
150
151  -----------------------------------
152   Boot Mode   BOOT2   BOOT1   BOOT0
153  -----------------------------------
154   Reserved      0       0       0
155   NOR           0       0       1
156   SD-Card       1       0       1
157   eMMC          0       1       0
158   NAND          0       1       1
159   Recovery      1       1       0
160   Recovery      0       0       0
161
162 Recovery is a boot from serial link (UART/USB) and it is used with
163 STM32CubeProgrammer tool to load executable in RAM and to update the flash
164 devices available on the board (NOR/NAND/eMMC/SDCARD).
165 The communication between HOST and board is based on
166 - for UARTs : the uart protocol used with all MCU STM32
167 - for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32)
168
169 7. Prepare an SDCard
170 ===================
171
172 The minimal requirements for STMP32MP1 boot up to U-Boot are:
173 - GPT partitioning (with gdisk or with sgdisk)
174 - 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB
175 - one ssbl partition for U-Boot
176
177 Then the minimal GPT partition is:
178    ----- ------- --------- --------------
179   | Num | Name  | Size    |  Content     |
180    ----- ------- -------- ---------------
181   |  1  | fsbl1 | 256 KiB |  TF-A or SPL |
182   |  2  | fsbl2 | 256 KiB |  TF-A or SPL |
183   |  3  | ssbl  | enought |  U-Boot      |
184   |  *  |  -    |  -      |  Boot/Rootfs |
185    ----- ------- --------- --------------
186
187 (*) add bootable partition for extlinux.conf
188     following Generic Distribution
189     (doc/README.distro for use)
190
191   according the used card reader select the block device
192   (/dev/sdx or /dev/mmcblk0)
193   in the next example I use /dev/mmcblk0
194
195 for example: with gpt table with 128 entries
196
197   a) remove previous formatting
198         # sgdisk -o /dev/<SDCard dev>
199
200   b) create minimal image
201         # sgdisk --resize-table=128 -a 1 \
202                 -n 1:34:545             -c 1:fsbl1 \
203                 -n 2:546:1057           -c 2:fsbl2 \
204                 -n 3:1058:5153          -c 3:ssbl \
205                 -p /dev/<SDCard dev>
206
207         you can add other partitions for kernel
208         one partition rootfs for example:
209                 -n 4:5154:              -c 4:rootfs \
210
211   c) copy the FSBL (2 times) and SSBL file on the correct partition.
212      in this example in partition 1 to 3
213
214      for basic boot mode : <SDCard dev> = /dev/mmcblk0
215         # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1
216         # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2
217         # dd if=u-boot.img of=/dev/mmcblk0p3
218
219      for trusted boot mode :
220         # dd if=tf-a.stm32 of=/dev/mmcblk0p1
221         # dd if=tf-a.stm32 of=/dev/mmcblk0p2
222         # dd if=u-boot.stm32 of=/dev/mmcblk0p3
223
224 To boot from SDCard, select BootPinMode = 1 1 1 and reset.
225
226 8. Prepare eMMC
227 ===============
228 You can use U-Boot to copy binary in eMMC.
229
230 In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
231 are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
232
233 To boot from SDCard, select BootPinMode = 1 0 1 and reset.
234
235 Then you update the eMMC with the next U-Boot command :
236
237 a) prepare GPT on eMMC,
238         example with 2 partitions, bootfs and roots:
239
240         # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512"
241         # gpt write mmc 1 ${emmc_part}
242
243 b) copy SPL on eMMC on firts boot partition
244         (SPL max size is 256kB, with LBA 512, 0x200)
245
246         # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32
247         # mmc dev 1
248         # mmc partconf 1 1 1 1
249         # mmc write ${fileaddr} 0 200
250         # mmc partconf 1 1 1 0
251
252 c) copy U-Boot in first GPT partition of eMMC
253
254         # ext4load mmc 0:4 0xC0000000 u-boot.img
255         # mmc dev 1
256         # part start mmc 1 1 partstart
257         # part size mmc 1 1 partsize
258         # mmc write ${fileaddr} ${partstart} ${partsize}
259
260 To boot from eMMC, select BootPinMode = 0 1 0 and reset.
261
262 9. MAC Address
263 ==============
264
265 Please read doc/README.enetaddr for the implementation guidelines for mac id
266 usage. Basically, environment has precedence over board specific storage.
267
268 Mac id storage and retrieval in stm32mp otp :
269 - OTP_57[31:0] = MAC_ADDR[31:0]
270 - OTP_58[15:0] = MAC_ADDR[47:32]
271
272 To program a MAC address on virgin OTP words above, you can use the fuse command
273 on bank 0 to access to internal OTP:
274
275     example to set mac address "12:34:56:78:9a:bc"
276
277     1- Write OTP
278        STM32MP> fuse prog -y 0 57 0x78563412 0x0000bc9a
279
280     2- Read OTP
281        STM32MP> fuse sense 0 57 2
282        Sensing bank 0:
283        Word 0x00000039: 78563412 0000bc9a
284
285     3- next REBOOT :
286        ### Setting environment from OTP MAC address = "12:34:56:78:9a:bc"
287
288     4 check env update
289        STM32MP> print ethaddr
290        ethaddr=12:34:56:78:9a:bc