Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2018 STMicroelectronics - All Rights Reserved |
| 3 | # |
| 4 | # SPDX-License-Identifier: GPL-2.0+ BSD-3-Clause |
| 5 | # |
| 6 | |
| 7 | U-Boot on STMicroelectronics STM32MP1 |
| 8 | ====================================== |
| 9 | |
| 10 | 1. Summary |
| 11 | ========== |
| 12 | This is a quick instruction for setup stm32mp1 boards. |
| 13 | |
| 14 | 2. Supported devices |
| 15 | ==================== |
| 16 | U-Boot supports one STMP32MP1 SoCs: STM32MP157 |
| 17 | |
| 18 | The STM32MP157 is a Cortex-A MPU aimed at various applications. |
| 19 | It 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 | |
| 26 | Everything is supported in Linux but U-Boot is limited to: |
| 27 | 1. UART |
| 28 | 2. SDCard/MMC controller (SDMMC) |
| 29 | |
| 30 | And the necessary drivers |
| 31 | 1. I2C |
| 32 | 2. STPMU1 |
| 33 | 3. Clock, Reset |
| 34 | |
| 35 | Currently the following boards are supported: |
| 36 | + stm32mp157c-ed1 |
| 37 | |
| 38 | 3. Boot Sequences |
| 39 | ================= |
| 40 | |
| 41 | BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel) |
| 42 | |
| 43 | with FSBL = First Stage Bootloader |
| 44 | SSBL = Second Stage Bootloader |
| 45 | |
| 46 | One 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 | |
| 54 | All the STM32MP1 board supported by U-Boot use the same generic board |
| 55 | stm32mp1 which support all the bootable devices. |
| 56 | |
| 57 | Each board is configurated only with the associated device tree. |
| 58 | |
| 59 | 4. Device Tree Selection |
| 60 | ======================== |
| 61 | |
| 62 | You need to select the appropriate device tree for your board, |
| 63 | the supported device trees for stm32mp157 are: |
| 64 | |
| 65 | + ed1: daughter board with pmic stpmu1 |
| 66 | dts: stm32mp157c-ed1 |
| 67 | |
| 68 | 5. Build Procedure |
| 69 | ================== |
| 70 | |
| 71 | 1. 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 | |
| 78 | 2. 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 | |
| 83 | 3. 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 | |
| 90 | 4. Configure the U-Boot: |
| 91 | |
| 92 | # make <defconfig_file> |
| 93 | |
| 94 | - For basic boot mode: "stm32mp15_basic_defconfig" |
| 95 | |
| 96 | 5. 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 | |
| 107 | 6. 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 | |
Patrick Delaunay | 0ed232b | 2018-03-20 10:54:52 +0100 | [diff] [blame^] | 118 | 6. Switch Setting for Boot Mode |
| 119 | =============================== |
| 120 | |
| 121 | You can select the boot mode, on the board ed1 with the switch SW1 |
| 122 | |
| 123 | ----------------------------------- |
| 124 | Boot Mode BOOT2 BOOT1 BOOT0 |
| 125 | ----------------------------------- |
| 126 | Reserved 0 0 0 |
| 127 | NOR 0 0 1 |
| 128 | SD-Card 1 1 1 |
| 129 | SD-Card 1 0 1 |
| 130 | eMMC 0 1 0 |
| 131 | NAND 0 1 1 |
| 132 | Recovery 1 1 0 |
| 133 | Recovery 0 0 0 |
| 134 | |
| 135 | Recovery is a boot from serial link (UART/USB) and it is used with |
| 136 | STM32CubeProgrammer tool to load executable in RAM and to update the flash |
| 137 | devices available on the board (NOR/NAND/eMMC/SDCARD). |
| 138 | The communication between HOST and board is based on |
| 139 | - for UARTs : the uart protocol used with all MCU STM32 |
| 140 | - for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32) |
| 141 | |
| 142 | 7. Prepare an SDCard |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 143 | =================== |
| 144 | |
| 145 | The minimal requirements for STMP32MP1 boot up to U-Boot are: |
| 146 | - GPT partitioning (with gdisk or with sgdisk) |
| 147 | - 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB |
| 148 | - one ssbl partition for U-Boot |
| 149 | |
| 150 | Then the minimal GPT partition is: |
| 151 | ----- ------- --------- ------------- |
| 152 | | Num | Name | Size | Content | |
| 153 | ----- ------- -------- -------------- |
| 154 | | 1 | fsbl1 | 256 KiB | ATF or SPL | |
| 155 | | 2 | fsbl2 | 256 KiB | ATF or SPL | |
| 156 | | 3 | ssbl | enought | U-Boot | |
| 157 | | * | - | - | Boot/Rootfs| |
| 158 | ----- ------- --------- ------------- |
| 159 | |
| 160 | (*) add bootable partition for extlinux.conf |
| 161 | following Generic Distribution |
| 162 | (doc/README.distro for use) |
| 163 | |
| 164 | according the used card reader select the block device |
| 165 | (/dev/sdx or /dev/mmcblk0) |
| 166 | in the next example I use /dev/mmcblk0 |
| 167 | |
| 168 | for example: with gpt table with 128 entries |
| 169 | |
| 170 | a) remove previous formatting |
| 171 | # sgdisk -o /dev/<SDCard dev> |
| 172 | |
| 173 | b) create minimal image |
Patrick Delaunay | 0ed232b | 2018-03-20 10:54:52 +0100 | [diff] [blame^] | 174 | # sgdisk --resize-table=128 -a 1 \ |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 175 | -n 1:34:545 -c 1:fsbl1 \ |
| 176 | -n 2:546:1057 -c 2:fsbl2 \ |
| 177 | -n 3:1058:5153 -c 3:ssbl \ |
| 178 | -p /dev/<SDCard dev> |
| 179 | |
Patrick Delaunay | 0ed232b | 2018-03-20 10:54:52 +0100 | [diff] [blame^] | 180 | you can add other partition for kernel (rootfs for example) |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 181 | |
| 182 | c) copy the FSBL (2 times) and SSBL file on the correct partition. |
| 183 | in this example in partition 1 to 3 |
| 184 | |
| 185 | for basic boot mode : <SDCard dev> = /dev/mmcblk0 |
| 186 | # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1 |
| 187 | # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2 |
| 188 | # dd if=u-boot.img of=/dev/mmcblk0p3 |
| 189 | |
Patrick Delaunay | 0ed232b | 2018-03-20 10:54:52 +0100 | [diff] [blame^] | 190 | To boot from SDCard, select BootPinMode = 1 1 1 and reset. |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 191 | |
Patrick Delaunay | 0ed232b | 2018-03-20 10:54:52 +0100 | [diff] [blame^] | 192 | 8. Prepare eMMC |
| 193 | =============== |
| 194 | You can use U-Boot to copy binary in eMMC. |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 195 | |
Patrick Delaunay | 0ed232b | 2018-03-20 10:54:52 +0100 | [diff] [blame^] | 196 | In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img) |
| 197 | are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs). |
Patrick Delaunay | f8598d9 | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 198 | |
| 199 | To boot from SDCard, select BootPinMode = 1 1 1 and reset. |
| 200 | |
Patrick Delaunay | 0ed232b | 2018-03-20 10:54:52 +0100 | [diff] [blame^] | 201 | Then you update the eMMC with the next U-Boot command : |
| 202 | |
| 203 | a) prepare GPT on eMMC, |
| 204 | example with 2 partitions, bootfs and roots: |
| 205 | |
| 206 | # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512" |
| 207 | # gpt write mmc 1 ${emmc_part} |
| 208 | |
| 209 | b) copy SPL on eMMC on firts boot partition |
| 210 | (SPL max size is 256kB, with LBA 512, 0x200) |
| 211 | |
| 212 | # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32 |
| 213 | # mmc dev 1 |
| 214 | # mmc partconf 1 1 1 1 |
| 215 | # mmc write ${fileaddr} 0 200 |
| 216 | # mmc partconf 1 1 1 0 |
| 217 | |
| 218 | b) copy U-Boot in first GPT partition of eMMC |
| 219 | |
| 220 | # ext4load mmc 0:4 0xC0000000 u-boot.img |
| 221 | # mmc dev 1 |
| 222 | # part start mmc 1 1 partstart |
| 223 | # part size mmc 1 1 partsize |
| 224 | # mmc write ${fileaddr} ${partstart} ${partsize} |
| 225 | |
| 226 | To boot from eMMC, select BootPinMode = 0 1 0 and reset. |