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