1# 2# Copyright (C) 2018 STMicroelectronics - All Rights Reserved 3# 4# SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause 5# 6 7U-Boot on STMicroelectronics STM32MP1 8====================================== 9 101. Summary 11========== 12This is a quick instruction for setup stm32mp1 boards. 13 142. Supported devices 15==================== 16U-Boot supports one STMP32MP1 SoCs: STM32MP157 17 18The STM32MP157 is a Cortex-A MPU aimed at various applications. 19It features: 20- Dual core Cortex-A7 application core 21- 2D/3D image composition with GPU 22- Standard memories interface support 23- Standard connectivity, widely inherited from the STM32 MCU family 24- Comprehensive security support 25 26Everything is supported in Linux but U-Boot is limited to: 271. UART 282. SDCard/MMC controller (SDMMC) 29 30And the necessary drivers 311. I2C 322. STPMU1 333. Clock, Reset 34 35Currently the following boards are supported: 36+ stm32mp157c-ed1 37 383. Boot Sequences 39================= 40 41BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel) 42 43with FSBL = First Stage Bootloader 44 SSBL = Second Stage Bootloader 45 46One boot configuration is supported: 47 48 The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig) 49 BootRom => FSBL = U-Boot SPL => SSBL = U-Boot 50 SPL has limited security initialisation 51 U-Boot is running in secure mode and provide a secure monitor to the kernel 52 with only PSCI support (Power State Coordination Interface defined by ARM) 53 54All the STM32MP1 board supported by U-Boot use the same generic board 55stm32mp1 which support all the bootable devices. 56 57Each board is configurated only with the associated device tree. 58 594. Device Tree Selection 60======================== 61 62You need to select the appropriate device tree for your board, 63the supported device trees for stm32mp157 are: 64 65+ ed1: daughter board with pmic stpmu1 66 dts: stm32mp157c-ed1 67 685. Build Procedure 69================== 70 711. Install required tools for U-Boot 72 73 + install package needed in U-Boot makefile 74 (libssl-dev, swig, libpython-dev...) 75 + install ARMv7 toolchain for 32bit Cortex-A (from Linaro, 76 from SDK for STM32MP1, or any crosstoolchains from your distribution) 77 782. Set the cross compiler: 79 80 # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi- 81 (you can use any gcc cross compiler compatible with U-Boot) 82 833. Select the output directory (optional) 84 85 # export KBUILD_OUTPUT=/path/to/output 86 87 for example: use one output directory for each configuration 88 # export KBUILD_OUTPUT=stm32mp15_basic 89 904. Configure the U-Boot: 91 92 # make <defconfig_file> 93 94 - For basic boot mode: "stm32mp15_basic_defconfig" 95 965. Configure the device-tree and build the U-Boot image: 97 98 # make DEVICE_TREE=<name> all 99 100 101 example: 102 basic boot on ed1 103 # export KBUILD_OUTPUT=stm32mp15_basic 104 # make stm32mp15_basic_defconfig 105 # make DEVICE_TREE=stm32mp157c-ed1 all 106 1076. Output files 108 109 BootRom and ATF expect binaries with STM32 image header 110 SPL expects file with U-Boot uImage header 111 112 So in the output directory (selected by KBUILD_OUTPUT), 113 you can found the needed files: 114 115 + FSBL = spl/u-boot-spl.stm32 116 + SSBL = u-boot.img 117 1186. Prepare an SDCard 119=================== 120 121The minimal requirements for STMP32MP1 boot up to U-Boot are: 122- GPT partitioning (with gdisk or with sgdisk) 123- 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB 124- one ssbl partition for U-Boot 125 126Then the minimal GPT partition is: 127 ----- ------- --------- ------------- 128 | Num | Name | Size | Content | 129 ----- ------- -------- -------------- 130 | 1 | fsbl1 | 256 KiB | ATF or SPL | 131 | 2 | fsbl2 | 256 KiB | ATF or SPL | 132 | 3 | ssbl | enought | U-Boot | 133 | * | - | - | Boot/Rootfs| 134 ----- ------- --------- ------------- 135 136(*) add bootable partition for extlinux.conf 137 following Generic Distribution 138 (doc/README.distro for use) 139 140 according the used card reader select the block device 141 (/dev/sdx or /dev/mmcblk0) 142 in the next example I use /dev/mmcblk0 143 144for example: with gpt table with 128 entries 145 146 a) remove previous formatting 147 # sgdisk -o /dev/<SDCard dev> 148 149 b) create minimal image 150 # sgdisk --resize-table=128 -a 1 \ 151 -n 1:34:545 -c 1:fsbl1 \ 152 -n 2:546:1057 -c 2:fsbl2 \ 153 -n 3:1058:5153 -c 3:ssbl \ 154 -p /dev/<SDCard dev> 155 156 you can add other partition for kernel (rootfs) 157 158 c) copy the FSBL (2 times) and SSBL file on the correct partition. 159 in this example in partition 1 to 3 160 161 for basic boot mode : <SDCard dev> = /dev/mmcblk0 162 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1 163 # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2 164 # dd if=u-boot.img of=/dev/mmcblk0p3 165 1667. Switch Setting 167================== 168 169You can select the boot mode, on the board ed1 with the switch SW1 170 171 ----------------------------------- 172 Boot Mode BOOT2 BOOT1 BOOT0 173 ----------------------------------- 174 Reserved 0 0 0 175 NOR 0 0 1 176 SD-Card 1 1 1 177 SD-Card 1 0 1 178 eMMC 0 1 0 179 NAND 0 1 1 180 Recovery 1 1 0 181 Recovery 0 0 0 182 183 184To boot from SDCard, select BootPinMode = 1 1 1 and reset. 185 186Recovery is a boot from serial link (UART/USB) and it is used with 187STM32CubeProgrammer tool to load executable in RAM and to update the flash 188devices available on the board (NOR/NAND/eMMC/SDCARD). 189The communication between HOST and board is based on 190- for UARTs : the uart protocol used with all MCU STM32 191- for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32) 192