Paul Beesley | f3653a6 | 2019-05-22 11:22:44 +0100 | [diff] [blame] | 1 | STMicroelectronics STM32MP1 |
| 2 | =========================== |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 3 | |
| 4 | STM32MP1 is a microprocessor designed by STMicroelectronics |
| 5 | based on a dual Arm Cortex-A7. |
| 6 | It is an Armv7-A platform, using dedicated code from TF-A. |
Yann Gautier | 969be34 | 2019-02-20 17:34:16 +0100 | [diff] [blame] | 7 | The STM32MP1 chip also embeds a Cortex-M4. |
| 8 | More information can be found on `STM32MP1 Series`_ page. |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 9 | |
| 10 | |
Yann Gautier | 26c1067 | 2020-10-13 11:27:05 +0200 | [diff] [blame] | 11 | STM32MP1 Versions |
| 12 | ----------------- |
| 13 | The STM32MP1 series is available in 3 different lines which are pin-to-pin compatible: |
| 14 | |
| 15 | - STM32MP157: Dual Cortex-A7 cores, Cortex-M4 core @ 209 MHz, 3D GPU, DSI display interface and CAN FD |
| 16 | - STM32MP153: Dual Cortex-A7 cores, Cortex-M4 core @ 209 MHz and CAN FD |
| 17 | - STM32MP151: Single Cortex-A7 core, Cortex-M4 core @ 209 MHz |
| 18 | |
| 19 | Each line comes with a security option (cryptography & secure boot) and a Cortex-A frequency option: |
| 20 | |
| 21 | - A Basic + Cortex-A7 @ 650 MHz |
| 22 | - C Secure Boot + HW Crypto + Cortex-A7 @ 650 MHz |
| 23 | - D Basic + Cortex-A7 @ 800 MHz |
| 24 | - F Secure Boot + HW Crypto + Cortex-A7 @ 800 MHz |
| 25 | |
| 26 | The `STM32MP1 part number codification`_ page gives more information about part numbers. |
| 27 | |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 28 | Design |
| 29 | ------ |
| 30 | The STM32MP1 resets in the ROM code of the Cortex-A7. |
| 31 | The primary boot core (core 0) executes the boot sequence while |
| 32 | secondary boot core (core 1) is kept in a holding pen loop. |
| 33 | The ROM code boot sequence loads the TF-A binary image from boot device |
| 34 | to embedded SRAM. |
| 35 | |
| 36 | The TF-A image must be properly formatted with a STM32 header structure |
| 37 | for ROM code is able to load this image. |
| 38 | Tool stm32image can be used to prepend this header to the generated TF-A binary. |
| 39 | |
Yann Gautier | 9730da0 | 2021-02-12 18:04:23 +0100 | [diff] [blame] | 40 | Boot with FIP |
| 41 | ~~~~~~~~~~~~~ |
| 42 | The use of FIP is now the recommended way to boot STM32MP1 platform. |
| 43 | Only BL2 (with STM32 header) is loaded by ROM code. The other binaries are |
| 44 | inside the FIP binary: BL32 (SP_min or OP-TEE), U-Boot and their respective |
| 45 | device tree blobs. |
| 46 | |
| 47 | STM32IMAGE bootchain |
| 48 | ~~~~~~~~~~~~~~~~~~~~ |
| 49 | Although still supported, this way of booting is not recommended. |
| 50 | Pease use FIP instead. |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 51 | At compilation step, BL2, BL32 and DTB file are linked together in a single |
| 52 | binary. The stm32image tool is also generated and the header is added to TF-A |
| 53 | binary. This binary file with header is named tf-a-stm32mp157c-ev1.stm32. |
| 54 | It can then be copied in the first partition of the boot device. |
| 55 | |
| 56 | |
| 57 | Memory mapping |
| 58 | ~~~~~~~~~~~~~~ |
| 59 | |
| 60 | :: |
| 61 | |
| 62 | 0x00000000 +-----------------+ |
| 63 | | | ROM |
| 64 | 0x00020000 +-----------------+ |
| 65 | | | |
| 66 | | ... | |
| 67 | | | |
| 68 | 0x2FFC0000 +-----------------+ \ |
Yann Gautier | 9730da0 | 2021-02-12 18:04:23 +0100 | [diff] [blame] | 69 | | BL32 DTB | | |
| 70 | 0x2FFC5000 +-----------------+ | |
| 71 | | BL32 | | |
| 72 | 0x2FFDF000 +-----------------+ | |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 73 | | ... | | |
Yann Gautier | 9730da0 | 2021-02-12 18:04:23 +0100 | [diff] [blame] | 74 | 0x2FFE3000 +-----------------+ | |
| 75 | | BL2 DTB | | Embedded SRAM |
| 76 | 0x2FFEA000 +-----------------+ | |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 77 | | BL2 | | |
Yann Gautier | 9730da0 | 2021-02-12 18:04:23 +0100 | [diff] [blame] | 78 | 0x2FFFF000 +-----------------+ | |
| 79 | | SCMI mailbox | | |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 80 | 0x30000000 +-----------------+ / |
| 81 | | | |
| 82 | | ... | |
| 83 | | | |
| 84 | 0x40000000 +-----------------+ |
| 85 | | | |
| 86 | | | Devices |
| 87 | | | |
| 88 | 0xC0000000 +-----------------+ \ |
| 89 | | | | |
| 90 | 0xC0100000 +-----------------+ | |
| 91 | | BL33 | | Non-secure RAM (DDR) |
| 92 | | ... | | |
| 93 | | | | |
| 94 | 0xFFFFFFFF +-----------------+ / |
| 95 | |
| 96 | |
| 97 | Boot sequence |
| 98 | ~~~~~~~~~~~~~ |
| 99 | |
| 100 | ROM code -> BL2 (compiled with BL2_AT_EL3) -> BL32 (SP_min) -> BL33 (U-Boot) |
| 101 | |
Yann Gautier | b3386f7 | 2019-04-19 09:41:01 +0200 | [diff] [blame] | 102 | or if Op-TEE is used: |
| 103 | |
| 104 | ROM code -> BL2 (compiled with BL2_AT_EL3) -> OP-TEE -> BL33 (U-Boot) |
| 105 | |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 106 | |
| 107 | Build Instructions |
| 108 | ------------------ |
Lionel Debieve | 4066c90 | 2019-10-17 15:12:13 +0200 | [diff] [blame] | 109 | Boot media(s) supported by BL2 must be specified in the build command. |
| 110 | Available storage medias are: |
Yann Gautier | 2392913 | 2021-02-15 17:13:23 +0100 | [diff] [blame] | 111 | |
Lionel Debieve | 4066c90 | 2019-10-17 15:12:13 +0200 | [diff] [blame] | 112 | - ``STM32MP_SDMMC`` |
| 113 | - ``STM32MP_EMMC`` |
| 114 | - ``STM32MP_RAW_NAND`` |
| 115 | - ``STM32MP_SPI_NAND`` |
| 116 | - ``STM32MP_SPI_NOR`` |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 117 | |
Yann Gautier | 9730da0 | 2021-02-12 18:04:23 +0100 | [diff] [blame] | 118 | Boot with FIP |
| 119 | ~~~~~~~~~~~~~ |
| 120 | You need to build BL2, BL32 (SP_min or OP-TEE) and BL33 (U-Boot) before building FIP binary. |
| 121 | |
| 122 | U-Boot |
| 123 | ______ |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 124 | |
| 125 | .. code:: bash |
| 126 | |
Yann Gautier | b4ddd30 | 2018-10-24 10:50:12 +0200 | [diff] [blame] | 127 | cd <u-boot_directory> |
Yann Gautier | b7168ee | 2019-05-20 11:50:18 +0200 | [diff] [blame] | 128 | make stm32mp15_trusted_defconfig |
Yann Gautier | 969be34 | 2019-02-20 17:34:16 +0100 | [diff] [blame] | 129 | make DEVICE_TREE=stm32mp157c-ev1 all |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 130 | |
Yann Gautier | 9730da0 | 2021-02-12 18:04:23 +0100 | [diff] [blame] | 131 | OP-TEE (optional) |
| 132 | _________________ |
Yann Gautier | 2392913 | 2021-02-15 17:13:23 +0100 | [diff] [blame] | 133 | |
Yann Gautier | b3386f7 | 2019-04-19 09:41:01 +0200 | [diff] [blame] | 134 | .. code:: bash |
| 135 | |
Lionel Debieve | 4066c90 | 2019-10-17 15:12:13 +0200 | [diff] [blame] | 136 | cd <optee_directory> |
Yann Gautier | 9730da0 | 2021-02-12 18:04:23 +0100 | [diff] [blame] | 137 | make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm PLATFORM=stm32mp1 \ |
| 138 | CFG_EMBED_DTB_SOURCE_FILE=stm32mp157c-ev1.dts |
| 139 | |
| 140 | |
| 141 | TF-A BL32 (SP_min) |
| 142 | __________________ |
| 143 | If you choose not to use OP-TEE, you can use TF-A SP_min. |
| 144 | To build TF-A BL32, and its device tree file: |
| 145 | |
| 146 | .. code:: bash |
| 147 | |
| 148 | make CROSS_COMPILE=arm-none-eabi- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ |
| 149 | AARCH32_SP=sp_min DTB_FILE_NAME=stm32mp157c-ev1.dtb bl32 dtbs |
| 150 | |
| 151 | TF-A BL2 |
| 152 | ________ |
| 153 | To build TF-A BL2 with its STM32 header for SD-card boot: |
| 154 | |
| 155 | .. code:: bash |
| 156 | |
| 157 | make CROSS_COMPILE=arm-none-eabi- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ |
| 158 | DTB_FILE_NAME=stm32mp157c-ev1.dtb STM32MP_SDMMC=1 |
| 159 | |
| 160 | For other boot devices, you have to replace STM32MP_SDMMC in the previous command |
| 161 | with the desired device flag. |
| 162 | |
| 163 | This BL2 is independent of the BL32 used (SP_min or OP-TEE) |
| 164 | |
| 165 | |
| 166 | FIP |
| 167 | ___ |
| 168 | With BL32 SP_min: |
| 169 | |
| 170 | .. code:: bash |
| 171 | |
| 172 | make CROSS_COMPILE=arm-none-eabi- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ |
| 173 | AARCH32_SP=sp_min \ |
| 174 | DTB_FILE_NAME=stm32mp157c-ev1.dtb \ |
| 175 | BL33=<u-boot_directory>/u-boot-nodtb.bin \ |
| 176 | BL33_CFG=<u-boot_directory>/u-boot.dtb \ |
| 177 | fip |
| 178 | |
| 179 | With OP-TEE: |
| 180 | |
| 181 | .. code:: bash |
| 182 | |
| 183 | make CROSS_COMPILE=arm-none-eabi- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ |
| 184 | DTB_FILE_NAME=stm32mp157c-ev1.dtb \ |
| 185 | BL33=<u-boot_directory>/u-boot-nodtb.bin \ |
| 186 | BL33_CFG=<u-boot_directory>/u-boot.dtb \ |
| 187 | BL32=<optee_directory>/tee-header_v2.bin \ |
| 188 | BL32_EXTRA1=<optee_directory>/tee-pager_v2.bin |
| 189 | BL32_EXTRA2=<optee_directory>/tee-pageable_v2.bin |
| 190 | fip |
| 191 | |
| 192 | |
| 193 | STM32IMAGE bootchain |
| 194 | ~~~~~~~~~~~~~~~~~~~~ |
| 195 | You need to add the following flag to the make command: |
| 196 | ``STM32MP_USE_STM32IMAGE=1`` |
| 197 | |
| 198 | To build with SP_min and support for SD-card boot: |
| 199 | |
| 200 | .. code:: bash |
| 201 | |
| 202 | make CROSS_COMPILE=arm-linux-gnueabihf- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ |
| 203 | AARCH32_SP=sp_min STM32MP_SDMMC=1 DTB_FILE_NAME=stm32mp157c-ev1.dtb \ |
| 204 | STM32MP_USE_STM32IMAGE=1 |
| 205 | |
| 206 | cd <u-boot_directory> |
| 207 | make stm32mp15_trusted_defconfig |
| 208 | make DEVICE_TREE=stm32mp157c-ev1 all |
| 209 | |
| 210 | To build TF-A with OP-TEE support for SD-card boot: |
| 211 | |
| 212 | .. code:: bash |
| 213 | |
| 214 | make CROSS_COMPILE=arm-linux-gnueabihf- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ |
| 215 | AARCH32_SP=optee STM32MP_SDMMC=1 DTB_FILE_NAME=stm32mp157c-ev1.dtb \ |
| 216 | STM32MP_USE_STM32IMAGE=1 |
| 217 | |
| 218 | cd <optee_directory> |
| 219 | make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm PLATFORM=stm32mp1 \ |
| 220 | CFG_EMBED_DTB_SOURCE_FILE=stm32mp157c-ev1.dts |
| 221 | |
Lionel Debieve | 4066c90 | 2019-10-17 15:12:13 +0200 | [diff] [blame] | 222 | cd <u-boot_directory> |
Jan Kiszka | 30576a4 | 2020-10-02 10:07:00 +0200 | [diff] [blame] | 223 | make stm32mp15_trusted_defconfig |
Lionel Debieve | 4066c90 | 2019-10-17 15:12:13 +0200 | [diff] [blame] | 224 | make DEVICE_TREE=stm32mp157c-ev1 all |
| 225 | |
Yann Gautier | b3386f7 | 2019-04-19 09:41:01 +0200 | [diff] [blame] | 226 | |
Yann Gautier | 7511539 | 2018-07-16 14:49:34 +0200 | [diff] [blame] | 227 | The following build options are supported: |
| 228 | |
| 229 | - ``ENABLE_STACK_PROTECTOR``: To enable the stack protection. |
Yann Gautier | b4ddd30 | 2018-10-24 10:50:12 +0200 | [diff] [blame] | 230 | |
| 231 | |
| 232 | Populate SD-card |
| 233 | ---------------- |
| 234 | |
Yann Gautier | 9730da0 | 2021-02-12 18:04:23 +0100 | [diff] [blame] | 235 | Boot with FIP |
| 236 | ~~~~~~~~~~~~~ |
| 237 | The SD-card has to be formatted with GPT. |
| 238 | It should contain at least those partitions: |
| 239 | |
| 240 | - fsbl: to copy the tf-a-stm32mp157c-ev1.stm32 binary (BL2) |
| 241 | - fip: which contains the FIP binary |
| 242 | |
| 243 | Usually, two copies of fsbl are used (fsbl1 and fsbl2) instead of one partition fsbl. |
| 244 | |
| 245 | STM32IMAGE bootchain |
| 246 | ~~~~~~~~~~~~~~~~~~~~ |
| 247 | The SD-card has to be formatted with GPT. |
Yann Gautier | b4ddd30 | 2018-10-24 10:50:12 +0200 | [diff] [blame] | 248 | It should contain at least those partitions: |
| 249 | |
| 250 | - fsbl: to copy the tf-a-stm32mp157c-ev1.stm32 binary |
| 251 | - ssbl: to copy the u-boot.stm32 binary |
| 252 | |
| 253 | Usually, two copies of fsbl are used (fsbl1 and fsbl2) instead of one partition fsbl. |
Yann Gautier | 969be34 | 2019-02-20 17:34:16 +0100 | [diff] [blame] | 254 | |
Jan Kiszka | 30576a4 | 2020-10-02 10:07:00 +0200 | [diff] [blame] | 255 | OP-TEE artifacts go into separate partitions as follows: |
| 256 | |
| 257 | - teeh: tee-header_v2.stm32 |
| 258 | - teed: tee-pageable_v2.stm32 |
| 259 | - teex: tee-pager_v2.stm32 |
| 260 | |
Yann Gautier | 969be34 | 2019-02-20 17:34:16 +0100 | [diff] [blame] | 261 | |
| 262 | .. _STM32MP1 Series: https://www.st.com/en/microcontrollers-microprocessors/stm32mp1-series.html |
Yann Gautier | 26c1067 | 2020-10-13 11:27:05 +0200 | [diff] [blame] | 263 | .. _STM32MP1 part number codification: https://wiki.st.com/stm32mpu/wiki/STM32MP15_microprocessor#Part_number_codification |