mirror of
https://git.yoctoproject.org/meta-arm
synced 2026-06-05 02:20:30 +00:00
arm-bsp/tf-m:cs1k: modified mcuboot to use GPT library
Corstone1000 used to use its own implementation of a GPT parser for use in a capsule update. The patches in this commit replace what exists with the generic GPT library, as well as other minor self-explanatory fixes. The wic file has undergone two changes as a result of this: 1. The partition type GUID of each of the four partitions that can be updated by a capsule update must match the GUID of each capsule. This allows for the existing partition to be matched with its updated image. Different machines (e.g. MPS3 vs FVP) have different GUIDs for these images hence the need for separate files. 2. The second bank has been removed from provisioning. Because the library supports dynamic creation of partitions, the second bank no longer needs to be provisioned at build time. However, a small reserved partition is still created above the 32KiB mark to force wic to size the disk as 64KiB and write this into the GPT header for the library to read on initialisation. Finally, the size of bl1_1 is reduced by one of the patches in this commit, so this is also reflected in the recipe. Signed-off-by: Frazer Carsley <frazer.carsley@arm.com> Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
committed by
Jon Mason
parent
5fc4c29db9
commit
1778b36d66
@@ -15,6 +15,8 @@ TFM_PLATFORM_IS_FVP = "TRUE"
|
||||
|
||||
CORSTONE_1000_TYPE = "CORSTONE_1000_TYPE_CORTEX_A35_FVP"
|
||||
|
||||
WKS_FILE:firmware ?= "corstone1000-flash-firmware-fvp.wks.in"
|
||||
|
||||
# testimage config
|
||||
TEST_TARGET = "OEFVPTarget"
|
||||
TEST_TARGET_IP = "127.0.0.1:2222"
|
||||
|
||||
@@ -10,3 +10,5 @@ TFA_TARGET_PLATFORM = "fpga"
|
||||
MACHINE_FEATURES += "coresight"
|
||||
|
||||
CORSTONE_1000_TYPE = "CORSTONE_1000_TYPE_CORTEX_A35_MPS3"
|
||||
|
||||
WKS_FILE:firmware ?= "corstone1000-flash-firmware-mps3.wks.in"
|
||||
|
||||
@@ -52,7 +52,6 @@ IMAGE_FSTYPES += "wic"
|
||||
# Need to clear the suffix so TESTIMAGE_AUTO works
|
||||
IMAGE_NAME_SUFFIX = ""
|
||||
WKS_FILE ?= "efi-disk-no-swap.wks.in"
|
||||
WKS_FILE:firmware ?= "corstone1000-flash-firmware.wks.in"
|
||||
|
||||
# making sure EXTRA_IMAGEDEPENDS will be used while creating the image
|
||||
WKS_FILE_DEPENDS:append = " ${EXTRA_IMAGEDEPENDS}"
|
||||
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
From 9402dd67413e74284bc598225b4c5399fbd1a099 Mon Sep 17 00:00:00 2001
|
||||
From: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Date: Wed, 19 Nov 2025 17:12:13 +0000
|
||||
Subject: [PATCH] plat: cs1k: Fixed formatting errors
|
||||
|
||||
Many of these were tab characters, however the style guide for this repo
|
||||
is clear that spaces shall be used.
|
||||
|
||||
Sometimes the wrong number of spaces was used and that is fixed here as
|
||||
well.
|
||||
|
||||
Change-Id: I4c797d1de9723961eac707476e249062653aece0
|
||||
Signed-off-by: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/49423]
|
||||
---
|
||||
.../target/arm/corstone1000/CMakeLists.txt | 6 +-
|
||||
.../bootloader/mcuboot/tfm_mcuboot_fwu.c | 60 +++++++++----------
|
||||
2 files changed, 33 insertions(+), 33 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt
|
||||
index 993c51591..58edae74e 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/CMakeLists.txt
|
||||
+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt
|
||||
@@ -242,7 +242,7 @@ target_include_directories(platform_bl1_1_interface
|
||||
${PLATFORM_DIR}/ext/target/arm/drivers/usart/pl011
|
||||
$<$<BOOL:${CRYPTO_HW_ACCELERATOR}>:${CMAKE_SOURCE_DIR}/platform/ext/accelerator/interface>
|
||||
${PLATFORM_DIR}/ext/accelerator/cc312/
|
||||
- ${CMAKE_SOURCE_DIR}/lib/fih/inc/
|
||||
+ ${CMAKE_SOURCE_DIR}/lib/fih/inc/
|
||||
)
|
||||
|
||||
target_link_libraries(platform_bl1_1
|
||||
@@ -289,7 +289,7 @@ target_include_directories(platform_bl1_2
|
||||
${PLATFORM_DIR}/ext/target/arm/drivers/flash/n25q256a/
|
||||
${PLATFORM_DIR}/ext/target/arm/drivers/flash/sst26vf064b/
|
||||
${PLATFORM_DIR}/ext/accelerator/cc312/
|
||||
- ${CMAKE_SOURCE_DIR}/interface/include # for psa/error.h
|
||||
+ ${CMAKE_SOURCE_DIR}/interface/include # for psa/error.h
|
||||
)
|
||||
|
||||
#========================= Platform BL2 =======================================#
|
||||
@@ -397,7 +397,7 @@ target_include_directories(platform_bl2
|
||||
${MCUBOOT_PATH}/boot/bootutil/include # for fault_injection_hardening.h only
|
||||
${CMAKE_BINARY_DIR}/bl2/ext/mcuboot # for mcuboot_config.h only
|
||||
$<BUILD_INTERFACE:${BL2_SOURCE}/ext/mcuboot/include>
|
||||
- ${CMAKE_SOURCE_DIR}/interface/include # for psa/error.h
|
||||
+ ${CMAKE_SOURCE_DIR}/interface/include # for psa/error.h
|
||||
)
|
||||
|
||||
#========================= ns_agent_mailbox ===================================#
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
index a458b5478..cff80b755 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
@@ -995,7 +995,7 @@ psa_status_t fwu_metadata_provision(void)
|
||||
static uint8_t get_fwu_image_state(
|
||||
struct fwu_metadata *metadata,
|
||||
struct fwu_private_metadata *priv_metadata,
|
||||
- uint32_t fwu_image_index)
|
||||
+ uint32_t fwu_image_index)
|
||||
{
|
||||
FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
|
||||
@@ -1305,12 +1305,12 @@ psa_status_t corstone1000_fwu_host_ack(void)
|
||||
|
||||
ret = PSA_SUCCESS; /* nothing to be done */
|
||||
|
||||
- for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; i++) {
|
||||
- fmp_set_image_info(&fwu_image[i].image_guid,
|
||||
- priv_metadata.fmp_version[i],
|
||||
- priv_metadata.fmp_last_attempt_version[i],
|
||||
- priv_metadata.fmp_last_attempt_status[i]);
|
||||
- }
|
||||
+ for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; i++) {
|
||||
+ fmp_set_image_info(&fwu_image[i].image_guid,
|
||||
+ priv_metadata.fmp_version[i],
|
||||
+ priv_metadata.fmp_last_attempt_version[i],
|
||||
+ priv_metadata.fmp_last_attempt_status[i]);
|
||||
+ }
|
||||
|
||||
goto out;
|
||||
|
||||
@@ -1322,13 +1322,13 @@ psa_status_t corstone1000_fwu_host_ack(void)
|
||||
|
||||
/* firmware update failed, revert back to previous bank */
|
||||
|
||||
- for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; i++) {
|
||||
+ for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; i++) {
|
||||
if(get_fwu_image_state(&_metadata, &priv_metadata, i) == PSA_FWU_TRIAL) {
|
||||
priv_metadata.fmp_last_attempt_version[i] =
|
||||
_metadata.fw_desc.img_entry[i].img_props[_metadata.active_index].version;
|
||||
|
||||
priv_metadata.fmp_last_attempt_status[i] = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
|
||||
- }
|
||||
+ }
|
||||
}
|
||||
ret = fwu_select_previous(&_metadata, &priv_metadata);
|
||||
|
||||
@@ -1455,14 +1455,14 @@ psa_status_t fwu_stage_nv_counter(enum fwu_nv_counter_index_t index,
|
||||
|
||||
psa_status_t corstone1000_fwu_flash_image(void)
|
||||
{
|
||||
- return PSA_SUCCESS;
|
||||
+ return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
/* Verify if image index is valid or not */
|
||||
bool is_image_index_valid(uint8_t fwu_image_index) {
|
||||
return (fwu_image_index != FWU_FAKE_IMAGE_INDEX &&
|
||||
fwu_image_index != FWU_IMAGE_INDEX_ESRT &&
|
||||
- fwu_image_index < FWU_COMPONENT_NUMBER);
|
||||
+ fwu_image_index < FWU_COMPONENT_NUMBER);
|
||||
}
|
||||
|
||||
static psa_status_t get_esrt_data(struct fwu_esrt_data_wrapper *esrt)
|
||||
@@ -1585,8 +1585,8 @@ static void fmp_header_image_info_init()
|
||||
for (int i=0; i<FWU_COMPONENT_NUMBER; i++)
|
||||
{
|
||||
fmp_header_image_info[i].fmp_hdr_size_recvd = 0;
|
||||
- fmp_header_image_info[i].image_size_recvd = 0;
|
||||
- memset(&fmp_header_image_info[i].fmp_hdr, 0, sizeof(fmp_header_image_info[i].fmp_hdr));
|
||||
+ fmp_header_image_info[i].image_size_recvd = 0;
|
||||
+ memset(&fmp_header_image_info[i].fmp_hdr, 0, sizeof(fmp_header_image_info[i].fmp_hdr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1598,7 +1598,7 @@ static psa_status_t erase_staging_area(struct fwu_metadata* metadata, psa_fwu_co
|
||||
|
||||
if (!is_image_index_valid(component)) {
|
||||
FWU_LOG_MSG("%s: Invalid Component received \n\r", __func__);
|
||||
- return PSA_ERROR_GENERIC_ERROR;
|
||||
+ return PSA_ERROR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
uint32_t active_index = metadata->active_index;
|
||||
@@ -1691,7 +1691,7 @@ psa_status_t parse_fmp_header(psa_fwu_component_t component, const void *block,
|
||||
(sizeof(fmp_header_image_info[component].fmp_hdr) - fmp_header_image_info[component].fmp_hdr_size_recvd));
|
||||
|
||||
fmp_header_image_info[component].fmp_hdr_size_recvd = sizeof(fmp_header_image_info[component].fmp_hdr);
|
||||
- return PSA_SUCCESS;
|
||||
+ return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1738,7 +1738,7 @@ psa_status_t fwu_bootloader_load_image(psa_fwu_component_t component,
|
||||
}
|
||||
if (ret == PSA_SUCCESS) {
|
||||
block_size -= fmp_header_image_info[fwu_image_index].fmp_hdr_size_recvd;
|
||||
- block += fmp_header_image_info[fwu_image_index].fmp_hdr_size_recvd;
|
||||
+ block += fmp_header_image_info[fwu_image_index].fmp_hdr_size_recvd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1774,7 +1774,7 @@ psa_status_t fwu_bootloader_load_image(psa_fwu_component_t component,
|
||||
if (fw_version <=
|
||||
_metadata.fw_desc.img_entry[fwu_image_index].img_props[active_index].version)
|
||||
{
|
||||
- /* Version is extracted from the fmp_payload_header */
|
||||
+ /* Version is extracted from the fmp_payload_header */
|
||||
priv_metadata.fmp_last_attempt_version[fwu_image_index] = fmp_header_image_info[fwu_image_index].fmp_hdr.fw_version;
|
||||
priv_metadata.fmp_last_attempt_status[fwu_image_index] = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
|
||||
private_metadata_write(&priv_metadata);
|
||||
@@ -1785,8 +1785,8 @@ psa_status_t fwu_bootloader_load_image(psa_fwu_component_t component,
|
||||
priv_metadata.fmp_last_attempt_status[fwu_image_index]);
|
||||
|
||||
FWU_LOG_MSG("ERROR: %s: version error\n\r",__func__);
|
||||
- ret = PSA_OPERATION_INCOMPLETE;
|
||||
- goto out;
|
||||
+ ret = PSA_OPERATION_INCOMPLETE;
|
||||
+ goto out;
|
||||
}
|
||||
|
||||
if (active_index == BANK_0) {
|
||||
@@ -1828,7 +1828,7 @@ psa_status_t fwu_bootloader_load_image(psa_fwu_component_t component,
|
||||
priv_metadata.fmp_last_attempt_version[fwu_image_index],
|
||||
priv_metadata.fmp_last_attempt_status[fwu_image_index]);
|
||||
ret = PSA_OPERATION_INCOMPLETE;
|
||||
- goto out;
|
||||
+ goto out;
|
||||
}
|
||||
else {
|
||||
ret = PSA_SUCCESS;
|
||||
@@ -1871,7 +1871,7 @@ static psa_status_t fwu_update_metadata(const psa_fwu_component_t *candidates, u
|
||||
} else {
|
||||
FWU_LOG_MSG("ERROR: %s: active_index %d\n\r",__func__,active_index);
|
||||
ret = PSA_ERROR_DATA_INVALID;
|
||||
- goto out;
|
||||
+ goto out;
|
||||
}
|
||||
|
||||
_metadata.active_index = previous_active_index;
|
||||
@@ -1881,7 +1881,7 @@ static psa_status_t fwu_update_metadata(const psa_fwu_component_t *candidates, u
|
||||
/* Change system state to trial bank state */
|
||||
for (int i = 0; i < number; i++) {
|
||||
/* Skip image with index 0 and ESRT image */
|
||||
- if(!is_image_index_valid(candidates[i])) {
|
||||
+ if(!is_image_index_valid(candidates[i])) {
|
||||
FWU_LOG_MSG("%s: Invalid image index received \n\r", __func__);
|
||||
continue;
|
||||
}
|
||||
@@ -1946,7 +1946,7 @@ static psa_status_t copy_image_from_other_bank(int image_index,
|
||||
}
|
||||
|
||||
offset_read += data_size;
|
||||
-
|
||||
+
|
||||
/* write image data to flash */
|
||||
data_transferred_count = FWU_METADATA_FLASH_DEV.ProgramData(offset_write, data, data_size);
|
||||
if (data_transferred_count < 0) {
|
||||
@@ -1961,7 +1961,7 @@ static psa_status_t copy_image_from_other_bank(int image_index,
|
||||
}
|
||||
|
||||
offset_write += data_size;
|
||||
- remaining_size -= data_size;
|
||||
+ remaining_size -= data_size;
|
||||
}
|
||||
|
||||
FWU_LOG_MSG("%s: exit \n\r", __func__);
|
||||
@@ -2004,8 +2004,8 @@ static psa_status_t maintain_bank_consistency(void)
|
||||
ret = copy_image_from_other_bank(i, active_index, previous_active_index);
|
||||
if(ret) {
|
||||
FWU_LOG_MSG("ERROR: %s: copy_image_from_other_bank failed for Image : %d\n\r",__func__, i);
|
||||
- return ret;
|
||||
- }
|
||||
+ return ret;
|
||||
+ }
|
||||
|
||||
_metadata.fw_desc.img_entry[i].img_props[previous_active_index].version =
|
||||
_metadata.fw_desc.img_entry[i].img_props[active_index].version;
|
||||
@@ -2110,7 +2110,7 @@ psa_status_t fwu_bootloader_mark_image_accepted(const psa_fwu_component_t *trial
|
||||
|
||||
/* firmware update successful */
|
||||
for (int i = 0; i < number; i++) {
|
||||
- if(!is_image_index_valid(trials[i])) {
|
||||
+ if(!is_image_index_valid(trials[i])) {
|
||||
FWU_LOG_MSG("%s: Invalid image index received \n\r", __func__);
|
||||
continue;
|
||||
}
|
||||
@@ -2201,7 +2201,7 @@ psa_status_t fwu_bootloader_reject_staged_image(psa_fwu_component_t component)
|
||||
} else {
|
||||
FWU_LOG_MSG("ERROR: %s: active_index %d\n\r",__func__,active_index);
|
||||
ret = PSA_ERROR_GENERIC_ERROR;
|
||||
- goto out;
|
||||
+ goto out;
|
||||
}
|
||||
|
||||
image_offset = bank_offset + fwu_image[image_index].image_offset;
|
||||
@@ -2308,11 +2308,11 @@ psa_status_t fwu_bootloader_get_image_info(psa_fwu_component_t component,
|
||||
ret = get_esrt_data(&esrt);
|
||||
if (ret) {
|
||||
FWU_LOG_MSG("%s: ERROR : Unable to populate ESRT \n\r", __func__);
|
||||
- goto out;
|
||||
+ goto out;
|
||||
}
|
||||
|
||||
memcpy(&info->impl.candidate_digest, &esrt, esrt_size);
|
||||
- if (query_state) {
|
||||
+ if (query_state) {
|
||||
info->state = PSA_FWU_READY;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
From c579565c25937ae9455efe9cc3fbcace84c3e580 Mon Sep 17 00:00:00 2001
|
||||
From: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Date: Mon, 29 Dec 2025 11:28:47 +0000
|
||||
Subject: [PATCH] plat: cs1k: Removed unused variables
|
||||
|
||||
Change-Id: I0dd3ff834c47c58dc833586c74791deca679a3ab
|
||||
Signed-off-by: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Upstream-Status: Backport
|
||||
---
|
||||
.../arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c | 4 ----
|
||||
1 file changed, 4 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
index cff80b755..83b0bd27d 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
@@ -1511,7 +1511,6 @@ static psa_status_t fwu_accept_image(struct fwu_metadata *metadata,
|
||||
uint8_t number)
|
||||
{
|
||||
uint8_t current_state;
|
||||
- uint32_t image_bank_offset;
|
||||
uint32_t active_bank_index;
|
||||
uint32_t fwu_image_index;
|
||||
psa_status_t ret;
|
||||
@@ -1848,7 +1847,6 @@ static psa_status_t fwu_update_metadata(const psa_fwu_component_t *candidates, u
|
||||
{
|
||||
int ret;
|
||||
uint32_t active_index;
|
||||
- uint32_t bank_offset;
|
||||
uint32_t previous_active_index;
|
||||
uint8_t fwu_image_index;
|
||||
|
||||
@@ -1864,10 +1862,8 @@ static psa_status_t fwu_update_metadata(const psa_fwu_component_t *candidates, u
|
||||
|
||||
if (active_index == BANK_0) {
|
||||
previous_active_index = BANK_1;
|
||||
- bank_offset = BANK_1_PARTITION_OFFSET;
|
||||
} else if (active_index == BANK_1) {
|
||||
previous_active_index = BANK_0;
|
||||
- bank_offset = BANK_0_PARTITION_OFFSET;
|
||||
} else {
|
||||
FWU_LOG_MSG("ERROR: %s: active_index %d\n\r",__func__,active_index);
|
||||
ret = PSA_ERROR_DATA_INVALID;
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
From 50db5724ef37d5c7cec019254d135b3dcfd0d340 Mon Sep 17 00:00:00 2001
|
||||
From: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Date: Mon, 29 Dec 2025 11:30:32 +0000
|
||||
Subject: [PATCH] plat: cs1k: Fixed bad function returns
|
||||
|
||||
The rest of the functions would go to a label to perform some cleanup
|
||||
before exiting the function, however these particular errors did not. The
|
||||
cleanup would reset the write mode on flash, which is required since the
|
||||
errors occur after it being changed.
|
||||
|
||||
Change-Id: Ic8277a3295398922b2f05fcaddfb5a188b14e537
|
||||
Signed-off-by: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/49425]
|
||||
---
|
||||
.../arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
index 52db60bbc..2c17d4b79 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
@@ -1798,7 +1798,8 @@ psa_status_t fwu_bootloader_load_image(psa_fwu_component_t component,
|
||||
bank_offset = BANK_0_PARTITION_OFFSET;
|
||||
} else {
|
||||
FWU_LOG_MSG("ERROR: %s: active_index %d\n\r",__func__,active_index);
|
||||
- return PSA_ERROR_DATA_INVALID;
|
||||
+ ret = PSA_ERROR_DATA_INVALID;
|
||||
+ goto out;
|
||||
}
|
||||
|
||||
image_offset = bank_offset + fwu_image[fwu_image_index].image_offset;
|
||||
@@ -2002,7 +2003,7 @@ static psa_status_t maintain_bank_consistency(void)
|
||||
ret = copy_image_from_other_bank(i, active_index, previous_active_index);
|
||||
if(ret) {
|
||||
FWU_LOG_MSG("ERROR: %s: copy_image_from_other_bank failed for Image : %d\n\r",__func__, i);
|
||||
- return ret;
|
||||
+ goto out;
|
||||
}
|
||||
|
||||
_metadata.fw_desc.img_entry[i].img_props[previous_active_index].version =
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
From f48a0a6b60309433269c7927dac992eff06f3745 Mon Sep 17 00:00:00 2001
|
||||
From: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Date: Mon, 29 Dec 2025 11:29:33 +0000
|
||||
Subject: [PATCH] plat: cs1k: Improved logging in function
|
||||
|
||||
The enter log statement claims to log when the function is entered,
|
||||
however it was possible for the function to return before reaching it.
|
||||
The error cases have now been given log statements too in order to make
|
||||
it easier to track when and why the function exited.
|
||||
|
||||
Change-Id: I7fe610ca6a596b6af1e48720a503b76064eed3ff
|
||||
Signed-off-by: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/49424]
|
||||
---
|
||||
.../arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
index 83b0bd27d..52db60bbc 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
@@ -1700,11 +1700,16 @@ psa_status_t fwu_bootloader_load_image(psa_fwu_component_t component,
|
||||
size_t block_size)
|
||||
{
|
||||
|
||||
+ FWU_LOG_MSG("%s: enter: block_offset = %u, block = 0x%p, block_size = %u\n\r"
|
||||
+ , __func__, block_offset, block, block_size);
|
||||
+
|
||||
if (block == NULL) {
|
||||
+ FWU_LOG_MSG("%s: exit: block is NULL\n\r", __func__);
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (!is_initialized) {
|
||||
+ FWU_LOG_MSG("%s: exit: not initialised\n\r", __func__);
|
||||
return PSA_ERROR_BAD_STATE;
|
||||
}
|
||||
|
||||
@@ -1726,9 +1731,6 @@ psa_status_t fwu_bootloader_load_image(psa_fwu_component_t component,
|
||||
uint8_t fwu_image_index = component - FWU_FAKE_IMAGES_INDEX_COUNT;
|
||||
struct fwu_private_metadata priv_metadata;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter: block_offset = %u, block = 0x%p, block_size = %u\n\r"
|
||||
- , __func__, block_offset, block, block_size);
|
||||
-
|
||||
/* Parse the incoming block to make sure complete FMP header is received */
|
||||
if (fmp_header_image_info[fwu_image_index].fmp_hdr_size_recvd != sizeof(fmp_header_image_info[fwu_image_index].fmp_hdr)) {
|
||||
ret = parse_fmp_header(fwu_image_index, block, block_size);
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
From bd6d7dc80556e8c4261343141d675e865d4e960b Mon Sep 17 00:00:00 2001
|
||||
From: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Date: Fri, 2 Jan 2026 13:33:25 +0000
|
||||
Subject: [PATCH] plat: cs1k: Remove unused function
|
||||
|
||||
Change-Id: I6e054213dc1ec94a6dc8304705d4cb6e6da701cc
|
||||
Signed-off-by: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/49426]
|
||||
---
|
||||
.../bootloader/mcuboot/tfm_mcuboot_fwu.c | 70 -------------------
|
||||
1 file changed, 70 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
index 2c17d4b79..76ee8a3dc 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
@@ -501,76 +501,6 @@ static psa_status_t metadata_validate(struct fwu_metadata *metadata)
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
-#ifdef BL1_BUILD
|
||||
-static psa_status_t metadata_read_without_validation(struct fwu_metadata *metadata)
|
||||
-{
|
||||
- FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
- FWU_METADATA_REPLICA_1_OFFSET, sizeof(*metadata));
|
||||
-
|
||||
- if (!metadata) {
|
||||
- FWU_LOG_MSG("%s: ERROR - Null pointer received\n\r", __func__);
|
||||
- return PSA_ERROR_INVALID_ARGUMENT;
|
||||
- }
|
||||
-
|
||||
- int ret = FWU_METADATA_FLASH_DEV.ReadData(FWU_METADATA_REPLICA_1_OFFSET,
|
||||
- metadata, sizeof(*metadata));
|
||||
- if (ret < 0) {
|
||||
- FWU_LOG_MSG("%s: ERROR - Flash read failed (ret = %d)\n\r", __func__, ret);
|
||||
- return PSA_ERROR_STORAGE_FAILURE;
|
||||
- }
|
||||
-
|
||||
- if (ret != sizeof(*metadata)) {
|
||||
- FWU_LOG_MSG("%s: ERROR - Incomplete metadata read (expected %zu, got %d)\n\r",
|
||||
- __func__, sizeof(*metadata), ret);
|
||||
- return PSA_ERROR_INSUFFICIENT_DATA;
|
||||
- }
|
||||
-
|
||||
- FWU_LOG_MSG("%s: success: active = %u, previous = %d\n\r", __func__,
|
||||
- metadata->active_index, metadata->previous_active_index);
|
||||
-
|
||||
- return PSA_SUCCESS;
|
||||
-}
|
||||
-#else
|
||||
-static psa_status_t metadata_read_without_validation(struct fwu_metadata *metadata)
|
||||
-{
|
||||
- uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID;
|
||||
- partition_entry_t *part;
|
||||
-
|
||||
- if (!metadata) {
|
||||
- FWU_LOG_MSG("%s: ERROR - Null pointer received\n\r", __func__);
|
||||
- return PSA_ERROR_INVALID_ARGUMENT;
|
||||
- }
|
||||
-
|
||||
- part = get_partition_entry_by_type(&metadata_uuid);
|
||||
- if (!part) {
|
||||
- FWU_LOG_MSG("%s: FWU metadata partition not found\n\r", __func__);
|
||||
- return PSA_ERROR_GENERIC_ERROR;
|
||||
- }
|
||||
-
|
||||
- FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
- part->start, sizeof(*metadata));
|
||||
-
|
||||
-
|
||||
- int ret = FWU_METADATA_FLASH_DEV.ReadData(part->start,
|
||||
- metadata, sizeof(*metadata));
|
||||
- if (ret < 0) {
|
||||
- FWU_LOG_MSG("%s: ERROR - Flash read failed (ret = %d)\n\r", __func__, ret);
|
||||
- return PSA_ERROR_STORAGE_FAILURE;
|
||||
- }
|
||||
-
|
||||
- if (ret != sizeof(*metadata)) {
|
||||
- FWU_LOG_MSG("%s: ERROR - Incomplete metadata read (expected %zu, got %d)\n\r",
|
||||
- __func__, sizeof(*metadata), ret);
|
||||
- return PSA_ERROR_INSUFFICIENT_DATA;
|
||||
- }
|
||||
-
|
||||
- FWU_LOG_MSG("%s: success: active = %u, previous = %d\n\r", __func__,
|
||||
- metadata->active_index, metadata->previous_active_index);
|
||||
-
|
||||
- return PSA_SUCCESS;
|
||||
-}
|
||||
-#endif
|
||||
-
|
||||
#ifdef BL1_BUILD
|
||||
static psa_status_t metadata_read(struct fwu_metadata *metadata, uint8_t replica_num)
|
||||
{
|
||||
+464
@@ -0,0 +1,464 @@
|
||||
From 939d18a0d8dcedd2b5c4b6220e1a0f6c6855fcf6 Mon Sep 17 00:00:00 2001
|
||||
From: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Date: Fri, 2 Jan 2026 14:21:57 +0000
|
||||
Subject: [PATCH] plat: cs1k: Reduce BL1 binary size
|
||||
|
||||
The size of the BL1 binary is nearly at its maximum allowable size of
|
||||
64KiB. By making logging a bit more consistent, string literals can be
|
||||
re-used and reduce the size of the binary. This allows more space for
|
||||
BL1_2.
|
||||
|
||||
Some functions also had two or more "entry" logging statements, and so
|
||||
the redundant statements were removed.
|
||||
|
||||
The size of BL1_1 has been updated to reflect these changes.
|
||||
|
||||
Change-Id: Id52dd0d319fb252d7d05e40b6f8f640d27d45ddb
|
||||
Signed-off-by: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/49427]
|
||||
---
|
||||
.../bootloader/mcuboot/tfm_mcuboot_fwu.c | 101 ++++++++++--------
|
||||
.../arm/corstone1000/partition/region_defs.h | 2 +-
|
||||
2 files changed, 56 insertions(+), 47 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
index 76ee8a3dc..dc7503d41 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
@@ -56,6 +56,13 @@
|
||||
#define FWU_FAKE_IMAGES_INDEX_COUNT 1
|
||||
#define FWU_FAKE_IMAGE_INDEX 0
|
||||
|
||||
+/* These macros provide consistent logging for simple function enter and
|
||||
+ * successful exit. This helps reduce the number of string literals in the
|
||||
+ * final binary, thus reducing its size
|
||||
+ */
|
||||
+#define FWU_LOG_FUNC_ENTER FWU_LOG_MSG("%s: enter\n\r", __func__)
|
||||
+#define FWU_LOG_FUNC_EXIT_SUCCESS FWU_LOG_MSG("%s: success\n\r", __func__)
|
||||
+
|
||||
/*
|
||||
* Metadata version 2 data structures defined by PSA_FW update specification
|
||||
* at https://developer.arm.com/documentation/den0118/latest/
|
||||
@@ -334,7 +341,7 @@ extern ARM_DRIVER_FLASH FWU_METADATA_FLASH_DEV;
|
||||
static psa_status_t private_metadata_read(
|
||||
struct fwu_private_metadata* priv_metadata)
|
||||
{
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if (!priv_metadata) {
|
||||
FWU_LOG_MSG("%s: ERROR - Null pointer received\n\r", __func__);
|
||||
@@ -366,7 +373,7 @@ static psa_status_t private_metadata_read(
|
||||
partition_entry_t *part;
|
||||
uuid_t private_uuid = PRIVATE_METADATA_TYPE_UUID;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if (!priv_metadata) {
|
||||
FWU_LOG_MSG("%s: ERROR - Null pointer received\n\r", __func__);
|
||||
@@ -430,7 +437,7 @@ static psa_status_t private_metadata_write(
|
||||
return PSA_ERROR_INSUFFICIENT_DATA;
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: success\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
#else
|
||||
@@ -473,14 +480,14 @@ static psa_status_t private_metadata_write(
|
||||
return PSA_ERROR_INSUFFICIENT_DATA;
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: success\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
static psa_status_t metadata_validate(struct fwu_metadata *metadata)
|
||||
{
|
||||
- FWU_LOG_MSG("%s: enter:\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if (!metadata) {
|
||||
FWU_LOG_MSG("%s: ERROR - Null pointer received\n\r", __func__);
|
||||
@@ -496,7 +503,7 @@ static psa_status_t metadata_validate(struct fwu_metadata *metadata)
|
||||
return PSA_ERROR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: success\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
@@ -506,7 +513,7 @@ static psa_status_t metadata_read(struct fwu_metadata *metadata, uint8_t replica
|
||||
{
|
||||
uint32_t replica_offset = 0;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if (!metadata) {
|
||||
FWU_LOG_MSG("%s: ERROR - Null pointer received\n\r", __func__);
|
||||
@@ -525,7 +532,6 @@ static psa_status_t metadata_read(struct fwu_metadata *metadata, uint8_t replica
|
||||
FWU_LOG_MSG("%s: flash addr = %u, size = %d\n\r", __func__,
|
||||
replica_offset, sizeof(*metadata));
|
||||
|
||||
-
|
||||
int ret = FWU_METADATA_FLASH_DEV.ReadData(replica_offset,
|
||||
metadata, sizeof(*metadata));
|
||||
if (ret < 0) {
|
||||
@@ -555,7 +561,7 @@ static psa_status_t metadata_read(struct fwu_metadata *metadata, uint8_t replica
|
||||
uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID;
|
||||
partition_entry_t *part;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if (!metadata) {
|
||||
FWU_LOG_MSG("%s: ERROR - Null pointer received\n\r", __func__);
|
||||
@@ -611,7 +617,7 @@ static psa_status_t metadata_write(
|
||||
{
|
||||
uint32_t replica_offset = 0;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if (!metadata) {
|
||||
FWU_LOG_MSG("%s: ERROR - Null pointer received\n\r", __func__);
|
||||
@@ -627,10 +633,9 @@ static psa_status_t metadata_write(
|
||||
return PSA_ERROR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
+ FWU_LOG_MSG("%s: flash addr = %u, size = %d\n\r", __func__,
|
||||
replica_offset, sizeof(*metadata));
|
||||
|
||||
-
|
||||
int ret = FWU_METADATA_FLASH_DEV.EraseSector(replica_offset);
|
||||
if (ret != ARM_DRIVER_OK) {
|
||||
FWU_LOG_MSG("%s: ERROR - Flash erase failed (ret = %d)\n\r", __func__, ret);
|
||||
@@ -661,6 +666,8 @@ static psa_status_t metadata_write(
|
||||
uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID;
|
||||
partition_entry_t *part;
|
||||
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
+
|
||||
if (!metadata) {
|
||||
FWU_LOG_MSG("%s: ERROR - Null pointer received\n\r", __func__);
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
@@ -888,7 +895,7 @@ psa_status_t fwu_metadata_provision(void)
|
||||
{
|
||||
psa_status_t ret;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
ret = fwu_metadata_init();
|
||||
if (ret) {
|
||||
@@ -918,7 +925,7 @@ psa_status_t fwu_metadata_provision(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: FWU METADATA PROVISIONED.\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -927,7 +934,7 @@ static uint8_t get_fwu_image_state(
|
||||
struct fwu_private_metadata *priv_metadata,
|
||||
uint32_t fwu_image_index)
|
||||
{
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if ((metadata->fw_desc.img_entry[fwu_image_index].img_props[metadata->active_index].accepted)
|
||||
== (IMAGE_NOT_ACCEPTED)) {
|
||||
@@ -943,7 +950,7 @@ static uint8_t get_fwu_agent_state(
|
||||
struct fwu_metadata *metadata,
|
||||
struct fwu_private_metadata *priv_metadata)
|
||||
{
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if (priv_metadata->boot_index != metadata->active_index) {
|
||||
FWU_LOG_MSG("%s: exit: FWU Agent PSA_FWU_TRIAL (index mismatch)\n\r", __func__);
|
||||
@@ -966,7 +973,7 @@ static psa_status_t erase_image(uint32_t image_offset, uint32_t image_size)
|
||||
int ret;
|
||||
uint32_t sectors;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if ((image_offset % FWU_METADATA_FLASH_SECTOR_SIZE) != 0) {
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
@@ -989,7 +996,7 @@ static psa_status_t erase_image(uint32_t image_offset, uint32_t image_size)
|
||||
}
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: exit\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1001,7 +1008,7 @@ static psa_status_t fwu_select_previous(
|
||||
uint8_t current_state;
|
||||
uint32_t index;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
/* it is expected to receive this call only when
|
||||
in trial state */
|
||||
@@ -1049,8 +1056,8 @@ static psa_status_t fwu_select_previous(
|
||||
FWU_LOG_MSG("%s: in regular state by choosing previous active bank\n\r",
|
||||
__func__);
|
||||
|
||||
- FWU_LOG_MSG("%s: exit: ret = %d\n\r", __func__, ret);
|
||||
- return ret;
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
+ return PSA_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
@@ -1061,7 +1068,7 @@ void bl1_get_active_bl2_image(uint32_t *offset)
|
||||
uint32_t boot_attempted;
|
||||
uint32_t boot_index;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if (fwu_metadata_init()) {
|
||||
FWU_ASSERT(0);
|
||||
@@ -1125,7 +1132,7 @@ uint8_t bl2_get_boot_bank(void)
|
||||
{
|
||||
uint8_t boot_index;
|
||||
struct fwu_private_metadata priv_metadata;
|
||||
- FWU_LOG_MSG("%s: enter", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
if (fwu_metadata_init()) {
|
||||
FWU_ASSERT(0);
|
||||
}
|
||||
@@ -1150,7 +1157,7 @@ static psa_status_t update_nv_counters(
|
||||
uint32_t security_cnt;
|
||||
enum tfm_nv_counter_t tfm_nv_counter_i;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
/* The FWU_BL2_NV_COUNTER (0) is not mirrored in the private metadata. It is
|
||||
* directly updated in the bl1_2_validate_image_at_addr() function, in
|
||||
@@ -1194,7 +1201,7 @@ static psa_status_t update_nv_counters(
|
||||
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: exit\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1204,7 +1211,7 @@ psa_status_t corstone1000_fwu_host_ack(void)
|
||||
struct fwu_private_metadata priv_metadata;
|
||||
uint8_t current_state;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if (!is_initialized) {
|
||||
return PSA_ERROR_BAD_STATE;
|
||||
@@ -1309,7 +1316,7 @@ void host_acknowledgement_timer_to_reset(void)
|
||||
struct fwu_private_metadata priv_metadata;
|
||||
uint8_t current_state;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
Select_Write_Mode_For_Shared_Flash();
|
||||
|
||||
@@ -1342,7 +1349,7 @@ void host_acknowledgement_timer_to_reset(void)
|
||||
}
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: exit\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1379,7 +1386,7 @@ psa_status_t fwu_stage_nv_counter(enum fwu_nv_counter_index_t index,
|
||||
}
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: exit\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1397,7 +1404,7 @@ bool is_image_index_valid(uint8_t fwu_image_index) {
|
||||
|
||||
static psa_status_t get_esrt_data(struct fwu_esrt_data_wrapper *esrt)
|
||||
{
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
if (!esrt)
|
||||
{
|
||||
@@ -1445,7 +1452,7 @@ static psa_status_t fwu_accept_image(struct fwu_metadata *metadata,
|
||||
uint32_t fwu_image_index;
|
||||
psa_status_t ret;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
|
||||
/* booted from previous_active_bank, not expected
|
||||
@@ -1492,8 +1499,8 @@ static psa_status_t fwu_accept_image(struct fwu_metadata *metadata,
|
||||
return ret;
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: exit: fwu state is changed to regular, ret - %d\n\r", __func__, ret);
|
||||
- return ret;
|
||||
+ FWU_LOG_MSG("%s: success: fwu state is changed to regular\n\r", __func__);
|
||||
+ return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
static psa_status_t uint_to_image_version(uint32_t ver_in, psa_fwu_image_version_t *ver_out)
|
||||
@@ -1525,6 +1532,8 @@ static psa_status_t erase_staging_area(struct fwu_metadata* metadata, psa_fwu_co
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
+
|
||||
if (!is_image_index_valid(component)) {
|
||||
FWU_LOG_MSG("%s: Invalid Component received \n\r", __func__);
|
||||
return PSA_ERROR_GENERIC_ERROR;
|
||||
@@ -1535,8 +1544,6 @@ static psa_status_t erase_staging_area(struct fwu_metadata* metadata, psa_fwu_co
|
||||
uint32_t image_offset;
|
||||
uint8_t fwu_image_index = component - FWU_FAKE_IMAGES_INDEX_COUNT; /* Decrement to get the correct fwu image index */
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
-
|
||||
if (active_index == BANK_0) {
|
||||
bank_offset = BANK_1_PARTITION_OFFSET;
|
||||
} else if (active_index == BANK_1) {
|
||||
@@ -1551,7 +1558,7 @@ static psa_status_t erase_staging_area(struct fwu_metadata* metadata, psa_fwu_co
|
||||
return PSA_ERROR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
- FWU_LOG_MSG("%s: exit: Staging area erased succesfully \n\r", __func__);
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1559,7 +1566,7 @@ psa_status_t fwu_bootloader_init(void)
|
||||
{
|
||||
psa_status_t ret;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
ret = fwu_metadata_init();
|
||||
if (ret) {
|
||||
@@ -1569,7 +1576,7 @@ psa_status_t fwu_bootloader_init(void)
|
||||
/* Initialize the fmp_header_image_info object */
|
||||
fmp_header_image_info_init();
|
||||
|
||||
- FWU_LOG_MSG("%s: exit: Initialized\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_EXIT_SUCCESS;
|
||||
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
@@ -1588,7 +1595,7 @@ psa_status_t fwu_bootloader_staging_area_init(psa_fwu_component_t component,
|
||||
|
||||
psa_status_t ret;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
Select_Write_Mode_For_Shared_Flash();
|
||||
|
||||
@@ -1783,7 +1790,7 @@ static psa_status_t fwu_update_metadata(const psa_fwu_component_t *candidates, u
|
||||
uint32_t previous_active_index;
|
||||
uint8_t fwu_image_index;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter function\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
Select_Write_Mode_For_Shared_Flash();
|
||||
|
||||
@@ -1842,6 +1849,8 @@ static psa_status_t copy_image_from_other_bank(int image_index,
|
||||
uint32_t active_index,
|
||||
uint32_t previous_active_index)
|
||||
{
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
+
|
||||
uint32_t bank_offset[NR_OF_FW_BANKS] = {BANK_0_PARTITION_OFFSET, BANK_1_PARTITION_OFFSET};
|
||||
uint8_t data[FLASH_CHUNK_SIZE];
|
||||
size_t remaining_size = fwu_image[image_index].image_size;
|
||||
@@ -1904,7 +1913,7 @@ static psa_status_t maintain_bank_consistency(void)
|
||||
uint32_t previous_active_index;
|
||||
struct fwu_private_metadata priv_metadata;
|
||||
|
||||
- FWU_LOG_MSG("%s: Enter \n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
Select_Write_Mode_For_Shared_Flash();
|
||||
|
||||
if (metadata_read(&_metadata, 1) || private_metadata_read(&priv_metadata)) {
|
||||
@@ -1979,7 +1988,7 @@ psa_status_t fwu_bootloader_install_image(const psa_fwu_component_t *candidates,
|
||||
}
|
||||
|
||||
psa_status_t ret;
|
||||
- FWU_LOG_MSG("%s: enter function\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
/* Copy images from other bank which are not received by FWU client */
|
||||
ret = maintain_bank_consistency();
|
||||
@@ -2015,7 +2024,7 @@ psa_status_t fwu_bootloader_mark_image_accepted(const psa_fwu_component_t *trial
|
||||
uint8_t current_state;
|
||||
uint8_t fwu_image_index;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
Select_Write_Mode_For_Shared_Flash();
|
||||
|
||||
@@ -2114,7 +2123,7 @@ psa_status_t fwu_bootloader_reject_staged_image(psa_fwu_component_t component)
|
||||
uint32_t image_offset;
|
||||
uint8_t image_index = component - FWU_FAKE_IMAGES_INDEX_COUNT; /* Decrement to get the correct fwu image index */
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
Select_Write_Mode_For_Shared_Flash();
|
||||
|
||||
if (metadata_read(&_metadata, 1)) {
|
||||
@@ -2158,7 +2167,7 @@ psa_status_t fwu_bootloader_reject_trial_image(psa_fwu_component_t component)
|
||||
int ret;
|
||||
uint8_t fwu_image_index = component - FWU_FAKE_IMAGES_INDEX_COUNT; /* Decrement to get the correct fwu image index */
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
/* Disable host ackowledgement timer */
|
||||
disable_host_ack_timer();
|
||||
@@ -2213,7 +2222,7 @@ psa_status_t fwu_bootloader_get_image_info(psa_fwu_component_t component,
|
||||
uint8_t current_state;
|
||||
psa_status_t ret;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+ FWU_LOG_FUNC_ENTER;
|
||||
|
||||
|
||||
Select_Write_Mode_For_Shared_Flash();
|
||||
diff --git a/platform/ext/target/arm/corstone1000/partition/region_defs.h b/platform/ext/target/arm/corstone1000/partition/region_defs.h
|
||||
index 92e01c0e3..1feee7841 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/partition/region_defs.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/partition/region_defs.h
|
||||
@@ -94,7 +94,7 @@
|
||||
|
||||
/* SE BL1 regions */
|
||||
#define BL1_1_CODE_START (0)
|
||||
-#define BL1_1_CODE_SIZE (0x0000E800) /* 58 KiB */
|
||||
+#define BL1_1_CODE_SIZE (0x0000E748) /* 58 KiB */
|
||||
#define BL1_1_CODE_LIMIT (BL1_1_CODE_START + BL1_1_CODE_SIZE - 1)
|
||||
|
||||
#define PROVISIONING_DATA_START (BL1_1_CODE_START + BL1_1_CODE_SIZE)
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
From b4fd75b96b49756c4815685fc19089793fcc9356 Mon Sep 17 00:00:00 2001
|
||||
From: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Date: Wed, 14 Jan 2026 14:00:12 +0000
|
||||
Subject: [PATCH] plat: cs1k: Update license identifier
|
||||
|
||||
Change-Id: I26af0dbf66359e76b7164b3abdbbf3ace3f358c6
|
||||
Signed-off-by: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/49428]
|
||||
---
|
||||
platform/ext/target/arm/corstone1000/platform.c | 2 +-
|
||||
platform/ext/target/arm/corstone1000/platform.h | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/platform.c b/platform/ext/target/arm/corstone1000/platform.c
|
||||
index d0f30b72a..32fdc55aa 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/platform.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/platform.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
- * Copyright (c) 2023, Arm Limited. All rights reserved.
|
||||
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
diff --git a/platform/ext/target/arm/corstone1000/platform.h b/platform/ext/target/arm/corstone1000/platform.h
|
||||
index a88093ed4..906a8f9ae 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/platform.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/platform.h
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
- * Copyright (c) 2023, Arm Limited. All rights reserved.
|
||||
+ * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
+4536
File diff suppressed because it is too large
Load Diff
+55
@@ -0,0 +1,55 @@
|
||||
From 201166be49ca4c0079cf804f208534f201cb4b65 Mon Sep 17 00:00:00 2001
|
||||
From: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Date: Fri, 13 Mar 2026 16:53:54 +0000
|
||||
Subject: [PATCH] plat: cs1k: Move variable from stack to data
|
||||
|
||||
The firmware update secure partition stack is only 0x600 bytes in size.
|
||||
The variable moved is a buffer of size 0x200, consituting one third of
|
||||
the available stack. Moving this to the much larger .data section allows
|
||||
much more stack space if required.
|
||||
|
||||
Change-Id: I59d68e80acefaeea36c7060442e005998217d923
|
||||
Signed-off-by: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/49430]
|
||||
---
|
||||
.../arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
index 5e1c4ecc5..a35125b00 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
@@ -39,6 +39,7 @@
|
||||
* This is used when bank consistency is maintained during partial capsule update
|
||||
*/
|
||||
#define FLASH_CHUNK_SIZE 512
|
||||
+static uint8_t flash_data_buf[FLASH_CHUNK_SIZE];
|
||||
|
||||
/* Possible states of the bank.
|
||||
* Naming convention here matches the implementation in U-Boot
|
||||
@@ -1978,7 +1979,6 @@ static psa_status_t copy_image_from_other_bank(int image_index,
|
||||
FWU_LOG_FUNC_ENTER;
|
||||
|
||||
uint32_t bank_offset[NR_OF_FW_BANKS] = {BANK_0_PARTITION_OFFSET, BANK_1_PARTITION_OFFSET};
|
||||
- uint8_t data[FLASH_CHUNK_SIZE];
|
||||
size_t remaining_size = fwu_image[image_index].image_size;
|
||||
size_t data_size;
|
||||
size_t offset_read = bank_offset[active_index] + fwu_image[image_index].image_offset;
|
||||
@@ -1997,7 +1997,7 @@ static psa_status_t copy_image_from_other_bank(int image_index,
|
||||
data_size = (remaining_size > FLASH_CHUNK_SIZE) ? FLASH_CHUNK_SIZE : remaining_size;
|
||||
|
||||
/* read image data from flash */
|
||||
- data_transferred_count = FWU_METADATA_FLASH_DEV.ReadData(offset_read, data, data_size);
|
||||
+ data_transferred_count = FWU_METADATA_FLASH_DEV.ReadData(offset_read, flash_data_buf, data_size);
|
||||
if (data_transferred_count < 0) {
|
||||
FWU_LOG_MSG("%s: ERROR - Flash read failed (ret = %d)\n\r", __func__, data_transferred_count);
|
||||
return PSA_ERROR_STORAGE_FAILURE;
|
||||
@@ -2012,7 +2012,7 @@ static psa_status_t copy_image_from_other_bank(int image_index,
|
||||
offset_read += data_size;
|
||||
|
||||
/* write image data to flash */
|
||||
- data_transferred_count = FWU_METADATA_FLASH_DEV.ProgramData(offset_write, data, data_size);
|
||||
+ data_transferred_count = FWU_METADATA_FLASH_DEV.ProgramData(offset_write, flash_data_buf, data_size);
|
||||
if (data_transferred_count < 0) {
|
||||
FWU_LOG_MSG("%s: ERROR - Flash read failed (ret = %d)\n\r", __func__, data_transferred_count);
|
||||
return PSA_ERROR_STORAGE_FAILURE;
|
||||
+521
@@ -0,0 +1,521 @@
|
||||
From 93101e6de045c0c4d633c502616ccf184c07e70a Mon Sep 17 00:00:00 2001
|
||||
From: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Date: Fri, 13 Mar 2026 13:42:16 +0000
|
||||
Subject: [PATCH] plat: cs1k: Create and remove FWU image partitions
|
||||
|
||||
Previous to this commit, the GPT library was used only to read each
|
||||
firmware update image partition. However, the library now is used to
|
||||
create new partitions, if they don't exist, at the start of an update
|
||||
and remove the unused partitions at the end of an update, regardless of
|
||||
whether the images were accepted or rejected.
|
||||
|
||||
The images are not moved and are still placed in fixed offsets, so the
|
||||
idea of a ping-pong between banks still persists.
|
||||
|
||||
Change-Id: Ie2a2f0246a500c01019e3b498ac131466a2b3c84
|
||||
Signed-off-by: Frazer Carsley <frazer.carsley@arm.com>
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/49431]
|
||||
---
|
||||
.../arm/corstone1000/bootloader/fwu_agent.h | 7 +-
|
||||
.../bootloader/mcuboot/tfm_mcuboot_fwu.c | 313 +++++++++++++++++-
|
||||
2 files changed, 302 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bootloader/fwu_agent.h b/platform/ext/target/arm/corstone1000/bootloader/fwu_agent.h
|
||||
index 4393f5f7b..729e1594c 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bootloader/fwu_agent.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/bootloader/fwu_agent.h
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef FWU_AGENT_H
|
||||
#define FWU_AGENT_H
|
||||
|
||||
+#include "flash_layout.h"
|
||||
#include "psa/error.h"
|
||||
#include "efi_guid_structs.h"
|
||||
#include "gpt.h"
|
||||
@@ -47,7 +48,7 @@ typedef struct {
|
||||
size_t image_size_recvd;
|
||||
} __packed fmp_header_image_info_t;
|
||||
|
||||
-/* Image information common for both the banks */
|
||||
+/* Image information for each bank */
|
||||
typedef struct {
|
||||
/* Total size of the image */
|
||||
uint32_t image_size;
|
||||
@@ -55,8 +56,8 @@ typedef struct {
|
||||
/* Offset of image within a bank. */
|
||||
uint32_t image_offset;
|
||||
|
||||
- /* Name of the image in ascii */
|
||||
- char image_name[FWU_IMAGE_NAME_LENGTH];
|
||||
+ /* Names of the image in ascii, one for each bank */
|
||||
+ const char image_names[NR_OF_FW_BANKS][FWU_IMAGE_NAME_LENGTH];
|
||||
|
||||
/* Image-type GUID */
|
||||
struct efi_guid_t image_type;
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
index a35125b00..71a91ade5 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bootloader/mcuboot/tfm_mcuboot_fwu.c
|
||||
@@ -214,7 +214,7 @@ const fwu_image_info_t fwu_image[NR_OF_IMAGES_IN_FW_BANK] = {
|
||||
#if PLATFORM_IS_FVP
|
||||
// FVP payloads GUIDs
|
||||
{
|
||||
- .image_name = "bl2_secondary",
|
||||
+ .image_names = {"bl2_primary", "bl2_secondary"},
|
||||
.image_size = SE_BL2_PARTITION_SIZE,
|
||||
.image_offset = SE_BL2_PARTITION_BANK_OFFSET,
|
||||
.image_type = {
|
||||
@@ -227,7 +227,7 @@ const fwu_image_info_t fwu_image[NR_OF_IMAGES_IN_FW_BANK] = {
|
||||
},
|
||||
},
|
||||
{
|
||||
- .image_name = "tfm_secondary",
|
||||
+ .image_names = {"tfm_primary", "tfm_secondary"},
|
||||
.image_size = TFM_PARTITION_SIZE,
|
||||
.image_offset = TFM_PARTITION_BANK_OFFSET,
|
||||
.image_type = {
|
||||
@@ -240,7 +240,7 @@ const fwu_image_info_t fwu_image[NR_OF_IMAGES_IN_FW_BANK] = {
|
||||
},
|
||||
},
|
||||
{
|
||||
- .image_name = "FIP_B",
|
||||
+ .image_names = {"FIP_A", "FIP_B"},
|
||||
.image_size = FIP_PARTITION_SIZE,
|
||||
.image_offset = FIP_PARTITION_BANK_OFFSET,
|
||||
.image_type = {
|
||||
@@ -253,7 +253,7 @@ const fwu_image_info_t fwu_image[NR_OF_IMAGES_IN_FW_BANK] = {
|
||||
},
|
||||
},
|
||||
{
|
||||
- .image_name = "kernel_secondary",
|
||||
+ .image_names = {"kernel_primary", "kernel_secondary"},
|
||||
.image_size = INITRAMFS_PARTITION_SIZE,
|
||||
.image_offset = INITRAMFS_PARTITION_BANK_OFFSET,
|
||||
.image_type = {
|
||||
@@ -268,7 +268,7 @@ const fwu_image_info_t fwu_image[NR_OF_IMAGES_IN_FW_BANK] = {
|
||||
#else
|
||||
// MPS3 payloads GUIDs
|
||||
{
|
||||
- .image_name = "bl2_secondary",
|
||||
+ .image_names = {"bl2_primary", "bl2_secondary"},
|
||||
.image_size = SE_BL2_PARTITION_SIZE,
|
||||
.image_offset = SE_BL2_PARTITION_BANK_OFFSET,
|
||||
.image_type = {
|
||||
@@ -281,7 +281,7 @@ const fwu_image_info_t fwu_image[NR_OF_IMAGES_IN_FW_BANK] = {
|
||||
},
|
||||
},
|
||||
{
|
||||
- .image_name = "tfm_secondary",
|
||||
+ .image_names = {"tfm_primary", "tfm_secondary"},
|
||||
.image_size = TFM_PARTITION_SIZE,
|
||||
.image_offset = TFM_PARTITION_BANK_OFFSET,
|
||||
.image_type = {
|
||||
@@ -294,7 +294,7 @@ const fwu_image_info_t fwu_image[NR_OF_IMAGES_IN_FW_BANK] = {
|
||||
}
|
||||
},
|
||||
{
|
||||
- .image_name = "FIP_B",
|
||||
+ .image_names = {"FIP_A", "FIP_B"},
|
||||
.image_size = FIP_PARTITION_SIZE,
|
||||
.image_offset = FIP_PARTITION_BANK_OFFSET,
|
||||
.image_type = {
|
||||
@@ -307,7 +307,7 @@ const fwu_image_info_t fwu_image[NR_OF_IMAGES_IN_FW_BANK] = {
|
||||
}
|
||||
},
|
||||
{
|
||||
- .image_name = "kernel_secondary",
|
||||
+ .image_names = {"kernel_primary", "kernel_secondary"},
|
||||
.image_size = INITRAMFS_PARTITION_SIZE,
|
||||
.image_offset = INITRAMFS_PARTITION_BANK_OFFSET,
|
||||
.image_type = {
|
||||
@@ -354,6 +354,15 @@ extern ARM_DRIVER_FLASH FWU_METADATA_FLASH_DEV;
|
||||
* This is the value decided after monitoring the total time
|
||||
* taken by the host to boot both on FVP and FPGA.
|
||||
*/
|
||||
+#ifndef BL1_BUILD
|
||||
+static void ascii_to_unicode(const char *ascii, char *unicode)
|
||||
+{
|
||||
+ for (int i = 0; i < strlen(ascii) + 1; ++i) {
|
||||
+ unicode[i << 1] = ascii[i];
|
||||
+ unicode[(i << 1) + 1] = '\0';
|
||||
+ }
|
||||
+}
|
||||
+#endif
|
||||
|
||||
#ifdef BL1_BUILD
|
||||
static psa_status_t private_metadata_read(
|
||||
@@ -856,6 +865,11 @@ psa_status_t fwu_metadata_init(void)
|
||||
if (ret != PSA_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
+
|
||||
+ ret = psa_crypto_init();
|
||||
+ if (ret != PSA_SUCCESS) {
|
||||
+ return ret;
|
||||
+ }
|
||||
#endif
|
||||
|
||||
/* Code assumes everything fits into a sector */
|
||||
@@ -1146,6 +1160,45 @@ static psa_status_t fwu_select_previous(
|
||||
return ret;
|
||||
}
|
||||
|
||||
+#ifndef BL1_BUILD
|
||||
+ /* Remove the GPT partitions for the rejected images. It is always the newer
|
||||
+ * (second) partitions that are rejected, as they are created during the
|
||||
+ * fwu process
|
||||
+ */
|
||||
+ for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; ++i) {
|
||||
+ struct partition_entry_t part;
|
||||
+ ret = gpt_entry_read_by_type(&(fwu_image[i].image_type), 1, &part);
|
||||
+
|
||||
+ if (ret == PSA_ERROR_DOES_NOT_EXIST) {
|
||||
+ FWU_LOG_MSG("%s: Unable to find partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[index]);
|
||||
+ return ret;
|
||||
+ } else if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst reading GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ FWU_LOG_MSG("%s: Unable to read partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[index]);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = gpt_entry_remove(&(part.partition_guid));
|
||||
+ if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst removing GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ FWU_LOG_MSG("%s: Unable to remove partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[index]);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: Removed GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[index]);
|
||||
+ }
|
||||
+#endif /* BL1_BUILD */
|
||||
+
|
||||
FWU_LOG_MSG("%s: in regular state by choosing previous active bank\n\r",
|
||||
__func__);
|
||||
|
||||
@@ -1594,6 +1647,47 @@ static psa_status_t fwu_accept_image(struct fwu_metadata *metadata,
|
||||
return ret;
|
||||
}
|
||||
|
||||
+#ifndef BL1_BUILD
|
||||
+ /* Remove the old (first) partitions from the GPT header. It is always the
|
||||
+ * older images to be removed, as they were not created by the update
|
||||
+ * process but existed before
|
||||
+ */
|
||||
+ uint32_t previous_bank_index = metadata->previous_active_index;
|
||||
+
|
||||
+ for (int i = 0; i < NR_OF_IMAGES_IN_FW_BANK; ++i) {
|
||||
+ struct partition_entry_t part;
|
||||
+
|
||||
+ ret = gpt_entry_read_by_type(
|
||||
+ &(fwu_image[i].image_type),
|
||||
+ 0,
|
||||
+ &part);
|
||||
+ if (ret == PSA_ERROR_DOES_NOT_EXIST) {
|
||||
+ FWU_LOG_MSG("%s: Unable to find partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[previous_bank_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst reading GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[previous_bank_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ FWU_LOG_MSG("%s: Unable to read partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[previous_bank_index]);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = gpt_entry_remove(&(part.partition_guid));
|
||||
+ if (ret == PSA_ERROR_DOES_NOT_EXIST) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst removing GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[previous_bank_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ FWU_LOG_MSG("%s: Unable to remove partition '%s'\r\n",
|
||||
+ __func__, fwu_image[i].image_names[previous_bank_index]);
|
||||
+ return ret;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
FWU_LOG_MSG("%s: success: fwu state is changed to regular\n\r", __func__);
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
@@ -1635,21 +1729,81 @@ static psa_status_t erase_staging_area(struct fwu_metadata* metadata, psa_fwu_co
|
||||
}
|
||||
|
||||
uint32_t active_index = metadata->active_index;
|
||||
+ uint32_t previous_active_index;
|
||||
uint32_t bank_offset;
|
||||
uint32_t image_offset;
|
||||
+ uint32_t image_size;
|
||||
uint8_t fwu_image_index = component - FWU_FAKE_IMAGES_INDEX_COUNT; /* Decrement to get the correct fwu image index */
|
||||
|
||||
if (active_index == BANK_0) {
|
||||
bank_offset = BANK_1_PARTITION_OFFSET;
|
||||
+ previous_active_index = BANK_1;
|
||||
} else if (active_index == BANK_1) {
|
||||
bank_offset = BANK_0_PARTITION_OFFSET;
|
||||
+ previous_active_index = BANK_0;
|
||||
} else {
|
||||
FWU_LOG_MSG("ERROR: %s: active_index %d\n\r",__func__,active_index);
|
||||
return PSA_ERROR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
+#ifdef BL1_BUILD
|
||||
image_offset = bank_offset + fwu_image[fwu_image_index].image_offset;
|
||||
- if (erase_image(image_offset, fwu_image[fwu_image_index].image_size)) {
|
||||
+ image_size = fwu_image[fwu_image_index].image_size;
|
||||
+#else
|
||||
+ /* Use GPT to find partition instead */
|
||||
+ struct partition_entry_t part;
|
||||
+
|
||||
+ psa_status_t ret = gpt_entry_read_by_type(&(fwu_image[fwu_image_index].image_type), 1, &part);
|
||||
+ if (ret == PSA_ERROR_DOES_NOT_EXIST) {
|
||||
+ /* Create the partition in the expected space */
|
||||
+ struct efi_guid_t new_guid = {0};
|
||||
+ char unicode_name[GPT_ENTRY_NAME_LENGTH] = {'\0'};
|
||||
+ ascii_to_unicode(fwu_image[fwu_image_index].image_names[previous_active_index], unicode_name);
|
||||
+
|
||||
+ ret = gpt_entry_create(&(fwu_image[fwu_image_index].image_type),
|
||||
+ (bank_offset + fwu_image[fwu_image_index].image_offset) / TFM_GPT_BLOCK_SIZE,
|
||||
+ 1 + ((fwu_image[fwu_image_index].image_size - 1) / TFM_GPT_BLOCK_SIZE),
|
||||
+ 0,
|
||||
+ unicode_name,
|
||||
+ &new_guid);
|
||||
+ if (ret == PSA_ERROR_INSUFFICIENT_STORAGE) {
|
||||
+ FWU_LOG_MSG("%s: No space left on device!\r\n", __func__);
|
||||
+ return ret;
|
||||
+ } else if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst creating GPT partition '%s'!\r\n",
|
||||
+ __func__, fwu_image[fwu_image_index].image_names[previous_active_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ FWU_LOG_MSG("%s: Unable to create GPT partition '%s': %d\r\n", __func__,
|
||||
+ fwu_image[fwu_image_index].image_names[previous_active_index], ret);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = gpt_entry_read(&new_guid, &part);
|
||||
+ if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst reading GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[fwu_image_index].image_names[previous_active_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ FWU_LOG_MSG("%s: Unable to read GPT partition '%s': %d\r\n", __func__,
|
||||
+ fwu_image[fwu_image_index].image_names[previous_active_index], ret);
|
||||
+ return ret;
|
||||
+ }
|
||||
+ } else if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst reading GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[fwu_image_index].image_names[previous_active_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ FWU_LOG_MSG("%s: Unable to read GPT partition '%s': %d\r\n", __func__,
|
||||
+ fwu_image[fwu_image_index].image_names[previous_active_index], ret);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ image_offset = part.start * TFM_GPT_BLOCK_SIZE;
|
||||
+ image_size = part.size * TFM_GPT_BLOCK_SIZE;
|
||||
+#endif /* BL1_BUILD */
|
||||
+
|
||||
+ if (erase_image(image_offset, image_size)) {
|
||||
return PSA_ERROR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
@@ -1924,7 +2078,6 @@ static psa_status_t fwu_update_metadata(const psa_fwu_component_t *candidates, u
|
||||
goto out;
|
||||
}
|
||||
active_index = _metadata.active_index;
|
||||
-
|
||||
if (active_index == BANK_0) {
|
||||
previous_active_index = BANK_1;
|
||||
} else if (active_index == BANK_1) {
|
||||
@@ -1979,15 +2132,89 @@ static psa_status_t copy_image_from_other_bank(int image_index,
|
||||
FWU_LOG_FUNC_ENTER;
|
||||
|
||||
uint32_t bank_offset[NR_OF_FW_BANKS] = {BANK_0_PARTITION_OFFSET, BANK_1_PARTITION_OFFSET};
|
||||
+ psa_status_t ret;
|
||||
+
|
||||
+#ifdef BL1_BUILD
|
||||
+ /* Use offsets directly */
|
||||
size_t remaining_size = fwu_image[image_index].image_size;
|
||||
size_t data_size;
|
||||
size_t offset_read = bank_offset[active_index] + fwu_image[image_index].image_offset;
|
||||
size_t offset_write = bank_offset[previous_active_index] + fwu_image[image_index].image_offset;
|
||||
int data_transferred_count;
|
||||
+#else
|
||||
+ /* Use GPT to find the correct image */
|
||||
+ struct partition_entry_t active_part;
|
||||
+ ret = gpt_entry_read_by_type(
|
||||
+ &(fwu_image[image_index].image_type),
|
||||
+ 0,
|
||||
+ &active_part);
|
||||
+ if (ret == PSA_ERROR_DOES_NOT_EXIST) {
|
||||
+ FWU_LOG_MSG("%s: Unable to find partition '%s'\r\n",
|
||||
+ __func__, fwu_image[image_index].image_names[active_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst reading GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[image_index].image_names[active_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ FWU_LOG_MSG("%s: Unable to read partition '%s'\r\n",
|
||||
+ __func__, fwu_image[image_index].image_names[active_index]);
|
||||
+ return ret;
|
||||
+ }
|
||||
|
||||
- FWU_LOG_MSG("%s: Enter \n\r", __func__);
|
||||
+ struct partition_entry_t prev_active_part;
|
||||
+ ret = gpt_entry_read_by_type(
|
||||
+ &(fwu_image[image_index].image_type),
|
||||
+ 1,
|
||||
+ &prev_active_part);
|
||||
|
||||
- psa_status_t ret = erase_image(offset_write, fwu_image[image_index].image_size);
|
||||
+ if (ret == PSA_ERROR_DOES_NOT_EXIST) {
|
||||
+ /* Create the partition in the expected space */
|
||||
+ struct efi_guid_t new_guid = {0};
|
||||
+ char unicode_name[GPT_ENTRY_NAME_LENGTH] = {'\0'};
|
||||
+ ascii_to_unicode(fwu_image[image_index].image_names[previous_active_index], unicode_name);
|
||||
+
|
||||
+ ret = gpt_entry_create(&(fwu_image[image_index].image_type),
|
||||
+ (bank_offset[previous_active_index] + fwu_image[image_index].image_offset) / TFM_GPT_BLOCK_SIZE,
|
||||
+ 1 + ((fwu_image[image_index].image_size - 1) / TFM_GPT_BLOCK_SIZE),
|
||||
+ 0,
|
||||
+ unicode_name,
|
||||
+ &new_guid);
|
||||
+ if (ret == PSA_ERROR_INSUFFICIENT_STORAGE) {
|
||||
+ FWU_LOG_MSG("%s: No space left on device!\r\n", __func__);
|
||||
+ return ret;
|
||||
+ } else if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst creating GPT partition '%s'!\r\n",
|
||||
+ __func__, fwu_image[image_index].image_names[previous_active_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ ret = gpt_entry_read(&new_guid, &prev_active_part);
|
||||
+ if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst reading GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[image_index].image_names[previous_active_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ return ret;
|
||||
+ }
|
||||
+ } else if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst reading GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[image_index].image_names[previous_active_index]);
|
||||
+ return ret;
|
||||
+ } else if (ret < 0) {
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ size_t remaining_size = prev_active_part.size * TFM_GPT_BLOCK_SIZE;
|
||||
+ size_t data_size;
|
||||
+ size_t offset_read = active_part.start * TFM_GPT_BLOCK_SIZE;
|
||||
+ size_t offset_write = prev_active_part.start * TFM_GPT_BLOCK_SIZE;
|
||||
+ int data_transferred_count;
|
||||
+#endif /* BL1_BUILD */
|
||||
+
|
||||
+ ret = erase_image(offset_write, remaining_size);
|
||||
if (ret != PSA_SUCCESS) {
|
||||
FWU_LOG_MSG("%s: ERROR - Flash erase failed for Image: %d\n\r", __func__, image_index);
|
||||
return ret;
|
||||
@@ -2244,10 +2471,10 @@ psa_status_t fwu_bootloader_reject_staged_image(psa_fwu_component_t component)
|
||||
return PSA_ERROR_BAD_STATE;
|
||||
}
|
||||
|
||||
- int ret;
|
||||
+ psa_status_t ret;
|
||||
uint32_t active_index;;
|
||||
- uint32_t bank_offset;
|
||||
uint32_t image_offset;
|
||||
+ uint32_t image_size;
|
||||
uint8_t image_index = component - FWU_FAKE_IMAGES_INDEX_COUNT; /* Decrement to get the correct fwu image index */
|
||||
|
||||
FWU_LOG_FUNC_ENTER;
|
||||
@@ -2259,6 +2486,8 @@ psa_status_t fwu_bootloader_reject_staged_image(psa_fwu_component_t component)
|
||||
}
|
||||
active_index = _metadata.active_index;
|
||||
|
||||
+#ifdef BL1_BUILD
|
||||
+ uint32_t bank_offset;
|
||||
if (active_index == BANK_0) {
|
||||
bank_offset = BANK_1_PARTITION_OFFSET;
|
||||
} else if (active_index == BANK_1) {
|
||||
@@ -2270,8 +2499,62 @@ psa_status_t fwu_bootloader_reject_staged_image(psa_fwu_component_t component)
|
||||
}
|
||||
|
||||
image_offset = bank_offset + fwu_image[image_index].image_offset;
|
||||
+ image_size = fwu_image[image_index].image_size;
|
||||
+#else
|
||||
+ uint32_t previous_active_index;
|
||||
+ struct partition_entry_t part;
|
||||
+
|
||||
+ if (active_index == BANK_0) {
|
||||
+ previous_active_index = BANK_1;
|
||||
+ } else if (active_index == BANK_1) {
|
||||
+ previous_active_index = BANK_0;
|
||||
+ } else {
|
||||
+ FWU_LOG_MSG("ERROR: %s: active_index %d\n\r",__func__,active_index);
|
||||
+ ret = PSA_ERROR_GENERIC_ERROR;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ /* The newer entry of the same type is the staged image, as it was created
|
||||
+ * during the fwu process
|
||||
+ */
|
||||
+ ret = gpt_entry_read_by_type(
|
||||
+ &(fwu_image[image_index].image_type),
|
||||
+ 1,
|
||||
+ &part);
|
||||
+
|
||||
+ if (ret == PSA_ERROR_DOES_NOT_EXIST) {
|
||||
+ FWU_LOG_MSG("%s: Partition '%s' not found\n\r",
|
||||
+ __func__, fwu_image[image_index].image_names[previous_active_index]);
|
||||
+ goto out;
|
||||
+ } else if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s : ERROR - flash failure reading partition '%s'\n\r",
|
||||
+ __func__, fwu_image[image_index].image_names[previous_active_index]);
|
||||
+ goto out;
|
||||
+ } else if (ret < 0) {
|
||||
+ FWU_LOG_MSG("Unable to find partition '%s', ret: %d\n\r",
|
||||
+ fwu_image[image_index].image_names[previous_active_index], ret);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ /* Remove the partition. This only removes the entry from the header and
|
||||
+ * does not erase the actual data the partition referred to
|
||||
+ */
|
||||
+ ret = gpt_entry_remove(&(part.partition_guid));
|
||||
+ if (ret == PSA_ERROR_STORAGE_FAILURE) {
|
||||
+ FWU_LOG_MSG("%s: Flash error whilst removing GPT partition '%s'\r\n",
|
||||
+ __func__, fwu_image[image_index].image_names[previous_active_index]);
|
||||
+ goto out;
|
||||
+ } else if (ret < 0) {
|
||||
+ FWU_LOG_MSG("%s: Unable to remove partition '%s'\r\n",
|
||||
+ __func__, fwu_image[image_index].image_names[previous_active_index]);
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ image_offset = part.start * TFM_GPT_BLOCK_SIZE;
|
||||
+ image_size = part.size * TFM_GPT_BLOCK_SIZE;
|
||||
+#endif /* BL1_BUILD */
|
||||
|
||||
- if (erase_image(image_offset, fwu_image[image_index].image_size)) {
|
||||
+ if (erase_image(image_offset, image_size)) {
|
||||
return PSA_ERROR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,16 @@ SRC_URI:append:corstone1000 = " \
|
||||
file://0031-lib-gpt-Correct-variable-name-used.patch \
|
||||
file://0032-lib-gpt-Correct-include-directory.patch \
|
||||
file://0033-lib-gpt-Move-contents-of-CMake-config-file.patch \
|
||||
file://0034-plat-cs1k-Fixed-formatting-errors.patch \
|
||||
file://0035-plat-cs1k-Removed-unused-variables.patch \
|
||||
file://0036-plat-cs1k-Fixed-bad-function-returns.patch \
|
||||
file://0037-plat-cs1k-Improved-logging-in-function.patch \
|
||||
file://0038-plat-cs1k-Remove-unused-function.patch \
|
||||
file://0039-plat-cs1k-Reduce-BL1-binary-size.patch \
|
||||
file://0040-plat-cs1k-Update-license-identifier.patch \
|
||||
file://0041-plat-cs1k-Changed-to-use-new-GPT-library.patch \
|
||||
file://0042-plat-cs1k-Move-variable-from-stack-to-data.patch \
|
||||
file://0043-plat-cs1k-Create-and-remove-FWU-image-partitions.patch \
|
||||
"
|
||||
|
||||
SRCREV_tfm-psa-adac:corstone1000 = "f2809ae231be33a1afcd7714f40756c67d846c88"
|
||||
@@ -78,7 +88,7 @@ SRC_URI:append:corstone1000-mps3 = " \
|
||||
|
||||
create_bl1_image(){
|
||||
dd conv=notrunc bs=1 if=${D}${FIRMWARE_DIR}/bl1_1.bin of=${D}${FIRMWARE_DIR}/bl1.bin seek=0
|
||||
# Size of bl1_1.bin is 58KB (59392 bytes)
|
||||
dd conv=notrunc bs=1 if=${D}${FIRMWARE_DIR}/bl1_provisioning_bundle.bin of=${D}${FIRMWARE_DIR}/bl1.bin seek=59392
|
||||
# Size of bl1_1.bin is 58KB (59208 bytes)
|
||||
dd conv=notrunc bs=1 if=${D}${FIRMWARE_DIR}/bl1_provisioning_bundle.bin of=${D}${FIRMWARE_DIR}/bl1.bin seek=59208
|
||||
}
|
||||
do_install[postfuncs] += "create_bl1_image"
|
||||
|
||||
+8
-14
@@ -11,30 +11,24 @@ part --source empty --size 3k --offset 17k --part-name="reserved_1" --uuid B1F2F
|
||||
|
||||
part --source empty --size 4k --align 4 --offset 20k --part-name="FWU-Metadata" --uuid 3FDFFEE1-3223-4C6B-80F9-B0E7D780C21D --part-type 8A7A84A0-8387-40F6-AB41-A8B9A5A60D23
|
||||
part --source empty --size 4k --align 4 --offset 24k --part-name="Bkup-FWU-Metadata" --uuid B3068316-5351-4998-823A-3A7B09133EC1 --part-type 8A7A84A0-8387-40F6-AB41-A8B9A5A60D23
|
||||
|
||||
part --source empty --size 4k --align 4 --offset 28k --part-name="private_metadata_replica_2" --uuid 3CC3B456-DEC8-4CE3-BC5C-965483CE4828 --part-type ECB55DC3-8AB7-4A84-AB56-EB0A9974DB42
|
||||
part --source empty --size 4k --align 4 --offset 28k --part-name="private_metadata_replica_1" --uuid 3CC3B456-DEC8-4CE3-BC5C-965483CE4828 --part-type ECB55DC3-8AB7-4A84-AB56-EB0A9974DB42
|
||||
part --source empty --size 4k --align 4 --offset 32k --part-name="private_metadata_replica_2" --uuid DCE9C503-8DFD-4DCB-8889-647E49641552 --part-type ECB55DC3-8AB7-4A84-AB56-EB0A9974DB42
|
||||
|
||||
# The partition type of each of these four partitions should match the type of the images
|
||||
# in a fiwmare update capsule
|
||||
# The size has to be aligned to TF-M's SE_BL2_PARTITION_SIZE (tfm/platform/ext/target/arm/corstone1000/partition/flash_layout.h)
|
||||
part --source rawcopy --size 144k --sourceparams="file=trusted-firmware-m/bl2_signed.bin" --offset 36k --align 4 --part-name="bl2_primary" --uuid 9A3A8FBF-55EF-439C-80C9-A3F728033929 --part-type 64BD8ADB-02C0-4819-8688-03AB4CAB0ED9
|
||||
part --source rawcopy --size 144k --sourceparams="file=trusted-firmware-m/bl2_signed.bin" --offset 36k --align 4 --part-name="bl2_primary" --uuid 9A3A8FBF-55EF-439C-80C9-A3F728033929 --part-type F1D883F9-DFEB-5363-98D8-686EE3B69F4F
|
||||
|
||||
# The size has to be aligned to TF-M's TFM_PARTITION_SIZE (tfm/platform/ext/target/arm/corstone1000/partition/flash_layout.h)
|
||||
part --source rawcopy --size 320k --sourceparams="file=trusted-firmware-m/tfm_s_signed.bin" --align 4 --part-name="tfm_primary" --uuid 07F9616C-1233-439C-ACBA-72D75421BF70 --part-type D763C27F-07F6-4FF0-B2F3-060CB465CD4E
|
||||
part --source rawcopy --size 320k --sourceparams="file=trusted-firmware-m/tfm_s_signed.bin" --align 4 --part-name="tfm_primary" --uuid 07F9616C-1233-439C-ACBA-72D75421BF70 --part-type 7FAD470E-5EC5-5C03-A2C1-4756B495DE61
|
||||
|
||||
# Rawcopy of the FIP binary
|
||||
part --source rawcopy --size 2 --sourceparams="file=signed_fip.bin" --align 4 --part-name="FIP_A" --uuid B9C7AC9D-40FF-4675-956B-EEF4DE9DF1C5 --part-type B5EB19BD-CF56-45E8-ABA7-7ADB228FFEA7
|
||||
part --source rawcopy --size 2 --sourceparams="file=signed_fip.bin" --align 4 --part-name="FIP_A" --uuid B9C7AC9D-40FF-4675-956B-EEF4DE9DF1C5 --part-type F1933675-5A8C-5B6D-9EF4-846739E89BC8
|
||||
|
||||
# Rawcopy of kernel with initramfs
|
||||
part --source rawcopy --size 12 --sourceparams="file=Image.gz-initramfs-${MACHINE}.bin" --align 4 --part-name="kernel_primary" --uuid BF7A6142-0662-47FD-9434-6A8811980816 --part-type 8197561D-6124-46FC-921E-141CC5745B05
|
||||
|
||||
|
||||
# The offset has to be aligned to TF-M's SE_BL2_BANK_1_OFFSET define (tfm/platform/ext/target/arm/corstone1000/partition/flash_layout.h)
|
||||
part --source empty --size 144k --offset 16392k --align 4 --part-name="bl2_secondary" --uuid 3F0C49A4-48B7-4D1E-AF59-3E4A3CE1BA9F --part-type 64BD8ADB-02C0-4819-8688-03AB4CAB0ED9
|
||||
part --source empty --size 320k --align 4 --part-name="tfm_secondary" --uuid 009A6A12-64A6-4F0F-9882-57CD79A34A3D --part-type D763C27F-07F6-4FF0-B2F3-060CB465CD4E
|
||||
part --source empty --size 2 --align 4 --part-name="FIP_B" --uuid 9424E370-7BC9-43BB-8C23-71EE645E1273 --part-type B5EB19BD-CF56-45E8-ABA7-7ADB228FFEA7
|
||||
part --source empty --size 12 --align 4 --part-name="kernel_secondary" --uuid A2698A91-F9B1-4629-9188-94E4520808F8 --part-type 8197561D-6124-46FC-921E-141CC5745B05
|
||||
|
||||
part --source rawcopy --size 12 --sourceparams="file=Image.gz-initramfs-${MACHINE}.bin" --align 4 --part-name="kernel_primary" --uuid BF7A6142-0662-47FD-9434-6A8811980816 --part-type F771AFF9-C7E9-5F99-9EDA-2369DD694F61
|
||||
|
||||
# This ensures wic sets the size of the flash as 64MiB in the GPT header, despite only half being filled
|
||||
part --source empty --size 3k --offset 32748k --part-name="reserved_2" --uuid CCB18569-C0BA-42E0-A429-FE1DC862D660
|
||||
|
||||
bootloader --ptable gpt
|
||||
@@ -0,0 +1,34 @@
|
||||
# WIC partitioning for corstone1000 internal flash
|
||||
# Layout and maximum sizes (to be defined):
|
||||
#
|
||||
|
||||
# The entries with --offset parameter should not be relocated
|
||||
# because BL1 code is statically configured for the given positions
|
||||
# Partition sizes are fixed since corstone1000 does not support partial update
|
||||
# and has a limit for each partition to grow.
|
||||
|
||||
part --source empty --size 3k --offset 17k --part-name="reserved_1" --uuid B1F2FC8C-A7A3-4485-87CB-16961B8847D7
|
||||
|
||||
part --source empty --size 4k --align 4 --offset 20k --part-name="FWU-Metadata" --uuid 3FDFFEE1-3223-4C6B-80F9-B0E7D780C21D --part-type 8A7A84A0-8387-40F6-AB41-A8B9A5A60D23
|
||||
part --source empty --size 4k --align 4 --offset 24k --part-name="Bkup-FWU-Metadata" --uuid B3068316-5351-4998-823A-3A7B09133EC1 --part-type 8A7A84A0-8387-40F6-AB41-A8B9A5A60D23
|
||||
part --source empty --size 4k --align 4 --offset 28k --part-name="private_metadata_replica_1" --uuid 3CC3B456-DEC8-4CE3-BC5C-965483CE4828 --part-type ECB55DC3-8AB7-4A84-AB56-EB0A9974DB42
|
||||
part --source empty --size 4k --align 4 --offset 32k --part-name="private_metadata_replica_2" --uuid DCE9C503-8DFD-4DCB-8889-647E49641552 --part-type ECB55DC3-8AB7-4A84-AB56-EB0A9974DB42
|
||||
|
||||
# The partition type of each of these four partitions should match the type of the images
|
||||
# in a fiwmare update capsule
|
||||
# The size has to be aligned to TF-M's SE_BL2_PARTITION_SIZE (tfm/platform/ext/target/arm/corstone1000/partition/flash_layout.h)
|
||||
part --source rawcopy --size 144k --sourceparams="file=trusted-firmware-m/bl2_signed.bin" --offset 36k --align 4 --part-name="bl2_primary" --uuid 9A3A8FBF-55EF-439C-80C9-A3F728033929 --part-type FBFBEFAA-0A56-50D5-B651-74091D3D62CF
|
||||
|
||||
# The size has to be aligned to TF-M's TFM_PARTITION_SIZE (tfm/platform/ext/target/arm/corstone1000/partition/flash_layout.h)
|
||||
part --source rawcopy --size 320k --sourceparams="file=trusted-firmware-m/tfm_s_signed.bin" --align 4 --part-name="tfm_primary" --uuid 07F9616C-1233-439C-ACBA-72D75421BF70 --part-type AF4CC7AD-EE2E-5A39-AAD5-FAC8A1E6173C
|
||||
|
||||
# Rawcopy of the FIP binary
|
||||
part --source rawcopy --size 2 --sourceparams="file=signed_fip.bin" --align 4 --part-name="FIP_A" --uuid B9C7AC9D-40FF-4675-956B-EEF4DE9DF1C5 --part-type 55302F96-C4F0-5CF9-8624-E7CC388F2B68
|
||||
|
||||
# Rawcopy of kernel with initramfs
|
||||
part --source rawcopy --size 12 --sourceparams="file=Image.gz-initramfs-${MACHINE}.bin" --align 4 --part-name="kernel_primary" --uuid BF7A6142-0662-47FD-9434-6A8811980816 --part-type 3E8AC972-C33C-5CC9-90A0-CDD3159683EA
|
||||
|
||||
# This ensures wic sets the size of the flash as 64MiB in the GPT header, despite only half being filled
|
||||
part --source empty --size 3k --offset 32748k --part-name="reserved_2" --uuid CCB18569-C0BA-42E0-A429-FE1DC862D660
|
||||
|
||||
bootloader --ptable gpt
|
||||
Reference in New Issue
Block a user