Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stm32mp1 AB fixes #713

Merged
merged 5 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion meta-lmp-bsp/conf/machine/include/lmp-machine-custom.inc
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ LINUX_A7_EXAMPLES_DT:remove:stm32mp15-disco = "stm32mp157c-dk2-a7-examples"
CUBE_M4_EXAMPLES_DT:remove:stm32mp15-disco = "stm32mp157c-dk2-m4-examples"
UBOOT_DEVICETREE:stm32mp15-disco = "stm32mp157c-dk2"
SOTA_CLIENT_FEATURES:append:stm32mp15-disco = " ubootenv"
IMAGE_BOOT_FILES:stm32mp15-disco = "boot.itb"
IMAGE_BOOT_FILES:stm32mp15-disco = "boot.itb;boot1.itb boot.itb;boot2.itb"
ricardosalveti marked this conversation as resolved.
Show resolved Hide resolved
EXTRA_IMAGEDEPENDS:remove:stm32mp15-disco = "sdcard-raw-tools-native"
WKS_FILE_DEPENDS:append:stm32mp15-disco = " u-boot-default-script"
PREFERRED_PROVIDER_u-boot-default-script:stm32mp15-disco = "u-boot-ostree-scr-fit"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
From e65bf4316d9963e2a7321421d08520c2479f4e41 Mon Sep 17 00:00:00 2001
From: Igor Opaniuk <[email protected]>
Date: Tue, 5 Jul 2022 14:56:45 +0300
Subject: [PATCH] stm32mp1: check for fip-a/fip-b partitions

Check for FIP-A/FIP-B partitions, if regular FIP is not found.

Signed-off-by: Igor Opaniuk <[email protected]>
Change-Id: If143854b0cc91e7448f724b1d5f9119662555df9
---
plat/st/common/bl2_io_storage.c | 17 ++++++++++++++---
plat/st/stm32mp1/include/platform_def.h | 2 ++
2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/plat/st/common/bl2_io_storage.c b/plat/st/common/bl2_io_storage.c
index 2ea9f627e..7e7f29de5 100644
--- a/plat/st/common/bl2_io_storage.c
+++ b/plat/st/common/bl2_io_storage.c
@@ -404,9 +404,20 @@ int bl2_plat_handle_pre_image_load(unsigned int image_id)
partition_init(GPT_IMAGE_ID);
entry = get_partition_entry(FIP_IMAGE_NAME);
if (entry == NULL) {
- ERROR("Could NOT find the %s partition!\n",
- FIP_IMAGE_NAME);
- return -ENOENT;
+ boot_api_context_t *boot_context =
+ (boot_api_context_t *)stm32mp_get_boot_ctx_address();
+ uint32_t boot_part = boot_context->boot_partition_used_toboot;
+
+ if (boot_part == 1U)
+ entry = get_partition_entry(FIP_IMAGE_NAME_A);
+ else
+ entry = get_partition_entry(FIP_IMAGE_NAME_B);
+
+ if (entry == NULL) {
+ ERROR("Could NOT find the %s partition!\n",
+ FIP_IMAGE_NAME);
+ return -ENOENT;
+ }
}

image_block_spec.offset = entry->start;
diff --git a/plat/st/stm32mp1/include/platform_def.h b/plat/st/stm32mp1/include/platform_def.h
index 4434afa17..39c3b0b48 100644
--- a/plat/st/stm32mp1/include/platform_def.h
+++ b/plat/st/stm32mp1/include/platform_def.h
@@ -40,6 +40,8 @@
#define BL33_BINARY_TYPE U(0x0)
#else /* STM32MP_USE_STM32IMAGE */
#define FIP_IMAGE_NAME "fip"
+#define FIP_IMAGE_NAME_A "fip-a"
+#define FIP_IMAGE_NAME_B "fip-b"
#endif /* STM32MP_USE_STM32IMAGE */

#define STM32MP_PRIMARY_CPU U(0x0)
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

