README 6.3 KB

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