1STMicroelectronics STM32MP1 2=========================== 3 4STM32MP1 is a microprocessor designed by STMicroelectronics 5based on a dual Arm Cortex-A7. 6It is an Armv7-A platform, using dedicated code from TF-A. 7The STM32MP1 chip also embeds a Cortex-M4. 8More information can be found on `STM32MP1 Series`_ page. 9 10 11STM32MP1 Versions 12----------------- 13The 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 19Each 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 26The `STM32MP1 part number codification`_ page gives more information about part numbers. 27 28Design 29------ 30The STM32MP1 resets in the ROM code of the Cortex-A7. 31The primary boot core (core 0) executes the boot sequence while 32secondary boot core (core 1) is kept in a holding pen loop. 33The ROM code boot sequence loads the TF-A binary image from boot device 34to embedded SRAM. 35 36The TF-A image must be properly formatted with a STM32 header structure 37for ROM code is able to load this image. 38Tool stm32image can be used to prepend this header to the generated TF-A binary. 39 40Boot with FIP 41~~~~~~~~~~~~~ 42The use of FIP is now the recommended way to boot STM32MP1 platform. 43Only BL2 (with STM32 header) is loaded by ROM code. The other binaries are 44inside the FIP binary: BL32 (SP_min or OP-TEE), U-Boot and their respective 45device tree blobs. 46 47STM32IMAGE bootchain 48~~~~~~~~~~~~~~~~~~~~ 49Although still supported, this way of booting is not recommended. 50Pease use FIP instead. 51At compilation step, BL2, BL32 and DTB file are linked together in a single 52binary. The stm32image tool is also generated and the header is added to TF-A 53binary. This binary file with header is named tf-a-stm32mp157c-ev1.stm32. 54It can then be copied in the first partition of the boot device. 55 56 57Memory mapping 58~~~~~~~~~~~~~~ 59 60:: 61 62 0x00000000 +-----------------+ 63 | | ROM 64 0x00020000 +-----------------+ 65 | | 66 | ... | 67 | | 68 0x2FFC0000 +-----------------+ \ 69 | BL32 DTB | | 70 0x2FFC5000 +-----------------+ | 71 | BL32 | | 72 0x2FFDF000 +-----------------+ | 73 | ... | | 74 0x2FFE3000 +-----------------+ | 75 | BL2 DTB | | Embedded SRAM 76 0x2FFEA000 +-----------------+ | 77 | BL2 | | 78 0x2FFFF000 +-----------------+ | 79 | SCMI mailbox | | 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 97Boot sequence 98~~~~~~~~~~~~~ 99 100ROM code -> BL2 (compiled with BL2_AT_EL3) -> BL32 (SP_min) -> BL33 (U-Boot) 101 102or if Op-TEE is used: 103 104ROM code -> BL2 (compiled with BL2_AT_EL3) -> OP-TEE -> BL33 (U-Boot) 105 106 107Build Instructions 108------------------ 109Boot media(s) supported by BL2 must be specified in the build command. 110Available storage medias are: 111 112- ``STM32MP_SDMMC`` 113- ``STM32MP_EMMC`` 114- ``STM32MP_RAW_NAND`` 115- ``STM32MP_SPI_NAND`` 116- ``STM32MP_SPI_NOR`` 117 118Serial boot devices: 119 120- ``STM32MP_UART_PROGRAMMER`` 121- ``STM32MP_USB_PROGRAMMER`` 122 123 124Other configuration flags: 125 126- | ``DTB_FILE_NAME``: to precise board device-tree blob to be used. 127 | Default: stm32mp157c-ev1.dtb 128- | ``STM32MP_EARLY_CONSOLE``: to enable early traces before clock driver is setup. 129 | Default: 0 (disabled) 130- | ``STM32_TF_VERSION``: to manage BL2 monotonic counter. 131 | Default: 0 132 133 134Boot with FIP 135~~~~~~~~~~~~~ 136You need to build BL2, BL32 (SP_min or OP-TEE) and BL33 (U-Boot) before building FIP binary. 137 138U-Boot 139______ 140 141.. code:: bash 142 143 cd <u-boot_directory> 144 make stm32mp15_trusted_defconfig 145 make DEVICE_TREE=stm32mp157c-ev1 all 146 147OP-TEE (optional) 148_________________ 149 150.. code:: bash 151 152 cd <optee_directory> 153 make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm PLATFORM=stm32mp1 \ 154 CFG_EMBED_DTB_SOURCE_FILE=stm32mp157c-ev1.dts 155 156 157TF-A BL32 (SP_min) 158__________________ 159If you choose not to use OP-TEE, you can use TF-A SP_min. 160To build TF-A BL32, and its device tree file: 161 162.. code:: bash 163 164 make CROSS_COMPILE=arm-none-eabi- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ 165 AARCH32_SP=sp_min DTB_FILE_NAME=stm32mp157c-ev1.dtb bl32 dtbs 166 167TF-A BL2 168________ 169To build TF-A BL2 with its STM32 header for SD-card boot: 170 171.. code:: bash 172 173 make CROSS_COMPILE=arm-none-eabi- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ 174 DTB_FILE_NAME=stm32mp157c-ev1.dtb STM32MP_SDMMC=1 175 176For other boot devices, you have to replace STM32MP_SDMMC in the previous command 177with the desired device flag. 178 179This BL2 is independent of the BL32 used (SP_min or OP-TEE) 180 181 182FIP 183___ 184With BL32 SP_min: 185 186.. code:: bash 187 188 make CROSS_COMPILE=arm-none-eabi- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ 189 AARCH32_SP=sp_min \ 190 DTB_FILE_NAME=stm32mp157c-ev1.dtb \ 191 BL33=<u-boot_directory>/u-boot-nodtb.bin \ 192 BL33_CFG=<u-boot_directory>/u-boot.dtb \ 193 fip 194 195With OP-TEE: 196 197.. code:: bash 198 199 make CROSS_COMPILE=arm-none-eabi- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ 200 AARCH32_SP=optee \ 201 DTB_FILE_NAME=stm32mp157c-ev1.dtb \ 202 BL33=<u-boot_directory>/u-boot-nodtb.bin \ 203 BL33_CFG=<u-boot_directory>/u-boot.dtb \ 204 BL32=<optee_directory>/tee-header_v2.bin \ 205 BL32_EXTRA1=<optee_directory>/tee-pager_v2.bin 206 BL32_EXTRA2=<optee_directory>/tee-pageable_v2.bin 207 fip 208 209 210STM32IMAGE bootchain 211~~~~~~~~~~~~~~~~~~~~ 212You need to add the following flag to the make command: 213``STM32MP_USE_STM32IMAGE=1`` 214 215To build with SP_min and support for SD-card boot: 216 217.. code:: bash 218 219 make CROSS_COMPILE=arm-linux-gnueabihf- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ 220 AARCH32_SP=sp_min STM32MP_SDMMC=1 DTB_FILE_NAME=stm32mp157c-ev1.dtb \ 221 STM32MP_USE_STM32IMAGE=1 222 223 cd <u-boot_directory> 224 make stm32mp15_trusted_defconfig 225 make DEVICE_TREE=stm32mp157c-ev1 all 226 227To build TF-A with OP-TEE support for SD-card boot: 228 229.. code:: bash 230 231 make CROSS_COMPILE=arm-linux-gnueabihf- PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 \ 232 AARCH32_SP=optee STM32MP_SDMMC=1 DTB_FILE_NAME=stm32mp157c-ev1.dtb \ 233 STM32MP_USE_STM32IMAGE=1 234 235 cd <optee_directory> 236 make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm PLATFORM=stm32mp1 \ 237 CFG_EMBED_DTB_SOURCE_FILE=stm32mp157c-ev1.dts 238 239 cd <u-boot_directory> 240 make stm32mp15_trusted_defconfig 241 make DEVICE_TREE=stm32mp157c-ev1 all 242 243 244The following build options are supported: 245 246- ``ENABLE_STACK_PROTECTOR``: To enable the stack protection. 247 248 249Populate SD-card 250---------------- 251 252Boot with FIP 253~~~~~~~~~~~~~ 254The SD-card has to be formatted with GPT. 255It should contain at least those partitions: 256 257- fsbl: to copy the tf-a-stm32mp157c-ev1.stm32 binary (BL2) 258- fip: which contains the FIP binary 259 260Usually, two copies of fsbl are used (fsbl1 and fsbl2) instead of one partition fsbl. 261 262STM32IMAGE bootchain 263~~~~~~~~~~~~~~~~~~~~ 264The SD-card has to be formatted with GPT. 265It should contain at least those partitions: 266 267- fsbl: to copy the tf-a-stm32mp157c-ev1.stm32 binary 268- ssbl: to copy the u-boot.stm32 binary 269 270Usually, two copies of fsbl are used (fsbl1 and fsbl2) instead of one partition fsbl. 271 272OP-TEE artifacts go into separate partitions as follows: 273 274- teeh: tee-header_v2.stm32 275- teed: tee-pageable_v2.stm32 276- teex: tee-pager_v2.stm32 277 278 279.. _STM32MP1 Series: https://www.st.com/en/microcontrollers-microprocessors/stm32mp1-series.html 280.. _STM32MP1 part number codification: https://wiki.st.com/stm32mpu/wiki/STM32MP15_microprocessor#Part_number_codification 281