Merge tag 'u-boot-imx-20181112' of git://git.denx.de/u-boot-imx
[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. STPMU1
32 2. STPMU1 (PMIC and regulator)
33 3. Clock, Reset, Sysreset
34 4. Fuse
35
36 Currently the following boards are supported:
37 + stm32mp157c-ev1
38 + stm32mp157c-ed1
39
40 3. Boot Sequences
41 =================
42
43 BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel)
44
45 with FSBL = First Stage Bootloader
46      SSBL = Second Stage Bootloader
47
48 One 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
56 All the STM32MP1 board supported by U-Boot use the same generic board
57 stm32mp1 which support all the bootable devices.
58
59 Each board is configurated only with the associated device tree.
60
61 4. Device Tree Selection
62 ========================
63
64 You need to select the appropriate device tree for your board,
65 the 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
73 5. Build Procedure
74 ==================
75
76 1. 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
83 2. 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
88 3. 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
95 4. Configure the U-Boot:
96
97         # make <defconfig_file>
98
99         - For basic boot mode: "stm32mp15_basic_defconfig"
100
101 5. 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
117 6. 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
128 6. Switch Setting for Boot Mode
129 ===============================
130
131 You 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
145 Recovery is a boot from serial link (UART/USB) and it is used with
146 STM32CubeProgrammer tool to load executable in RAM and to update the flash
147 devices available on the board (NOR/NAND/eMMC/SDCARD).
148 The 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
152 7. Prepare an SDCard
153 ===================
154
155 The 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
160 Then 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
178 for 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
202 To boot from SDCard, select BootPinMode = 1 1 1 and reset.
203
204 8. Prepare eMMC
205 ===============
206 You can use U-Boot to copy binary in eMMC.
207
208 In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img)
209 are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs).
210
211 To boot from SDCard, select BootPinMode = 1 1 1 and reset.
212
213 Then you update the eMMC with the next U-Boot command :
214
215 a) 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
221 b) 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
230 b) 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
238 To boot from eMMC, select BootPinMode = 0 1 0 and reset.
239
240 9. MAC Address
241 ==============
242
243 Please read doc/README.enetaddr for the implementation guidelines for mac id
244 usage. Basically, environment has precedence over board specific storage.
245
246 Mac 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
250 To program a MAC address on virgin OTP words above, you can use the fuse command
251 on 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