SRC_URI += "file://0001-stm32mp1-save-boot-auth-status-and-partition-info.patch"
SRC_URI += "file://0001-stm32mp1-save-boot-auth-status-and-partition-info.patch \
file://0002-stm32mp1-check-for-fip-a-fip-b-partitions.patch \
"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CONFIG_BOOTCOMMAND="fatload ${boot_device} ${boot_instance}:4 ${scriptaddr} /boot.itb; setenv verify 1; source ${scriptaddr}; reset"
CONFIG_BOOTCOMMAND="fatload ${boot_device} ${boot_instance}:5 ${scriptaddr} /boot${boot_part}.itb; setenv verify 1; source ${scriptaddr}; reset"
CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTDELAY=-2
CONFIG_FIT=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ echo "Using ${fdtfile}"
setenv bootlimit 3
setenv devtype ${boot_device}
setenv devnum ${boot_instance}
setenv rootpart 6

setenv loadaddr ${ramdisk_addr_r}

setenv bootcmd_resetvars 'setenv kernel_image; setenv bootargs; setenv kernel_image2; setenv bootargs2'
setenv bootcmd_otenv 'run bootcmd_resetvars; ext4load ${devtype} ${devnum}:5 ${loadaddr} /boot/loader/uEnv.txt; env import -t ${loadaddr} ${filesize} kernel_image bootargs kernel_image2 bootargs2'
setenv bootcmd_load_f 'ext4load ${devtype} ${devnum}:5 ${loadaddr} "/boot"${kernel_image}'
setenv bootcmd_otenv 'run bootcmd_resetvars; ext4load ${devtype} ${devnum}:${rootpart} ${loadaddr} /boot/loader/uEnv.txt; env import -t ${loadaddr} ${filesize} kernel_image bootargs kernel_image2 bootargs2'
setenv bootcmd_load_f 'ext4load ${devtype} ${devnum}:${rootpart} ${loadaddr} "/boot"${kernel_image}'
setenv bootcmd_run 'bootm ${loadaddr}#conf-${fdtfile}'
setenv bootcmd_rollbackenv 'setenv kernel_image ${kernel_image2}; setenv bootargs ${bootargs2}'
setenv bootcmd_set_rollback 'if test ! "${rollback}" = "1"; then setenv rollback 1; setenv upgrade_available 0; saveenv; fi'
Expand Down
5 changes: 3 additions & 2 deletions meta-lmp-bsp/wic/sdimage-stm32mp157c-dk2-optee-sota.wks.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
# - ----- --------- -------------- ---------------
# ^ ^ ^ ^ ^
# | | | | |
# 0 17kB 529kB 4MB 68MB
# 0 17kB 529kB 8MB 68MB
#
# Warning: the first stage of boot (here fsbl1, fsbl2, fip) MUST be on GPT partition to be detected.
#
part fsbl1 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fsbl1 --sourceparams="file=${DEPLOY_DIR_IMAGE}/arm-trusted-firmware/tf-a-stm32mp157c-dk2-sdcard.stm32" --ondisk mmcblk --part-type 0x8301 --fixed-size 256K --align 17
part fsbl2 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fsbl2 --sourceparams="file=${DEPLOY_DIR_IMAGE}/arm-trusted-firmware/tf-a-stm32mp157c-dk2-sdcard.stm32" --ondisk mmcblk --part-type 0x8301 --fixed-size 256K
part fip --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fip --sourceparams="file=${DEPLOY_DIR_IMAGE}/fip/fip-stm32mp157c-dk2-optee.bin" --ondisk mmcblk --part-type 0x8301 --fixed-size 4096K
part fip1 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fip-a --sourceparams="file=${DEPLOY_DIR_IMAGE}/fip/fip-stm32mp157c-dk2-optee.bin" --ondisk mmcblk --part-type 0x8301 --fixed-size 4096K
part fip2 --source rawcopy --fstype=ext4 --fsoptions "noauto" --part-name=fip-b --sourceparams="file=${DEPLOY_DIR_IMAGE}/fip/fip-stm32mp157c-dk2-optee.bin" --ondisk mmcblk --part-type 0x8301 --fixed-size 4096K

part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 4096 --size 16
part / --source otaimage --ondisk mmcblk --fstype=ext4 --align 4096
Expand Down