stm32mp157c-dk2: non-trusted config and bsp updates
cover stm32mp157c-dk2: non-trusted config and bsp updates
Hi all,
This patch series introduces several updates for stm32mp157c-dk2:
- update BSP: bump Linux, U-Boot, TF-A versions
- introduce basic (non-trusted) image configuration
- remove u-boot config fragment that disables watchdog
The stm32mp157c-dk2 images with updated U-Boot have an issue: they
successully boot only once. Previously I have already attempted to
fix this problem: see
https://patchwork.ozlabs.org/project/buildroot/patch/20210130204456.793098-1-geomatsi at gmail.com/
However previous root cause analysis was not correct. Saving U-Boot environment indeed changes 'ssbl' partition checksum. But this is not the reason of TF-A complaints. In fact U-Boot corrupts its own image when it saves environment at the end of 'ssbl' partition. So it is necessary to reserve space at the end of 'ssbl' partition for both primary and redundant U-Boot environments. For this purpose post-build script is added that appends placeholder for environment to U-Boot image.
Regards,
Sergey
Sergey Matyukevich (4):
configs/stm32mp157c_dk2: bump BSP versions
stm32mp157c_dk2: add non-trusted configuration
stm32mp157c_dk2: remove uboot config fragment
stm32mp157c_dk2: fix U-Boot corruption on the first boot
DEVELOPERS | 4 ++-
.../common/stm32mp157/genimage.cfg.template | 6 ++--
.../common/stm32mp157/post-build.sh | 16 +++++++++
.../common/stm32mp157/post-image.sh | 35 +++++++++++++++----
.../stm32mp157c-dk2/readme.txt | 7 +++-
.../stm32mp157c-dk2/uboot-fragment.config | 1 -
configs/stm32mp157c_dk2_basic_defconfig | 28 +++++++++++++++
...nfig => stm32mp157c_dk2_trusted_defconfig} | 10 +++---
8 files changed, 89 insertions(+), 18 deletions(-)
create mode 100755 board/stmicroelectronics/common/stm32mp157/post-build.sh
delete mode 100644 board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config
create mode 100644 configs/stm32mp157c_dk2_basic_defconfig
rename configs/{stm32mp157c_dk2_defconfig => stm32mp157c_dk2_trusted_defconfig} (80%)Signature · 1 line
2.32.0
PATCH 1/4 configs/stm32mp157c_dk2: bump BSP versions
Update Linux kernel, U-Boot, and TF-A versions.
--- configs/stm32mp157c_dk2_defconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
configs/stm32mp157c_dk2_defconfig +4 -4
@@ -1,11 +1,11 @@ BR2_arm=y BR2_cortex_a7=y -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_8=y +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_12=y BR2_ROOTFS_OVERLAY="board/stmicroelectronics/stm32mp157c-dk2/overlay/" BR2_ROOTFS_POST_IMAGE_SCRIPT="board/stmicroelectronics/common/stm32mp157/post-image.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y -BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.8.13" +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.12.10" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/stmicroelectronics/stm32mp157c-dk2/linux.config" BR2_LINUX_KERNEL_DTS_SUPPORT=y
@@ -17,7 +17,7 @@ BR2_TARGET_ROOTFS_EXT2_SIZE="120M" # BR2_TARGET_ROOTFS_TAR is not set BR2_TARGET_ARM_TRUSTED_FIRMWARE=y BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION=y -BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE="v2.2" +BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE="v2.5" BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="stm32mp1" BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="STM32MP_SDMMC=1 AARCH32_SP=sp_min DTB_FILE_NAME=stm32mp157c-dk2.dtb" BR2_TARGET_ARM_TRUSTED_FIRMWARE_IMAGES="*.stm32"
@@ -25,7 +25,7 @@ BR2_TARGET_ARM_TRUSTED_FIRMWARE_NEEDS_DTC=y BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y BR2_TARGET_UBOOT_CUSTOM_VERSION=y -BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2020.07" +BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2021.04" BR2_TARGET_UBOOT_BOARD_DEFCONFIG="stm32mp15_trusted" BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config" # BR2_TARGET_UBOOT_FORMAT_BIN is not set
Signature · 1 line
2.32.0
Thomas Petazzoni
AppliedPATCH 1/4 configs/stm32mp157c_dk2: bump BSP versions
Quoted 6 lines · On Fri, 2 Jul 2021 00:00:03 +0300 Sergey Matyukevich <[email protected]>…
Update Linux kernel, U-Boot, and TF-A versions.
Signed-off-by Sergey Matyukevich <[email protected]>--- configs/stm32mp157c_dk2_defconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Applied to master, thanks. I guess it would be nice if someone did the same update for the DK1 defconfig.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 2/4 stm32mp157c_dk2: add non-trusted configuration
In reply to Sergey MatyukevichThe stm32mp157 supports two different boot chains. Trusted boot chain uses TF-A firmare as FSBL and U-Boot as SSBL. Basic boot chain uses U-Boot SPL as FSBL and U-Boot as SSBL. Available stm32mp157c_dk2_defconfig provides image with trusted boot chain. This commit renames existing defconfig and adds another defconfig for basic boot chain. Genimage template and post-image script are modified to use appropriate FSBL and SSBL to support both build configurations.
---
DEVELOPERS | 4 ++-
.../common/stm32mp157/genimage.cfg.template | 6 ++--
.../common/stm32mp157/post-image.sh | 35 +++++++++++++++----
.../stm32mp157c-dk2/readme.txt | 7 +++-
configs/stm32mp157c_dk2_basic_defconfig | 28 +++++++++++++++
...nfig => stm32mp157c_dk2_trusted_defconfig} | 0
6 files changed, 68 insertions(+), 12 deletions(-)
create mode 100644 configs/stm32mp157c_dk2_basic_defconfig
rename configs/{stm32mp157c_dk2_defconfig => stm32mp157c_dk2_trusted_defconfig} (100%)DEVELOPERS +3 -1
@@ -2427,6 +2427,8 @@ F: configs/linksprite_pcduino_defconfig F: configs/orangepi_one_defconfig F: configs/orangepi_pc_plus_defconfig F: configs/orangepi_zero_defconfig +F: configs/stm32mp157c_dk2_basic_defconfig +F: configs/stm32mp157c_dk2_trusted_defconfig F: package/armbian-firmware/ F: package/hostapd/ F: package/rtl8189fs/
@@ -2639,7 +2641,7 @@ F: boot/boot-wrapper-aarch64/ F: boot/grub2/ F: boot/gummiboot/ F: configs/beaglev_defconfig -F: configs/stm32mp157c_dk2_defconfig +F: configs/stm32mp157c_dk2_trusted_defconfig F: package/android-tools/ F: package/b43-firmware/ F: package/b43-fwcutter/
board/stmicroelectronics/common/stm32mp157/genimage.cfg.template +3 -3
@@ -4,15 +4,15 @@ image sdcard.img { } partition fsbl1 { - image = "%ATFBIN%" + image = "%FSBL%" } partition fsbl2 { - image = "%ATFBIN%" + image = "%FSBL%" } partition ssbl { - image = "u-boot.stm32" + image = "%SSBL%" } partition rootfs {
board/stmicroelectronics/common/stm32mp157/post-image.sh +28 -7
@@ -1,14 +1,17 @@ #!/usr/bin/env bash # -# atf_image extracts the ATF binary image from DTB_FILE_NAME that appears in -# BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES in ${BR_CONFIG}, -# then prints the corresponding file name for the genimage -# configuration file +# fsbl_image extracts the the first stage bootloader then prints the corresponding file name +# for the genimage configuration file: +# - for trusted configuration this is the name of ATF binary image from DTB_FILE_NAME +# that appears in BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES in ${BR2_CONFIG} +# - for basic configuration this is the name of SPL binary specified in +# BR2_TARGET_UBOOT_SPL_NAME in ${BR2_CONFIG} # -atf_image() +fsbl_image() { local ATF_VARIABLES="$(sed -n 's/^BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="\([\/a-zA-Z0-9_=. \-]*\)"$/\1/p' ${BR2_CONFIG})" + local SPL_NAME=$(sed -n 's/^BR2_TARGET_UBOOT_SPL_NAME="\(.*\)"$/\1/p' ${BR2_CONFIG}) if grep -Eq "DTB_FILE_NAME=stm32mp157c-dk2.dtb" <<< ${ATF_VARIABLES}; then echo "tf-a-stm32mp157c-dk2.stm32"
@@ -16,16 +19,34 @@ atf_image() echo "tf-a-stm32mp157a-dk1.stm32" elif grep -Eq "DTB_FILE_NAME=stm32mp157a-avenger96.dtb" <<< ${ATF_VARIABLES}; then echo "tf-a-stm32mp157a-avenger96.stm32" + else + echo "${SPL_NAME}" + fi +} + +# +# ssbl_image extracts the the second stage bootloader then prints the corresponding file name +# for the genimage configuration file: +# - for trusted configuration this is u-boot.stm32 +# - for basic configuration this is u-boot.img +# +ssbl_image() +{ + if grep -Eq "^BR2_TARGET_UBOOT_FORMAT_STM32=y$" ${BR2_CONFIG}; then + echo "u-boot.stm32" + elif grep -Eq "^BR2_TARGET_UBOOT_FORMAT_IMG=y$" ${BR2_CONFIG}; then + echo "u-boot.img" fi } main() { - local ATFBIN="$(atf_image)" local GENIMAGE_CFG="$(mktemp --suffix genimage.cfg)" local GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" + local FSBL="$(fsbl_image)" + local SSBL="$(ssbl_image)" - sed -e "s/%ATFBIN%/${ATFBIN}/" \ + sed -e "s/%FSBL%/${FSBL}/" -e "s/%SSBL%/${SSBL}/" \ board/stmicroelectronics/common/stm32mp157/genimage.cfg.template > ${GENIMAGE_CFG} support/scripts/genimage.sh -c ${GENIMAGE_CFG}
board/stmicroelectronics/stm32mp157c-dk2/readme.txt +6 -1
@@ -11,7 +11,12 @@ platform: How to build ============ - $ make stm32mp157c_dk2_defconfig +Build 'basic' image: + $ make stm32mp157c_dk2_basic_defconfig + $ make + +Build 'trusted' image: + $ make stm32mp157c_dk2_trusted_defconfig $ make How to write the microSD card
configs/stm32mp157c_dk2_basic_defconfig new file +28 -0
@@ -0,0 +1,28 @@ +BR2_arm=y +BR2_cortex_a7=y +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_12=y +BR2_ROOTFS_OVERLAY="board/stmicroelectronics/stm32mp157c-dk2/overlay/" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/stmicroelectronics/common/stm32mp157/post-image.sh" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.12.10" +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/stmicroelectronics/stm32mp157c-dk2/linux.config" +BR2_LINUX_KERNEL_DTS_SUPPORT=y +BR2_LINUX_KERNEL_INTREE_DTS_NAME="stm32mp157c-dk2" +BR2_LINUX_KERNEL_INSTALL_TARGET=y +BR2_TARGET_ROOTFS_EXT2=y +BR2_TARGET_ROOTFS_EXT2_4=y +BR2_TARGET_ROOTFS_EXT2_SIZE="120M" +# BR2_TARGET_ROOTFS_TAR is not set +BR2_TARGET_UBOOT=y +BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y +BR2_TARGET_UBOOT_CUSTOM_VERSION=y +BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2021.04" +BR2_TARGET_UBOOT_BOARD_DEFCONFIG="stm32mp15_basic" +BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config" +BR2_TARGET_UBOOT_FORMAT_IMG=y +BR2_TARGET_UBOOT_SPL=y +BR2_TARGET_UBOOT_SPL_NAME="u-boot-spl.stm32" +BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS="DEVICE_TREE=stm32mp157c-dk2" +BR2_PACKAGE_HOST_GENIMAGE=y
configs/stm32mp157c_dk2_trusted_defconfig renamed from configs/stm32mp157c_dk2_defconfig +0 -0
Signature · 1 line
2.32.0
PATCH 2/4 stm32mp157c_dk2: add non-trusted configuration
Quoted 7 lines · On Fri, 2 Jul 2021 00:00:04 +0300 Sergey Matyukevich <[email protected]>…
The stm32mp157 supports two different boot chains. Trusted boot chain uses TF-A firmare as FSBL and U-Boot as SSBL. Basic boot chain uses U-Boot SPL as FSBL and U-Boot as SSBL. Available
stm32mp157c_dk2_defconfigprovides image with trusted boot chain. This commit renames existing defconfig and adds another defconfig for basic boot chain. Genimage template and post-image script are modified to use appropriate FSBL and SSBL to support both build configurations.
Could you comment on the motivation to also support the non-trusted boot chain? ST is no longer supporting the non-trusted configuration. Of course, while we don't have to strictly follow vendor-defined rules/decision, there's the question of what is the benefit of the non-trusted version, and if it's worth the effort having support for both configurations as Buildroot defconfigs.
Thomas
Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 2/4 stm32mp157c_dk2: add non-trusted configuration
Hello Thomas,
Quoted 8 lines
Quoted 7 lines
The stm32mp157 supports two different boot chains. Trusted boot chain uses TF-A firmare as FSBL and U-Boot as SSBL. Basic boot chain uses U-Boot SPL as FSBL and U-Boot as SSBL. Available
stm32mp157c_dk2_defconfigprovides image with trusted boot chain. This commit renames existing defconfig and adds another defconfig for basic boot chain. Genimage template and post-image script are modified to use appropriate FSBL and SSBL to support both build configurations.
Quoted 6 lines
Could you comment on the motivation to also support the non-trusted boot chain? ST is no longer supporting the non-trusted configuration. Of course, while we don't have to strictly follow vendor-defined rules/decision, there's the question of what is the benefit of the non-trusted version, and if it's worth the effort having support for both configurations as Buildroot defconfigs.
Well, nothing specific. It just occured to me that there are not so many boards supporting both TF-A and SPL boot options. But if vendor no longer supports that configuration, then indeed that effort does not make a lot of sense. I will drop that in v2.
Regards,
Sergey
PATCH 3/4 stm32mp157c_dk2: remove uboot config fragment
In reply to Sergey MatyukevichRunning stm32mp1 watchdog is properly recognized and handled by kernel watchdog framework since Linux v5.6. For details see the Linux commit 85fdc63fe256 ("drivers: watchdog: stm32_iwdg: set WDOG_HW_RUNNING at probe"). So U-Boot config fragment can be safely removed without adding userspace watchdog daemon.
--- board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config | 1 - configs/stm32mp157c_dk2_basic_defconfig | 1 - configs/stm32mp157c_dk2_trusted_defconfig | 1 - 3 files changed, 3 deletions(-) delete mode 100644 board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config
board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config deleted +0 -1
@@ -1 +0,0 @@ -# CONFIG_STM32MP_WATCHDOG is not set
configs/stm32mp157c_dk2_basic_defconfig +0 -1
@@ -20,7 +20,6 @@ BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y BR2_TARGET_UBOOT_CUSTOM_VERSION=y BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2021.04" BR2_TARGET_UBOOT_BOARD_DEFCONFIG="stm32mp15_basic" -BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config" BR2_TARGET_UBOOT_FORMAT_IMG=y BR2_TARGET_UBOOT_SPL=y BR2_TARGET_UBOOT_SPL_NAME="u-boot-spl.stm32"
configs/stm32mp157c_dk2_trusted_defconfig +0 -1
@@ -27,7 +27,6 @@ BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y BR2_TARGET_UBOOT_CUSTOM_VERSION=y BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2021.04" BR2_TARGET_UBOOT_BOARD_DEFCONFIG="stm32mp15_trusted" -BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config" # BR2_TARGET_UBOOT_FORMAT_BIN is not set BR2_TARGET_UBOOT_FORMAT_STM32=y BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS="DEVICE_TREE=stm32mp157c-dk2"
Signature · 1 line
2.32.0
PATCH 4/4 stm32mp157c_dk2: fix U-Boot corruption on the first boot
In reply to Sergey MatyukevichBoth trusted and basic images successfully boot only once. Subsequent boot attempts fail to reach U-Boot. The root cause turns out to be in U-Boot corruption during the first boot. The stm32mp1 U-Boot stores its environment at the end of GPT partition named 'ssbl' since v2020.10-rc2. However Buildroot genimage template for stm32mp157 boards creates 'ssbl' partition w/o extra space for U-Boot primary and redundant environments. Add post-build script that appends placeholder for environment to U-Boot image.
--- .../common/stm32mp157/post-build.sh | 16 ++++++++++++++++ configs/stm32mp157c_dk2_basic_defconfig | 1 + configs/stm32mp157c_dk2_trusted_defconfig | 1 + 3 files changed, 18 insertions(+) create mode 100755 board/stmicroelectronics/common/stm32mp157/post-build.sh
board/stmicroelectronics/common/stm32mp157/post-build.sh new file +16 -0
@@ -0,0 +1,16 @@ +#!/bin/sh + +set -u +set -e + +cd "$BINARIES_DIR" + +dd if=/dev/zero of=env.bin bs=16384 count=1 + +if [ -f u-boot.stm32 ]; then + cat env.bin >> u-boot.stm32 +fi + +if [ -f u-boot.img ]; then + cat env.bin >> u-boot.img +fi
configs/stm32mp157c_dk2_basic_defconfig +1 -0
@@ -2,6 +2,7 @@ BR2_arm=y BR2_cortex_a7=y BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_12=y BR2_ROOTFS_OVERLAY="board/stmicroelectronics/stm32mp157c-dk2/overlay/" +BR2_ROOTFS_POST_BUILD_SCRIPT="board/stmicroelectronics/common/stm32mp157/post-build.sh" BR2_ROOTFS_POST_IMAGE_SCRIPT="board/stmicroelectronics/common/stm32mp157/post-image.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y
configs/stm32mp157c_dk2_trusted_defconfig +1 -0
@@ -2,6 +2,7 @@ BR2_arm=y BR2_cortex_a7=y BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_12=y BR2_ROOTFS_OVERLAY="board/stmicroelectronics/stm32mp157c-dk2/overlay/" +BR2_ROOTFS_POST_BUILD_SCRIPT="board/stmicroelectronics/common/stm32mp157/post-build.sh" BR2_ROOTFS_POST_IMAGE_SCRIPT="board/stmicroelectronics/common/stm32mp157/post-image.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y
Signature · 1 line
2.32.0
PATCH 4/4 stm32mp157c_dk2: fix U-Boot corruption on the first boot
Quoted 10 lines · On Fri, 2 Jul 2021 00:00:06 +0300 Sergey Matyukevich <[email protected]>…
Both trusted and basic images successfully boot only once. Subsequent boot attempts fail to reach U-Boot. The root cause turns out to be in U-Boot corruption during the first boot. The stm32mp1 U-Boot stores its environment at the end of GPT partition named 'ssbl' since v2020.10-rc2. However Buildroot genimage template for stm32mp157 boards creates 'ssbl' partition w/o extra space for U-Boot primary and redundant environments. Add post-build script that appends placeholder for environment to U-Boot image.
Signed-off-by Sergey Matyukevich <[email protected]>
What about making the ssbl partition larger in the genimage configuration file ?
Thomas
Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 4/4 stm32mp157c_dk2: fix U-Boot corruption on the first boot
Hello Thomas,
Quoted 9 lines
Quoted 9 lines
Both trusted and basic images successfully boot only once. Subsequent boot attempts fail to reach U-Boot. The root cause turns out to be in U-Boot corruption during the first boot. The stm32mp1 U-Boot stores its environment at the end of GPT partition named 'ssbl' since v2020.10-rc2. However Buildroot genimage template for stm32mp157 boards creates 'ssbl' partition w/o extra space for U-Boot primary and redundant environments. Add post-build script that appends placeholder for environment to U-Boot image.
Quoted 4 lines
Quoted 1 line
Signed-off-by Sergey Matyukevich <[email protected]>What about making the ssbl partition larger in the genimage configuration file ?
Appending env placeholders looked a bit more ergonomic and future proof to me. But just making 'ssbl' larger also works fine.
Regards,
Sergey