* [Buildroot] [PATCH 1/4] configs/stm32mp157c_dk2: bump BSP versions
2021-07-01 21:00 [Buildroot] [PATCH 0/4] stm32mp157c-dk2: non-trusted config and bsp updates Sergey Matyukevich
@ 2021-07-01 21:00 ` Sergey Matyukevich
2021-07-03 21:32 ` Thomas Petazzoni
2021-07-01 21:00 ` [Buildroot] [PATCH 2/4] stm32mp157c_dk2: add non-trusted configuration Sergey Matyukevich
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Sergey Matyukevich @ 2021-07-01 21:00 UTC (permalink / raw)
To: buildroot
Update Linux kernel, U-Boot, and TF-A versions.
Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
---
configs/stm32mp157c_dk2_defconfig | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/configs/stm32mp157c_dk2_defconfig b/configs/stm32mp157c_dk2_defconfig
index 50d875749b..6fea63d427 100644
--- a/configs/stm32mp157c_dk2_defconfig
+++ b/configs/stm32mp157c_dk2_defconfig
@@ -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
--
2.32.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Buildroot] [PATCH 2/4] stm32mp157c_dk2: add non-trusted configuration
2021-07-01 21:00 [Buildroot] [PATCH 0/4] stm32mp157c-dk2: non-trusted config and bsp updates Sergey Matyukevich
2021-07-01 21:00 ` [Buildroot] [PATCH 1/4] configs/stm32mp157c_dk2: bump BSP versions Sergey Matyukevich
@ 2021-07-01 21:00 ` Sergey Matyukevich
2021-07-03 21:16 ` Thomas Petazzoni
2021-07-01 21:00 ` [Buildroot] [PATCH 3/4] stm32mp157c_dk2: remove uboot config fragment Sergey Matyukevich
2021-07-01 21:00 ` [Buildroot] [PATCH 4/4] stm32mp157c_dk2: fix U-Boot corruption on the first boot Sergey Matyukevich
3 siblings, 1 reply; 10+ messages in thread
From: Sergey Matyukevich @ 2021-07-01 21:00 UTC (permalink / raw)
To: buildroot
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_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.
Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
---
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%)
diff --git a/DEVELOPERS b/DEVELOPERS
index 2a69f88299..11b0c57d8e 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -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/
diff --git a/board/stmicroelectronics/common/stm32mp157/genimage.cfg.template b/board/stmicroelectronics/common/stm32mp157/genimage.cfg.template
index f341c19f2f..88f6eb2785 100644
--- a/board/stmicroelectronics/common/stm32mp157/genimage.cfg.template
+++ b/board/stmicroelectronics/common/stm32mp157/genimage.cfg.template
@@ -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 {
diff --git a/board/stmicroelectronics/common/stm32mp157/post-image.sh b/board/stmicroelectronics/common/stm32mp157/post-image.sh
index 363c3127cf..100e2f58dc 100755
--- a/board/stmicroelectronics/common/stm32mp157/post-image.sh
+++ b/board/stmicroelectronics/common/stm32mp157/post-image.sh
@@ -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}
diff --git a/board/stmicroelectronics/stm32mp157c-dk2/readme.txt b/board/stmicroelectronics/stm32mp157c-dk2/readme.txt
index 8edc3e8bbb..331ffb3f70 100644
--- a/board/stmicroelectronics/stm32mp157c-dk2/readme.txt
+++ b/board/stmicroelectronics/stm32mp157c-dk2/readme.txt
@@ -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
diff --git a/configs/stm32mp157c_dk2_basic_defconfig b/configs/stm32mp157c_dk2_basic_defconfig
new file mode 100644
index 0000000000..13f0a135e1
--- /dev/null
+++ b/configs/stm32mp157c_dk2_basic_defconfig
@@ -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
diff --git a/configs/stm32mp157c_dk2_defconfig b/configs/stm32mp157c_dk2_trusted_defconfig
similarity index 100%
rename from configs/stm32mp157c_dk2_defconfig
rename to configs/stm32mp157c_dk2_trusted_defconfig
--
2.32.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Buildroot] [PATCH 2/4] stm32mp157c_dk2: add non-trusted configuration
2021-07-01 21:00 ` [Buildroot] [PATCH 2/4] stm32mp157c_dk2: add non-trusted configuration Sergey Matyukevich
@ 2021-07-03 21:16 ` Thomas Petazzoni
2021-07-04 15:30 ` Sergey Matyukevich
0 siblings, 1 reply; 10+ messages in thread
From: Thomas Petazzoni @ 2021-07-03 21:16 UTC (permalink / raw)
To: buildroot
On Fri, 2 Jul 2021 00:00:04 +0300
Sergey Matyukevich <geomatsi@gmail.com> wrote:
> 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_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.
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
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] [PATCH 2/4] stm32mp157c_dk2: add non-trusted configuration
2021-07-03 21:16 ` Thomas Petazzoni
@ 2021-07-04 15:30 ` Sergey Matyukevich
0 siblings, 0 replies; 10+ messages in thread
From: Sergey Matyukevich @ 2021-07-04 15:30 UTC (permalink / raw)
To: buildroot
Hello Thomas,
> > 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_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.
>
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] [PATCH 3/4] stm32mp157c_dk2: remove uboot config fragment
2021-07-01 21:00 [Buildroot] [PATCH 0/4] stm32mp157c-dk2: non-trusted config and bsp updates Sergey Matyukevich
2021-07-01 21:00 ` [Buildroot] [PATCH 1/4] configs/stm32mp157c_dk2: bump BSP versions Sergey Matyukevich
2021-07-01 21:00 ` [Buildroot] [PATCH 2/4] stm32mp157c_dk2: add non-trusted configuration Sergey Matyukevich
@ 2021-07-01 21:00 ` Sergey Matyukevich
2021-07-01 21:00 ` [Buildroot] [PATCH 4/4] stm32mp157c_dk2: fix U-Boot corruption on the first boot Sergey Matyukevich
3 siblings, 0 replies; 10+ messages in thread
From: Sergey Matyukevich @ 2021-07-01 21:00 UTC (permalink / raw)
To: buildroot
Running 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.
Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
---
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
diff --git a/board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config b/board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config
deleted file mode 100644
index a278ce9e23..0000000000
--- a/board/stmicroelectronics/stm32mp157c-dk2/uboot-fragment.config
+++ /dev/null
@@ -1 +0,0 @@
-# CONFIG_STM32MP_WATCHDOG is not set
diff --git a/configs/stm32mp157c_dk2_basic_defconfig b/configs/stm32mp157c_dk2_basic_defconfig
index 13f0a135e1..153540ddc1 100644
--- a/configs/stm32mp157c_dk2_basic_defconfig
+++ b/configs/stm32mp157c_dk2_basic_defconfig
@@ -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"
diff --git a/configs/stm32mp157c_dk2_trusted_defconfig b/configs/stm32mp157c_dk2_trusted_defconfig
index 6fea63d427..a4bff897e5 100644
--- a/configs/stm32mp157c_dk2_trusted_defconfig
+++ b/configs/stm32mp157c_dk2_trusted_defconfig
@@ -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"
--
2.32.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Buildroot] [PATCH 4/4] stm32mp157c_dk2: fix U-Boot corruption on the first boot
2021-07-01 21:00 [Buildroot] [PATCH 0/4] stm32mp157c-dk2: non-trusted config and bsp updates Sergey Matyukevich
` (2 preceding siblings ...)
2021-07-01 21:00 ` [Buildroot] [PATCH 3/4] stm32mp157c_dk2: remove uboot config fragment Sergey Matyukevich
@ 2021-07-01 21:00 ` Sergey Matyukevich
2021-07-03 21:31 ` Thomas Petazzoni
3 siblings, 1 reply; 10+ messages in thread
From: Sergey Matyukevich @ 2021-07-01 21:00 UTC (permalink / raw)
To: buildroot
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 <geomatsi@gmail.com>
---
.../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
diff --git a/board/stmicroelectronics/common/stm32mp157/post-build.sh b/board/stmicroelectronics/common/stm32mp157/post-build.sh
new file mode 100755
index 0000000000..5c59a3f6bb
--- /dev/null
+++ b/board/stmicroelectronics/common/stm32mp157/post-build.sh
@@ -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
diff --git a/configs/stm32mp157c_dk2_basic_defconfig b/configs/stm32mp157c_dk2_basic_defconfig
index 153540ddc1..7976b248ad 100644
--- a/configs/stm32mp157c_dk2_basic_defconfig
+++ b/configs/stm32mp157c_dk2_basic_defconfig
@@ -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
diff --git a/configs/stm32mp157c_dk2_trusted_defconfig b/configs/stm32mp157c_dk2_trusted_defconfig
index a4bff897e5..c987a2b66e 100644
--- a/configs/stm32mp157c_dk2_trusted_defconfig
+++ b/configs/stm32mp157c_dk2_trusted_defconfig
@@ -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
--
2.32.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Buildroot] [PATCH 4/4] stm32mp157c_dk2: fix U-Boot corruption on the first boot
2021-07-01 21:00 ` [Buildroot] [PATCH 4/4] stm32mp157c_dk2: fix U-Boot corruption on the first boot Sergey Matyukevich
@ 2021-07-03 21:31 ` Thomas Petazzoni
2021-07-04 15:27 ` Sergey Matyukevich
0 siblings, 1 reply; 10+ messages in thread
From: Thomas Petazzoni @ 2021-07-03 21:31 UTC (permalink / raw)
To: buildroot
On Fri, 2 Jul 2021 00:00:06 +0300
Sergey Matyukevich <geomatsi@gmail.com> wrote:
> 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 <geomatsi@gmail.com>
What about making the ssbl partition larger in the genimage
configuration file ?
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Buildroot] [PATCH 4/4] stm32mp157c_dk2: fix U-Boot corruption on the first boot
2021-07-03 21:31 ` Thomas Petazzoni
@ 2021-07-04 15:27 ` Sergey Matyukevich
0 siblings, 0 replies; 10+ messages in thread
From: Sergey Matyukevich @ 2021-07-04 15:27 UTC (permalink / raw)
To: buildroot
Hello Thomas,
> > 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 <geomatsi@gmail.com>
>
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread