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 |
| 31 | 2. STPMU1 |
| 32 | 3. Clock, Reset |
| 33 | |
| 34 | Currently the following boards are supported: |
| 35 | + stm32mp157c-ed1 |
| 36 | |
| 37 | 3. Boot Sequences |
| 38 | ================= |
| 39 | |
| 40 | BootRom => FSBL in SYSRAM => SSBL in DDR => OS (Linux Kernel) |
| 41 | |
| 42 | with FSBL = First Stage Bootloader |
| 43 | SSBL = Second Stage Bootloader |
| 44 | |
| 45 | One boot configuration is supported: |
| 46 | |
| 47 | The "Basic" boot chain (defconfig_file : stm32mp15_basic_defconfig) |
| 48 | BootRom => FSBL = U-Boot SPL => SSBL = U-Boot |
| 49 | SPL has limited security initialisation |
| 50 | U-Boot is running in secure mode and provide a secure monitor to the kernel |
| 51 | with only PSCI support (Power State Coordination Interface defined by ARM) |
| 52 | |
| 53 | All the STM32MP1 board supported by U-Boot use the same generic board |
| 54 | stm32mp1 which support all the bootable devices. |
| 55 | |
| 56 | Each board is configurated only with the associated device tree. |
| 57 | |
| 58 | 4. Device Tree Selection |
| 59 | ======================== |
| 60 | |
| 61 | You need to select the appropriate device tree for your board, |
| 62 | the supported device trees for stm32mp157 are: |
| 63 | |
| 64 | + ed1: daughter board with pmic stpmu1 |
| 65 | dts: stm32mp157c-ed1 |
| 66 | |
| 67 | 5. Build Procedure |
| 68 | ================== |
| 69 | |
| 70 | 1. Install required tools for U-Boot |
| 71 | |
| 72 | + install package needed in U-Boot makefile |
| 73 | (libssl-dev, swig, libpython-dev...) |
| 74 | + install ARMv7 toolchain for 32bit Cortex-A (from Linaro, |
| 75 | from SDK for STM32MP1, or any crosstoolchains from your distribution) |
| 76 | |
| 77 | 2. Set the cross compiler: |
| 78 | |
| 79 | # export CROSS_COMPILE=/path/to/toolchain/arm-linux-gnueabi- |
| 80 | (you can use any gcc cross compiler compatible with U-Boot) |
| 81 | |
| 82 | 3. Select the output directory (optional) |
| 83 | |
| 84 | # export KBUILD_OUTPUT=/path/to/output |
| 85 | |
| 86 | for example: use one output directory for each configuration |
| 87 | # export KBUILD_OUTPUT=stm32mp15_basic |
| 88 | |
| 89 | 4. Configure the U-Boot: |
| 90 | |
| 91 | # make <defconfig_file> |
| 92 | |
| 93 | - For basic boot mode: "stm32mp15_basic_defconfig" |
| 94 | |
| 95 | 5. Configure the device-tree and build the U-Boot image: |
| 96 | |
| 97 | # make DEVICE_TREE=<name> all |
| 98 | |
| 99 | |
| 100 | example: |
| 101 | basic boot on ed1 |
| 102 | # export KBUILD_OUTPUT=stm32mp15_basic |
| 103 | # make stm32mp15_basic_defconfig |
| 104 | # make DEVICE_TREE=stm32mp157c-ed1 all |
| 105 | |
| 106 | 6. Output files |
| 107 | |
| 108 | BootRom and ATF expect binaries with STM32 image header |
| 109 | SPL expects file with U-Boot uImage header |
| 110 | |
| 111 | So in the output directory (selected by KBUILD_OUTPUT), |
| 112 | you can found the needed files: |
| 113 | |
| 114 | + FSBL = spl/u-boot-spl.stm32 |
| 115 | + SSBL = u-boot.img |
| 116 | |
Patrick Delaunay | 8d05010 | 2018-03-20 10:54:52 +0100 | [diff] [blame] | 117 | 6. Switch Setting for Boot Mode |
| 118 | =============================== |
| 119 | |
| 120 | You can select the boot mode, on the board ed1 with the switch SW1 |
| 121 | |
| 122 | ----------------------------------- |
| 123 | Boot Mode BOOT2 BOOT1 BOOT0 |
| 124 | ----------------------------------- |
| 125 | Reserved 0 0 0 |
| 126 | NOR 0 0 1 |
| 127 | SD-Card 1 1 1 |
| 128 | SD-Card 1 0 1 |
| 129 | eMMC 0 1 0 |
| 130 | NAND 0 1 1 |
| 131 | Recovery 1 1 0 |
| 132 | Recovery 0 0 0 |
| 133 | |
| 134 | Recovery is a boot from serial link (UART/USB) and it is used with |
| 135 | STM32CubeProgrammer tool to load executable in RAM and to update the flash |
| 136 | devices available on the board (NOR/NAND/eMMC/SDCARD). |
| 137 | The communication between HOST and board is based on |
| 138 | - for UARTs : the uart protocol used with all MCU STM32 |
| 139 | - for USB : based on USB DFU 1.1 (without the ST extensions used on MCU STM32) |
| 140 | |
| 141 | 7. Prepare an SDCard |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 142 | =================== |
| 143 | |
| 144 | The minimal requirements for STMP32MP1 boot up to U-Boot are: |
| 145 | - GPT partitioning (with gdisk or with sgdisk) |
| 146 | - 2 fsbl partitions, named fsbl1 and fsbl2, size at least 256KiB |
| 147 | - one ssbl partition for U-Boot |
| 148 | |
| 149 | Then the minimal GPT partition is: |
| 150 | ----- ------- --------- ------------- |
| 151 | | Num | Name | Size | Content | |
| 152 | ----- ------- -------- -------------- |
| 153 | | 1 | fsbl1 | 256 KiB | ATF or SPL | |
| 154 | | 2 | fsbl2 | 256 KiB | ATF or SPL | |
| 155 | | 3 | ssbl | enought | U-Boot | |
| 156 | | * | - | - | Boot/Rootfs| |
| 157 | ----- ------- --------- ------------- |
| 158 | |
| 159 | (*) add bootable partition for extlinux.conf |
| 160 | following Generic Distribution |
| 161 | (doc/README.distro for use) |
| 162 | |
| 163 | according the used card reader select the block device |
| 164 | (/dev/sdx or /dev/mmcblk0) |
| 165 | in the next example I use /dev/mmcblk0 |
| 166 | |
| 167 | for example: with gpt table with 128 entries |
| 168 | |
| 169 | a) remove previous formatting |
| 170 | # sgdisk -o /dev/<SDCard dev> |
| 171 | |
| 172 | b) create minimal image |
Patrick Delaunay | 8d05010 | 2018-03-20 10:54:52 +0100 | [diff] [blame] | 173 | # sgdisk --resize-table=128 -a 1 \ |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 174 | -n 1:34:545 -c 1:fsbl1 \ |
| 175 | -n 2:546:1057 -c 2:fsbl2 \ |
| 176 | -n 3:1058:5153 -c 3:ssbl \ |
| 177 | -p /dev/<SDCard dev> |
| 178 | |
Patrick Delaunay | 8d05010 | 2018-03-20 10:54:52 +0100 | [diff] [blame] | 179 | you can add other partition for kernel (rootfs for example) |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 180 | |
| 181 | c) copy the FSBL (2 times) and SSBL file on the correct partition. |
| 182 | in this example in partition 1 to 3 |
| 183 | |
| 184 | for basic boot mode : <SDCard dev> = /dev/mmcblk0 |
| 185 | # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p1 |
| 186 | # dd if=u-boot-spl.stm32 of=/dev/mmcblk0p2 |
| 187 | # dd if=u-boot.img of=/dev/mmcblk0p3 |
| 188 | |
Patrick Delaunay | 8d05010 | 2018-03-20 10:54:52 +0100 | [diff] [blame] | 189 | To boot from SDCard, select BootPinMode = 1 1 1 and reset. |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 190 | |
Patrick Delaunay | 8d05010 | 2018-03-20 10:54:52 +0100 | [diff] [blame] | 191 | 8. Prepare eMMC |
| 192 | =============== |
| 193 | You can use U-Boot to copy binary in eMMC. |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 194 | |
Patrick Delaunay | 8d05010 | 2018-03-20 10:54:52 +0100 | [diff] [blame] | 195 | In the next example, you need to boot from SDCARD and the images (u-boot-spl.stm32, u-boot.img) |
| 196 | are presents on SDCARD (mmc 0) in ext4 partition 4 (bootfs). |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 197 | |
| 198 | To boot from SDCard, select BootPinMode = 1 1 1 and reset. |
| 199 | |
Patrick Delaunay | 8d05010 | 2018-03-20 10:54:52 +0100 | [diff] [blame] | 200 | Then you update the eMMC with the next U-Boot command : |
| 201 | |
| 202 | a) prepare GPT on eMMC, |
| 203 | example with 2 partitions, bootfs and roots: |
| 204 | |
| 205 | # setenv emmc_part "name=ssbl,size=2MiB;name=bootfs,type=linux,bootable,size=64MiB;name=rootfs,type=linux,size=512" |
| 206 | # gpt write mmc 1 ${emmc_part} |
| 207 | |
| 208 | b) copy SPL on eMMC on firts boot partition |
| 209 | (SPL max size is 256kB, with LBA 512, 0x200) |
| 210 | |
| 211 | # ext4load mmc 0:4 0xC0000000 u-boot-spl.stm32 |
| 212 | # mmc dev 1 |
| 213 | # mmc partconf 1 1 1 1 |
| 214 | # mmc write ${fileaddr} 0 200 |
| 215 | # mmc partconf 1 1 1 0 |
| 216 | |
| 217 | b) copy U-Boot in first GPT partition of eMMC |
| 218 | |
| 219 | # ext4load mmc 0:4 0xC0000000 u-boot.img |
| 220 | # mmc dev 1 |
| 221 | # part start mmc 1 1 partstart |
| 222 | # part size mmc 1 1 partsize |
| 223 | # mmc write ${fileaddr} ${partstart} ${partsize} |
| 224 | |
| 225 | To boot from eMMC, select BootPinMode = 0 1 0 and reset. |