Initial commit
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
From 0ee6842d348e206d511ec89a7ff5b29a6f325456 Mon Sep 17 00:00:00 2001
|
||||
From: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
Date: Sun, 29 Jan 2023 19:01:08 +0000
|
||||
Subject: [PATCH] corstone1000: make sure to write fwu metadata to replica 2
|
||||
|
||||
u-boot and other, before using fwu metadata validate if
|
||||
the copies in both replicas are good. so, make sure
|
||||
we write fwu metadata in both replicas.
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20550]
|
||||
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
---
|
||||
.../arm/corstone1000/fw_update_agent/fwu_agent.c | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
index e1fa297ac923..215902ce71b9 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
@@ -238,6 +238,20 @@ static enum fwu_agent_error_t metadata_write(
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
|
||||
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
+ FWU_METADATA_REPLICA_2_OFFSET, sizeof(struct fwu_metadata));
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_2_OFFSET);
|
||||
+ if (ret != ARM_DRIVER_OK) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_2_OFFSET,
|
||||
+ p_metadata, sizeof(struct fwu_metadata));
|
||||
+ if (ret < 0 || ret != sizeof(struct fwu_metadata)) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
FWU_LOG_MSG("%s: success: active = %u, previous = %d\n\r", __func__,
|
||||
p_metadata->active_index, p_metadata->previous_active_index);
|
||||
return FWU_AGENT_SUCCESS;
|
||||
--
|
||||
2.39.1
|
||||
|
||||
+307
@@ -0,0 +1,307 @@
|
||||
From 4a4d1b0a5a2455ad799a45f7f87c0c9fd0173034 Mon Sep 17 00:00:00 2001
|
||||
From: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
Date: Wed, 29 Mar 2023 10:58:32 +0100
|
||||
Subject: [PATCH] Platform: Corstone1000: get fwu and private metadata from gpt
|
||||
|
||||
Read and Write the FWU metadata and private metadata using instead
|
||||
static flash offsets get the partitions and start address from gpt
|
||||
partition table.
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20551]
|
||||
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
---
|
||||
.../target/arm/corstone1000/CMakeLists.txt | 7 ++
|
||||
.../corstone1000/fw_update_agent/fwu_agent.c | 90 +++++++++++++++----
|
||||
.../target/arm/corstone1000/partition/efi.h | 1 +
|
||||
.../arm/corstone1000/partition/partition.c | 14 +++
|
||||
.../arm/corstone1000/partition/partition.h | 1 +
|
||||
.../ext/target/arm/corstone1000/platform.h | 5 ++
|
||||
6 files changed, 99 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt
|
||||
index 19863bcdb6d2..f232c7639bd5 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/CMakeLists.txt
|
||||
+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt
|
||||
@@ -64,6 +64,8 @@ target_include_directories(platform_s
|
||||
cc312
|
||||
fw_update_agent
|
||||
soft_crc
|
||||
+ io
|
||||
+ partition
|
||||
)
|
||||
|
||||
target_sources(platform_s
|
||||
@@ -81,6 +83,11 @@ target_sources(platform_s
|
||||
fw_update_agent/fwu_agent.c
|
||||
fw_update_agent/uefi_fmp.c
|
||||
soft_crc/soft_crc.c
|
||||
+ io/io_block.c
|
||||
+ io/io_flash.c
|
||||
+ io/io_storage.c
|
||||
+ partition/partition.c
|
||||
+ partition/gpt.c
|
||||
$<$<NOT:$<BOOL:${PLATFORM_DEFAULT_OTP}>>:${PLATFORM_DIR}/ext/accelerator/cc312/otp_cc312.c>
|
||||
)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
index b6ed656de833..9c76b25a3a38 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "region_defs.h"
|
||||
#include "uefi_capsule_parser.h"
|
||||
#include "flash_common.h"
|
||||
+#include "partition.h"
|
||||
+#include "platform.h"
|
||||
#include "platform_base_address.h"
|
||||
#include "platform_description.h"
|
||||
#include "tfm_plat_nv_counters.h"
|
||||
@@ -146,6 +148,8 @@ extern ARM_DRIVER_FLASH FWU_METADATA_FLASH_DEV;
|
||||
static enum fwu_agent_error_t private_metadata_read(
|
||||
struct fwu_private_metadata* p_metadata)
|
||||
{
|
||||
+ partition_entry_t *part;
|
||||
+ uuid_t private_uuid = PRIVATE_METADATA_TYPE_UUID;
|
||||
int ret;
|
||||
|
||||
FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
@@ -154,7 +158,13 @@ static enum fwu_agent_error_t private_metadata_read(
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
|
||||
- ret = FWU_METADATA_FLASH_DEV.ReadData(FWU_PRIVATE_METADATA_REPLICA_1_OFFSET, p_metadata,
|
||||
+ part = get_partition_entry_by_type(&private_uuid);
|
||||
+ if (!part) {
|
||||
+ FWU_LOG_MSG("Private metadata partition not found\n\r");
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ReadData(part->start, p_metadata,
|
||||
sizeof(struct fwu_private_metadata));
|
||||
if (ret < 0 || ret != sizeof(struct fwu_private_metadata)) {
|
||||
return FWU_AGENT_ERROR;
|
||||
@@ -169,6 +179,8 @@ static enum fwu_agent_error_t private_metadata_read(
|
||||
static enum fwu_agent_error_t private_metadata_write(
|
||||
struct fwu_private_metadata* p_metadata)
|
||||
{
|
||||
+ uuid_t private_uuid = PRIVATE_METADATA_TYPE_UUID;
|
||||
+ partition_entry_t *part;
|
||||
int ret;
|
||||
|
||||
FWU_LOG_MSG("%s: enter: boot_index = %u\n\r", __func__,
|
||||
@@ -178,12 +190,18 @@ static enum fwu_agent_error_t private_metadata_write(
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
|
||||
- ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_PRIVATE_METADATA_REPLICA_1_OFFSET);
|
||||
+ part = get_partition_entry_by_type(&private_uuid);
|
||||
+ if (!part) {
|
||||
+ FWU_LOG_MSG("Private metadata partition not found\n\r");
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(part->start);
|
||||
if (ret != ARM_DRIVER_OK) {
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
|
||||
- ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_PRIVATE_METADATA_REPLICA_1_OFFSET,
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(part->start,
|
||||
p_metadata, sizeof(struct fwu_private_metadata));
|
||||
if (ret < 0 || ret != sizeof(struct fwu_private_metadata)) {
|
||||
return FWU_AGENT_ERROR;
|
||||
@@ -219,16 +237,25 @@ static enum fwu_agent_error_t metadata_validate(struct fwu_metadata *p_metadata)
|
||||
|
||||
static enum fwu_agent_error_t metadata_read_without_validation(struct fwu_metadata *p_metadata)
|
||||
{
|
||||
+ uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID;
|
||||
+ partition_entry_t *part;
|
||||
int ret;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
- FWU_METADATA_REPLICA_1_OFFSET, sizeof(struct fwu_metadata));
|
||||
-
|
||||
if (!p_metadata) {
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
|
||||
- ret = FWU_METADATA_FLASH_DEV.ReadData(FWU_METADATA_REPLICA_1_OFFSET,
|
||||
+ part = get_partition_entry_by_type(&metadata_uuid);
|
||||
+ if (!part) {
|
||||
+ FWU_LOG_MSG("%s: FWU metadata partition not found\n\r", __func__);
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
+ part->start, sizeof(struct fwu_metadata));
|
||||
+
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ReadData(part->start,
|
||||
p_metadata, sizeof(struct fwu_metadata));
|
||||
if (ret < 0 || ret != sizeof(struct fwu_metadata)) {
|
||||
return FWU_AGENT_ERROR;
|
||||
@@ -242,16 +269,24 @@ static enum fwu_agent_error_t metadata_read_without_validation(struct fwu_metada
|
||||
|
||||
static enum fwu_agent_error_t metadata_read(struct fwu_metadata *p_metadata)
|
||||
{
|
||||
+ uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID;
|
||||
+ partition_entry_t *part;
|
||||
int ret;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
- FWU_METADATA_REPLICA_1_OFFSET, sizeof(struct fwu_metadata));
|
||||
-
|
||||
if (!p_metadata) {
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
|
||||
- ret = FWU_METADATA_FLASH_DEV.ReadData(FWU_METADATA_REPLICA_1_OFFSET,
|
||||
+ part = get_partition_entry_by_type(&metadata_uuid);
|
||||
+ if (!part) {
|
||||
+ FWU_LOG_MSG("%s: FWU metadata partition not found\n\r", __func__);
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
+ part->start, sizeof(struct fwu_metadata));
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ReadData(part->start,
|
||||
p_metadata, sizeof(struct fwu_metadata));
|
||||
if (ret < 0 || ret != sizeof(struct fwu_metadata)) {
|
||||
return FWU_AGENT_ERROR;
|
||||
@@ -270,35 +305,49 @@ static enum fwu_agent_error_t metadata_read(struct fwu_metadata *p_metadata)
|
||||
static enum fwu_agent_error_t metadata_write(
|
||||
struct fwu_metadata *p_metadata)
|
||||
{
|
||||
+ uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID;
|
||||
+ partition_entry_t *part;
|
||||
int ret;
|
||||
|
||||
- FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
- FWU_METADATA_REPLICA_1_OFFSET, sizeof(struct fwu_metadata));
|
||||
-
|
||||
if (!p_metadata) {
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
|
||||
- ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_1_OFFSET);
|
||||
+ part = get_partition_entry_by_type(&metadata_uuid);
|
||||
+ if (!part) {
|
||||
+ FWU_LOG_MSG("%s: FWU metadata partition not found\n\r", __func__);
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
+ part->start, sizeof(struct fwu_metadata));
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(part->start);
|
||||
if (ret != ARM_DRIVER_OK) {
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
|
||||
- ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_1_OFFSET,
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(part->start,
|
||||
p_metadata, sizeof(struct fwu_metadata));
|
||||
if (ret < 0 || ret != sizeof(struct fwu_metadata)) {
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
|
||||
+ part = get_partition_replica_by_type(&metadata_uuid);
|
||||
+ if (!part) {
|
||||
+ FWU_LOG_MSG("%s: FWU metadata replica partition not found\n\r", __func__);
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
- FWU_METADATA_REPLICA_2_OFFSET, sizeof(struct fwu_metadata));
|
||||
+ part->start, sizeof(struct fwu_metadata));
|
||||
|
||||
- ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_2_OFFSET);
|
||||
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(part->start);
|
||||
if (ret != ARM_DRIVER_OK) {
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
|
||||
- ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_2_OFFSET,
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(part->start,
|
||||
p_metadata, sizeof(struct fwu_metadata));
|
||||
if (ret < 0 || ret != sizeof(struct fwu_metadata)) {
|
||||
return FWU_AGENT_ERROR;
|
||||
@@ -355,6 +404,9 @@ enum fwu_agent_error_t fwu_metadata_provision(void)
|
||||
|
||||
FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
|
||||
+ plat_io_storage_init();
|
||||
+ partition_init(PLATFORM_GPT_IMAGE);
|
||||
+
|
||||
ret = fwu_metadata_init();
|
||||
if (ret) {
|
||||
return ret;
|
||||
diff --git a/platform/ext/target/arm/corstone1000/partition/efi.h b/platform/ext/target/arm/corstone1000/partition/efi.h
|
||||
index f66daffb32d6..7e6a4bc883e6 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/partition/efi.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/partition/efi.h
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef DRIVERS_PARTITION_EFI_H
|
||||
#define DRIVERS_PARTITION_EFI_H
|
||||
|
||||
+#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "uuid.h"
|
||||
diff --git a/platform/ext/target/arm/corstone1000/partition/partition.c b/platform/ext/target/arm/corstone1000/partition/partition.c
|
||||
index afc6aa1c5cb8..d76e123d728f 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/partition/partition.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/partition/partition.c
|
||||
@@ -293,6 +293,20 @@ const partition_entry_t *get_partition_entry_by_type(const uuid_t *type_uuid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+const partition_entry_t *get_partition_replica_by_type(const uuid_t *type_uuid) {
|
||||
+ int count = 0;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < list.entry_count; i++) {
|
||||
+ if (guidcmp(type_uuid, &list.list[i].type_guid) == 0) {
|
||||
+ if (++count == 2)
|
||||
+ return &list.list[i];
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
const partition_entry_t *get_partition_entry_by_uuid(const uuid_t *part_uuid) {
|
||||
int i;
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/partition/partition.h b/platform/ext/target/arm/corstone1000/partition/partition.h
|
||||
index 54af47aca415..450cf20a073c 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/partition/partition.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/partition/partition.h
|
||||
@@ -40,6 +40,7 @@ typedef struct partition_entry_list {
|
||||
int load_partition_table(unsigned int image_id);
|
||||
const partition_entry_t *get_partition_entry(const char *name);
|
||||
const partition_entry_t *get_partition_entry_by_type(const uuid_t *type_guid);
|
||||
+const partition_entry_t *get_partition_replica_by_type(const uuid_t *type_uuid);
|
||||
const partition_entry_t *get_partition_entry_by_uuid(const uuid_t *part_uuid);
|
||||
const partition_entry_list_t *get_partition_entry_list(void);
|
||||
void partition_init(unsigned int image_id);
|
||||
diff --git a/platform/ext/target/arm/corstone1000/platform.h b/platform/ext/target/arm/corstone1000/platform.h
|
||||
index 894f5e309029..a88093ed4f9d 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/platform.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/platform.h
|
||||
@@ -13,6 +13,11 @@ typedef enum {
|
||||
PLATFORM_IMAGE_COUNT,
|
||||
}platform_image_id_t;
|
||||
|
||||
+#define FWU_METADATA_TYPE_UUID \
|
||||
+ ((uuid_t){{0xa0, 0x84, 0x7a, 0x8a}, {0x87, 0x83}, {0xf6, 0x40}, 0xab, 0x41, {0xa8, 0xb9, 0xa5, 0xa6, 0x0d, 0x23}})
|
||||
+#define PRIVATE_METADATA_TYPE_UUID \
|
||||
+ ((uuid_t){{0xc3, 0x5d, 0xb5, 0xec}, {0xb7, 0x8a}, {0x84, 0x4a}, 0xab, 0x56, {0xeb, 0x0a, 0x99, 0x74, 0xdb, 0x42}})
|
||||
+
|
||||
/* Initialize io storage of the platform */
|
||||
int32_t plat_io_storage_init(void);
|
||||
|
||||
--
|
||||
2.40.0
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
From 33d8f45c8f14e9e0d7add7d2804ed76c7d7fd0c2 Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Sat, 25 Feb 2023 09:04:38 +0000
|
||||
Subject: [PATCH 1/7] Platform: corstone1000: Add watchdog_reset_timer
|
||||
|
||||
From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
|
||||
Implement watchdog_reset_timer
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20552]
|
||||
Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Change-Id: I2684ca54f9a456b22efcbcd364abef3537d4c91f
|
||||
---
|
||||
.../arm/corstone1000/Native_Driver/watchdog.c | 17 +++++++++++++++++
|
||||
1 file changed, 17 insertions(+)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c
|
||||
index 4e024a3b1..f6e182194 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/Native_Driver/watchdog.c
|
||||
@@ -80,6 +80,23 @@ int corstone1000_watchdog_init()
|
||||
return ARM_DRIVER_OK;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * \brief Reset the Secure Enclave & SoC Watchdog's.
|
||||
+ *
|
||||
+ * \returns ARM Driver return code.
|
||||
+ */
|
||||
+int corstone1000_watchdog_reset_timer() {
|
||||
+ /* Unlock, clear and lock the watchdog timer */
|
||||
+ arm_watchdog_unlock(&SE_WD_DEV);
|
||||
+ arm_watchdog_clear_interrupt_and_refresh_counter(&SE_WD_DEV);
|
||||
+ arm_watchdog_lock(&SE_WD_DEV);
|
||||
+ /* Unlock, clear and lock the watchdog timer */
|
||||
+ arm_watchdog_unlock(&SOC_WD_DEV);
|
||||
+ arm_watchdog_clear_interrupt_and_refresh_counter(&SOC_WD_DEV);
|
||||
+ arm_watchdog_lock(&SOC_WD_DEV);
|
||||
+ return ARM_DRIVER_OK;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Secure Host Watchdog WS1 Handler
|
||||
* efi_reset_system from the host triggers "Secure
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+1034
File diff suppressed because it is too large
Load Diff
+202
@@ -0,0 +1,202 @@
|
||||
From d5a7cde4648d2247f83a0f259aa088152199dfbd Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Mon, 27 Feb 2023 20:58:30 +0000
|
||||
Subject: [PATCH 2/6] Platform: corstone1000: Replace MCUBOOT BL1 by TFM's
|
||||
(BL2)
|
||||
|
||||
From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
|
||||
Set region_defs of BL2 correctly
|
||||
Set FLASH Areas 0 and 1 to have BL2
|
||||
Set FLASH Areas 2 and 3 to have TFM
|
||||
Set FLASH Areas 4 and 5 to have FIP
|
||||
Initialize FLASH in BL1_2 boot platform code
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20554]
|
||||
Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Change-Id: I987d29cb6318b8b30cafab67d24f446aaadfe500
|
||||
---
|
||||
.../arm/corstone1000/bl1/boot_hal_bl1.c | 14 +++++++
|
||||
.../target/arm/corstone1000/bl2_flash_map.c | 8 ++--
|
||||
.../ext/target/arm/corstone1000/config.cmake | 3 ++
|
||||
.../arm/corstone1000/partition/flash_layout.h | 41 +++++++++++++------
|
||||
.../arm/corstone1000/partition/region_defs.h | 4 +-
|
||||
5 files changed, 51 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c b/platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c
|
||||
index 678342443..2124720b2 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bl1/boot_hal_bl1.c
|
||||
@@ -638,6 +638,13 @@ int32_t boot_platform_init(void)
|
||||
|
||||
int32_t boot_platform_post_init(void)
|
||||
{
|
||||
+ int32_t result;
|
||||
+ if (platform_code_is_bl1_2) {
|
||||
+ result = FLASH_DEV_NAME.Initialize(NULL);
|
||||
+ if (result != ARM_DRIVER_OK) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+ }
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -665,6 +672,13 @@ void boot_platform_quit(struct boot_arm_vector_table *vt)
|
||||
stdio_uninit();
|
||||
#endif /* defined(TFM_BL1_LOGGING) || defined(TEST_BL1_1) || defined(TEST_BL1_2) */
|
||||
|
||||
+ if (platform_code_is_bl1_2) {
|
||||
+ result = FLASH_DEV_NAME.Uninitialize();
|
||||
+ if (result != ARM_DRIVER_OK) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
result = corstone1000_watchdog_reset_timer();
|
||||
if (result != ARM_DRIVER_OK) {
|
||||
while (1);
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bl2_flash_map.c b/platform/ext/target/arm/corstone1000/bl2_flash_map.c
|
||||
index 599f80b41..2b1cdfa19 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bl2_flash_map.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bl2_flash_map.c
|
||||
@@ -25,14 +25,14 @@ extern ARM_DRIVER_FLASH FLASH_DEV_NAME;
|
||||
*/
|
||||
struct flash_area flash_map[] = {
|
||||
{
|
||||
- .fa_id = FLASH_AREA_0_ID,
|
||||
+ .fa_id = FLASH_AREA_2_ID,
|
||||
.fa_device_id = FLASH_DEVICE_ID,
|
||||
.fa_driver = &FLASH_DEV_NAME,
|
||||
.fa_off = FLASH_INVALID_OFFSET,
|
||||
.fa_size = FLASH_INVALID_SIZE,
|
||||
},
|
||||
{
|
||||
- .fa_id = FLASH_AREA_1_ID,
|
||||
+ .fa_id = FLASH_AREA_3_ID,
|
||||
.fa_device_id = FLASH_DEVICE_ID,
|
||||
.fa_driver = &FLASH_DEV_NAME,
|
||||
.fa_off = FLASH_INVALID_OFFSET,
|
||||
@@ -40,14 +40,14 @@ struct flash_area flash_map[] = {
|
||||
},
|
||||
#ifndef TFM_S_REG_TEST
|
||||
{
|
||||
- .fa_id = FLASH_AREA_2_ID,
|
||||
+ .fa_id = FLASH_AREA_4_ID,
|
||||
.fa_device_id = FLASH_DEVICE_ID,
|
||||
.fa_driver = &FLASH_DEV_NAME,
|
||||
.fa_off = FLASH_INVALID_OFFSET,
|
||||
.fa_size = FLASH_INVALID_SIZE,
|
||||
},
|
||||
{
|
||||
- .fa_id = FLASH_AREA_3_ID,
|
||||
+ .fa_id = FLASH_AREA_5_ID,
|
||||
.fa_device_id = FLASH_DEVICE_ID,
|
||||
.fa_driver = &FLASH_DEV_NAME,
|
||||
.fa_off = FLASH_INVALID_OFFSET,
|
||||
diff --git a/platform/ext/target/arm/corstone1000/config.cmake b/platform/ext/target/arm/corstone1000/config.cmake
|
||||
index 1b0675404..bec6b84f0 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/config.cmake
|
||||
+++ b/platform/ext/target/arm/corstone1000/config.cmake
|
||||
@@ -16,6 +16,9 @@ set(TFM_BL1_SOFTWARE_CRYPTO OFF CACHE BOOL "Whether BL1_1
|
||||
set(TFM_BL1_MEMORY_MAPPED_FLASH OFF CACHE BOOL "Whether BL1 can directly access flash content")
|
||||
set(TFM_BL1_PQ_CRYPTO OFF CACHE BOOL "Enable LMS PQ crypto for BL2 verification. This is experimental and should not yet be used in production")
|
||||
|
||||
+set(TFM_BL2_IMAGE_FLASH_AREA_NUM 0 CACHE STRING "Which flash area BL2 is stored in")
|
||||
+set(MCUBOOT_S_IMAGE_FLASH_AREA_NUM 2 CACHE STRING "ID of the flash area containing the primary Secure image")
|
||||
+
|
||||
set(BL2 ON CACHE BOOL "Whether to build BL2")
|
||||
set(BL2_TRAILER_SIZE 0x800 CACHE STRING "Trailer size")
|
||||
set(DEFAULT_MCUBOOT_FLASH_MAP OFF CACHE BOOL "Whether to use the default flash map defined by TF-M project")
|
||||
diff --git a/platform/ext/target/arm/corstone1000/partition/flash_layout.h b/platform/ext/target/arm/corstone1000/partition/flash_layout.h
|
||||
index a95ff63ef..41b4c6323 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/partition/flash_layout.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/partition/flash_layout.h
|
||||
@@ -136,23 +136,38 @@
|
||||
#define BANK_PARTITION_SIZE (0xFE0000) /* 15.875 MB */
|
||||
#define TFM_PARTITION_SIZE (0x5E000) /* 376 KB */
|
||||
|
||||
-/* Macros needed to imgtool.py, used when creating BL2 signed image */
|
||||
-#define BL2_IMAGE_LOAD_ADDRESS (SRAM_BASE + TFM_PARTITION_SIZE + BL2_DATA_GAP_SIZE)
|
||||
-#define BL2_IMAGE_OFFSET (0x0)
|
||||
-#define BL2_IMAGE_MAX_SIZE (SE_BL2_PARTITION_SIZE)
|
||||
+/************************************************************/
|
||||
+/* Bank : Images flash offsets are with respect to the bank */
|
||||
+/************************************************************/
|
||||
|
||||
-/* Image 1: TF-M primary and secondary images */
|
||||
+/* Image 0: BL2 primary and secondary images */
|
||||
#define FLASH_AREA_0_ID (1)
|
||||
-#define FLASH_AREA_0_SIZE (TFM_PARTITION_SIZE)
|
||||
+#define FLASH_AREA_0_OFFSET (0) /* starting from 0th offset of the bank */
|
||||
+#define FLASH_AREA_0_SIZE (SE_BL2_PARTITION_SIZE)
|
||||
+
|
||||
#define FLASH_AREA_1_ID (FLASH_AREA_0_ID + 1)
|
||||
-#define FLASH_AREA_1_SIZE (TFM_PARTITION_SIZE)
|
||||
+#define FLASH_AREA_1_OFFSET (FLASH_AREA_0_OFFSET + FLASH_AREA_0_SIZE)
|
||||
+#define FLASH_AREA_1_SIZE (SE_BL2_PARTITION_SIZE)
|
||||
+
|
||||
+/* Image 1: TF-M primary and secondary images */
|
||||
+#define FLASH_AREA_2_ID (1)
|
||||
+#define FLASH_AREA_2_SIZE (TFM_PARTITION_SIZE)
|
||||
+#define FLASH_AREA_3_ID (FLASH_AREA_2_ID + 1)
|
||||
+#define FLASH_AREA_3_SIZE (TFM_PARTITION_SIZE)
|
||||
|
||||
/* Image 2: Host FIP */
|
||||
#define FIP_SIGNATURE_AREA_SIZE (0x1000) /* 4 KB */
|
||||
|
||||
/* Host BL2 (TF-A) primary and secondary image. */
|
||||
-#define FLASH_AREA_2_ID (FLASH_AREA_1_ID + 1)
|
||||
-#define FLASH_AREA_3_ID (FLASH_AREA_2_ID + 1)
|
||||
+#define FLASH_AREA_4_ID (FLASH_AREA_3_ID + 1)
|
||||
+#define FLASH_AREA_5_ID (FLASH_AREA_4_ID + 1)
|
||||
+
|
||||
+#define BL1_FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? FLASH_AREA_0_ID : \
|
||||
+ 255 )
|
||||
+#define BL1_FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? FLASH_AREA_1_ID : \
|
||||
+ 255 )
|
||||
+
|
||||
+#define BL1_FLASH_AREA_IMAGE_SCRATCH 255
|
||||
|
||||
/* Macros needed to imgtool.py, used when creating TF-M signed image */
|
||||
#define S_IMAGE_LOAD_ADDRESS (SRAM_BASE)
|
||||
@@ -161,11 +176,11 @@
|
||||
#define NON_SECURE_IMAGE_OFFSET (TFM_PARTITION_SIZE)
|
||||
#define NON_SECURE_IMAGE_MAX_SIZE (0x0)
|
||||
|
||||
-#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? FLASH_AREA_0_ID : \
|
||||
- ((x) == 1) ? FLASH_AREA_2_ID : \
|
||||
+#define FLASH_AREA_IMAGE_PRIMARY(x) (((x) == 0) ? FLASH_AREA_2_ID : \
|
||||
+ ((x) == 1) ? FLASH_AREA_4_ID : \
|
||||
255 )
|
||||
-#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? FLASH_AREA_1_ID : \
|
||||
- ((x) == 1) ? FLASH_AREA_3_ID : \
|
||||
+#define FLASH_AREA_IMAGE_SECONDARY(x) (((x) == 0) ? FLASH_AREA_3_ID : \
|
||||
+ ((x) == 1) ? FLASH_AREA_5_ID : \
|
||||
255 )
|
||||
|
||||
#define FLASH_AREA_IMAGE_SCRATCH 255
|
||||
diff --git a/platform/ext/target/arm/corstone1000/partition/region_defs.h b/platform/ext/target/arm/corstone1000/partition/region_defs.h
|
||||
index 8157c36bf..fc9f734f6 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/partition/region_defs.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/partition/region_defs.h
|
||||
@@ -48,7 +48,7 @@
|
||||
(TFM_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
|
||||
|
||||
#define IMAGE_BL2_CODE_SIZE \
|
||||
- (SE_BL2_PARTITION_SIZE - BL2_HEADER_SIZE - BL2_TRAILER_SIZE)
|
||||
+ (SE_BL2_PARTITION_SIZE - BL1_HEADER_SIZE - BL1_TRAILER_SIZE)
|
||||
|
||||
/* Secure regions */
|
||||
#define S_CODE_START (SRAM_BASE + BL2_HEADER_SIZE)
|
||||
@@ -86,7 +86,7 @@
|
||||
|
||||
/* SE BL2 regions */
|
||||
#define BL2_IMAGE_START (SRAM_BASE + SRAM_SIZE - SE_BL2_PARTITION_SIZE)
|
||||
-#define BL2_CODE_START (BL2_IMAGE_START + BL2_HEADER_SIZE)
|
||||
+#define BL2_CODE_START (BL2_IMAGE_START + BL1_HEADER_SIZE)
|
||||
#define BL2_CODE_SIZE (IMAGE_BL2_CODE_SIZE)
|
||||
#define BL2_CODE_LIMIT (BL2_CODE_START + BL2_CODE_SIZE - 1)
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
From 535d366137d2dd0804d3e67ada78151e0e318eeb Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Fri, 3 Mar 2023 12:25:04 +0000
|
||||
Subject: [PATCH 3/6] Platform: corstone1000: Reorganize bl2 files
|
||||
|
||||
From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
|
||||
To be consistnant, organize bl2 files same as bl1 files
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20555]
|
||||
Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Change-Id: I3332f4dbbde1c5f2cde5a187b038dc3430b9503f
|
||||
---
|
||||
platform/ext/target/arm/corstone1000/CMakeLists.txt | 6 +++---
|
||||
.../ext/target/arm/corstone1000/{ => bl2}/boot_hal_bl2.c | 0
|
||||
.../corstone1000/{bl2_flash_map.c => bl2/flash_map_bl2.c} | 0
|
||||
.../{bl2_security_cnt.c => bl2/security_cnt_bl2.c} | 0
|
||||
4 files changed, 3 insertions(+), 3 deletions(-)
|
||||
rename platform/ext/target/arm/corstone1000/{ => bl2}/boot_hal_bl2.c (100%)
|
||||
rename platform/ext/target/arm/corstone1000/{bl2_flash_map.c => bl2/flash_map_bl2.c} (100%)
|
||||
rename platform/ext/target/arm/corstone1000/{bl2_security_cnt.c => bl2/security_cnt_bl2.c} (100%)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/CMakeLists.txt b/platform/ext/target/arm/corstone1000/CMakeLists.txt
|
||||
index a4fe28c08..3d4c787a6 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/CMakeLists.txt
|
||||
+++ b/platform/ext/target/arm/corstone1000/CMakeLists.txt
|
||||
@@ -196,7 +196,7 @@ target_sources(platform_bl2
|
||||
Native_Driver/arm_watchdog_drv.c
|
||||
fip_parser/fip_parser.c
|
||||
fw_update_agent/fwu_agent.c
|
||||
- bl2_security_cnt.c
|
||||
+ bl2/security_cnt_bl2.c
|
||||
$<$<NOT:$<BOOL:${PLATFORM_DEFAULT_OTP}>>:${PLATFORM_DIR}/ext/accelerator/cc312/otp_cc312.c>
|
||||
io/io_block.c
|
||||
io/io_flash.c
|
||||
@@ -235,8 +235,8 @@ target_compile_definitions(platform_bl2
|
||||
# platform_init/quit* apis symbol collision in bl1.
|
||||
target_sources(bl2
|
||||
PRIVATE
|
||||
- bl2_flash_map.c
|
||||
- boot_hal_bl2.c
|
||||
+ bl2/flash_map_bl2.c
|
||||
+ bl2/boot_hal_bl2.c
|
||||
)
|
||||
|
||||
target_link_libraries(bl2
|
||||
diff --git a/platform/ext/target/arm/corstone1000/boot_hal_bl2.c b/platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c
|
||||
similarity index 100%
|
||||
rename from platform/ext/target/arm/corstone1000/boot_hal_bl2.c
|
||||
rename to platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bl2_flash_map.c b/platform/ext/target/arm/corstone1000/bl2/flash_map_bl2.c
|
||||
similarity index 100%
|
||||
rename from platform/ext/target/arm/corstone1000/bl2_flash_map.c
|
||||
rename to platform/ext/target/arm/corstone1000/bl2/flash_map_bl2.c
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bl2_security_cnt.c b/platform/ext/target/arm/corstone1000/bl2/security_cnt_bl2.c
|
||||
similarity index 100%
|
||||
rename from platform/ext/target/arm/corstone1000/bl2_security_cnt.c
|
||||
rename to platform/ext/target/arm/corstone1000/bl2/security_cnt_bl2.c
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
From 25b131f0d082b32b262c4e788f3bc95b7761bef7 Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Mon, 13 Mar 2023 00:16:49 +0000
|
||||
Subject: [PATCH 4/6] Platform: corstone1000: Fix linker script comment
|
||||
|
||||
From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
|
||||
Comment explaining the necessary defines to copy multiple ROM to RAM
|
||||
sections, was refering to the wrong file.
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20556]
|
||||
Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Change-Id: I3e5f806330481daa24c5456d9c956e0cf589afee
|
||||
---
|
||||
.../arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld | 2 +-
|
||||
.../arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld
|
||||
index d4eca2841..8ee334c6b 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld
|
||||
+++ b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld
|
||||
@@ -89,7 +89,7 @@ SECTIONS
|
||||
|
||||
/* To copy multiple ROM to RAM sections,
|
||||
* define etext2/data2_start/data2_end and
|
||||
- * define __STARTUP_COPY_MULTIPLE in startup_corstone700_bl2.S */
|
||||
+ * define __STARTUP_COPY_MULTIPLE in startup_corstone1000.c */
|
||||
.copy.table :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
diff --git a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld
|
||||
index 6cd806378..e1e4f2966 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld
|
||||
+++ b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld
|
||||
@@ -84,7 +84,7 @@ SECTIONS
|
||||
|
||||
/* To copy multiple ROM to RAM sections,
|
||||
* define etext2/data2_start/data2_end and
|
||||
- * define __STARTUP_COPY_MULTIPLE in startup_corstone700_bl2.S */
|
||||
+ * define __STARTUP_COPY_MULTIPLE in startup_corstone1000.c */
|
||||
.copy.table :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
From 7db7b197ec3f01163422450947540060d3cb0c17 Mon Sep 17 00:00:00 2001
|
||||
From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Date: Mon, 13 Mar 2023 00:21:44 +0000
|
||||
Subject: [PATCH 6/6] Platform: corstone1000: Fix linkerscripts copyright year
|
||||
|
||||
set the copyright year to 2023 as these files are introduced in
|
||||
2023.
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20557]
|
||||
Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Change-Id: I293a4a380d5d1d59aba1e2ab17e0e5924664dbb4
|
||||
---
|
||||
.../arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld | 2 +-
|
||||
.../arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld
|
||||
index 8ee334c6b..cb6797f27 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld
|
||||
+++ b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_1.ld
|
||||
@@ -1,5 +1,5 @@
|
||||
;/*
|
||||
-; * Copyright (c) 2009-2022, Arm Limited. All rights reserved.
|
||||
+; * Copyright (c) 2023, Arm Limited. All rights reserved.
|
||||
; *
|
||||
; * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
; * you may not use this file except in compliance with the License.
|
||||
diff --git a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld
|
||||
index e1e4f2966..e66e54aa6 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld
|
||||
+++ b/platform/ext/target/arm/corstone1000/Device/Source/gcc/corstone1000_bl1_2.ld
|
||||
@@ -1,5 +1,5 @@
|
||||
;/*
|
||||
-; * Copyright (c) 2009-2022, Arm Limited. All rights reserved.
|
||||
+; * Copyright (c) 2023, Arm Limited. All rights reserved.
|
||||
; *
|
||||
; * Licensed under the Apache License, Version 2.0 (the "License");
|
||||
; * you may not use this file except in compliance with the License.
|
||||
--
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
From 7914ec3f96dbb8228e791d9492cfc3651cf9deca Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Wed, 5 Apr 2023 10:28:57 +0100
|
||||
Subject: [PATCH] Platform: corstone1000: Fix Flash reading issue for FIP data
|
||||
|
||||
Fixes the flash reading issue since bl2 needs to read the data from
|
||||
flash in XIP mode on FPGA (mps3).
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20558]
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
---
|
||||
platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c b/platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c
|
||||
index cf6340c5a9..e4183c7a57 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/bl2/boot_hal_bl2.c
|
||||
@@ -89,6 +89,7 @@ static bool fill_flash_map_with_fip_data(uint8_t boot_index) {
|
||||
|
||||
/* parse directly from flash using XIP mode */
|
||||
/* FIP is large so its not a good idea to load it in memory */
|
||||
+ Select_XIP_Mode_For_Shared_Flash();
|
||||
result = parse_fip_and_extract_tfa_info(
|
||||
FLASH_BASE_ADDRESS + fip_offset + FIP_SIGNATURE_AREA_SIZE, fip_size,
|
||||
&tfa_offset, &tfa_size);
|
||||
@@ -96,7 +97,7 @@ static bool fill_flash_map_with_fip_data(uint8_t boot_index) {
|
||||
BOOT_LOG_ERR("parse_fip_and_extract_tfa_info failed");
|
||||
return false;
|
||||
}
|
||||
-
|
||||
+ Select_Write_Mode_For_Shared_Flash();
|
||||
flash_map[2].fa_off = fip_offset + FIP_SIGNATURE_AREA_SIZE + tfa_offset;
|
||||
flash_map[2].fa_size = tfa_size;
|
||||
flash_map[3].fa_off = flash_map[2].fa_off + flash_map[2].fa_size;
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+273
@@ -0,0 +1,273 @@
|
||||
From 11f6af40dc322630031511146763cc9059bdb805 Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Fri, 14 Apr 2023 16:35:55 +0100
|
||||
Subject: [PATCH] Platform: corstone1000: Adds compiler flags to FWU agent for
|
||||
BL1
|
||||
|
||||
Adds compiler flags for BL1 to fwu_agent.c functions to not use GPT parser and
|
||||
IO libraries in BL1 rom code.
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20559]
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
---
|
||||
.../corstone1000/fw_update_agent/fwu_agent.c | 176 +++++++++++++++++-
|
||||
1 file changed, 174 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
index 8ecb03d157..afd8d66e42 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
@@ -14,8 +14,6 @@
|
||||
#include "region_defs.h"
|
||||
#include "uefi_capsule_parser.h"
|
||||
#include "flash_common.h"
|
||||
-#include "partition.h"
|
||||
-#include "platform.h"
|
||||
#include "platform_base_address.h"
|
||||
#include "platform_description.h"
|
||||
#include "tfm_plat_nv_counters.h"
|
||||
@@ -23,6 +21,10 @@
|
||||
#include "uefi_fmp.h"
|
||||
#include "uart_stdout.h"
|
||||
#include "soft_crc.h"
|
||||
+#if !BL1
|
||||
+#include "partition.h"
|
||||
+#include "platform.h"
|
||||
+#endif
|
||||
|
||||
/* Properties of image in a bank */
|
||||
struct fwu_image_properties {
|
||||
@@ -145,6 +147,30 @@ extern ARM_DRIVER_FLASH FWU_METADATA_FLASH_DEV;
|
||||
|
||||
#define HOST_ACK_TIMEOUT_SEC (6 * 60) /* ~seconds, not exact */
|
||||
|
||||
+#if BL1
|
||||
+static enum fwu_agent_error_t private_metadata_read(
|
||||
+ struct fwu_private_metadata* p_metadata)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
+
|
||||
+ if (!p_metadata) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ReadData(FWU_PRIVATE_METADATA_REPLICA_1_OFFSET, p_metadata,
|
||||
+ sizeof(struct fwu_private_metadata));
|
||||
+ if (ret < 0 || ret != sizeof(struct fwu_private_metadata)) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: success: boot_index = %u\n\r", __func__,
|
||||
+ p_metadata->boot_index);
|
||||
+
|
||||
+ return FWU_AGENT_SUCCESS;
|
||||
+}
|
||||
+#elif
|
||||
static enum fwu_agent_error_t private_metadata_read(
|
||||
struct fwu_private_metadata* p_metadata)
|
||||
{
|
||||
@@ -175,7 +201,36 @@ static enum fwu_agent_error_t private_metadata_read(
|
||||
|
||||
return FWU_AGENT_SUCCESS;
|
||||
}
|
||||
+#endif
|
||||
|
||||
+#if BL1
|
||||
+static enum fwu_agent_error_t private_metadata_write(
|
||||
+ struct fwu_private_metadata* p_metadata)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: enter: boot_index = %u\n\r", __func__,
|
||||
+ p_metadata->boot_index);
|
||||
+
|
||||
+ if (!p_metadata) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_PRIVATE_METADATA_REPLICA_1_OFFSET);
|
||||
+ if (ret != ARM_DRIVER_OK) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_PRIVATE_METADATA_REPLICA_1_OFFSET,
|
||||
+ p_metadata, sizeof(struct fwu_private_metadata));
|
||||
+ if (ret < 0 || ret != sizeof(struct fwu_private_metadata)) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: success\n\r", __func__);
|
||||
+ return FWU_AGENT_SUCCESS;
|
||||
+}
|
||||
+#elif
|
||||
static enum fwu_agent_error_t private_metadata_write(
|
||||
struct fwu_private_metadata* p_metadata)
|
||||
{
|
||||
@@ -210,6 +265,7 @@ static enum fwu_agent_error_t private_metadata_write(
|
||||
FWU_LOG_MSG("%s: success\n\r", __func__);
|
||||
return FWU_AGENT_SUCCESS;
|
||||
}
|
||||
+#endif
|
||||
|
||||
static enum fwu_agent_error_t metadata_validate(struct fwu_metadata *p_metadata)
|
||||
{
|
||||
@@ -235,6 +291,30 @@ static enum fwu_agent_error_t metadata_validate(struct fwu_metadata *p_metadata)
|
||||
return FWU_AGENT_SUCCESS;
|
||||
}
|
||||
|
||||
+#if BL1
|
||||
+static enum fwu_agent_error_t metadata_read_without_validation(struct fwu_metadata *p_metadata)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
+ FWU_METADATA_REPLICA_1_OFFSET, sizeof(struct fwu_metadata));
|
||||
+
|
||||
+ if (!p_metadata) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ReadData(FWU_METADATA_REPLICA_1_OFFSET,
|
||||
+ p_metadata, sizeof(struct fwu_metadata));
|
||||
+ if (ret < 0 || ret != sizeof(struct fwu_metadata)) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: success: active = %u, previous = %d\n\r", __func__,
|
||||
+ p_metadata->active_index, p_metadata->previous_active_index);
|
||||
+
|
||||
+ return FWU_AGENT_SUCCESS;
|
||||
+}
|
||||
+#elif
|
||||
static enum fwu_agent_error_t metadata_read_without_validation(struct fwu_metadata *p_metadata)
|
||||
{
|
||||
uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID;
|
||||
@@ -266,7 +346,36 @@ static enum fwu_agent_error_t metadata_read_without_validation(struct fwu_metada
|
||||
|
||||
return FWU_AGENT_SUCCESS;
|
||||
}
|
||||
+#endif
|
||||
+
|
||||
+#if BL1
|
||||
+static enum fwu_agent_error_t metadata_read(struct fwu_metadata *p_metadata)
|
||||
+{
|
||||
+ int ret;
|
||||
|
||||
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
+ FWU_METADATA_REPLICA_1_OFFSET, sizeof(struct fwu_metadata));
|
||||
+
|
||||
+ if (!p_metadata) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ReadData(FWU_METADATA_REPLICA_1_OFFSET,
|
||||
+ p_metadata, sizeof(struct fwu_metadata));
|
||||
+ if (ret < 0 || ret != sizeof(struct fwu_metadata)) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ if (metadata_validate(p_metadata) != FWU_AGENT_SUCCESS) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: success: active = %u, previous = %d\n\r", __func__,
|
||||
+ p_metadata->active_index, p_metadata->previous_active_index);
|
||||
+
|
||||
+ return FWU_AGENT_SUCCESS;
|
||||
+}
|
||||
+#elif
|
||||
static enum fwu_agent_error_t metadata_read(struct fwu_metadata *p_metadata)
|
||||
{
|
||||
uuid_t metadata_uuid = FWU_METADATA_TYPE_UUID;
|
||||
@@ -301,7 +410,66 @@ static enum fwu_agent_error_t metadata_read(struct fwu_metadata *p_metadata)
|
||||
|
||||
return FWU_AGENT_SUCCESS;
|
||||
}
|
||||
+#endif
|
||||
+
|
||||
|
||||
+#if BL1
|
||||
+static enum fwu_agent_error_t metadata_write(
|
||||
+ struct fwu_metadata *p_metadata)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
+ FWU_METADATA_REPLICA_1_OFFSET, sizeof(struct fwu_metadata));
|
||||
+
|
||||
+ if (!p_metadata) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_1_OFFSET);
|
||||
+ if (ret != ARM_DRIVER_OK) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_1_OFFSET,
|
||||
+ p_metadata, sizeof(struct fwu_metadata));
|
||||
+ if (ret < 0 || ret != sizeof(struct fwu_metadata)) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
+ FWU_METADATA_REPLICA_2_OFFSET, sizeof(struct fwu_metadata));
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_2_OFFSET);
|
||||
+ if (ret != ARM_DRIVER_OK) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_2_OFFSET,
|
||||
+ p_metadata, sizeof(struct fwu_metadata));
|
||||
+ if (ret < 0 || ret != sizeof(struct fwu_metadata)) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: enter: flash addr = %u, size = %d\n\r", __func__,
|
||||
+ FWU_METADATA_REPLICA_2_OFFSET, sizeof(struct fwu_metadata));
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.EraseSector(FWU_METADATA_REPLICA_2_OFFSET);
|
||||
+ if (ret != ARM_DRIVER_OK) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ ret = FWU_METADATA_FLASH_DEV.ProgramData(FWU_METADATA_REPLICA_2_OFFSET,
|
||||
+ p_metadata, sizeof(struct fwu_metadata));
|
||||
+ if (ret < 0 || ret != sizeof(struct fwu_metadata)) {
|
||||
+ return FWU_AGENT_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ FWU_LOG_MSG("%s: success: active = %u, previous = %d\n\r", __func__,
|
||||
+ p_metadata->active_index, p_metadata->previous_active_index);
|
||||
+ return FWU_AGENT_SUCCESS;
|
||||
+}
|
||||
+#elif
|
||||
static enum fwu_agent_error_t metadata_write(
|
||||
struct fwu_metadata *p_metadata)
|
||||
{
|
||||
@@ -371,6 +539,8 @@ static enum fwu_agent_error_t metadata_write(
|
||||
p_metadata->active_index, p_metadata->previous_active_index);
|
||||
return FWU_AGENT_SUCCESS;
|
||||
}
|
||||
+#endif
|
||||
+
|
||||
|
||||
enum fwu_agent_error_t fwu_metadata_init(void)
|
||||
{
|
||||
@@ -418,8 +588,10 @@ enum fwu_agent_error_t fwu_metadata_provision(void)
|
||||
|
||||
FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
|
||||
+#if !BL1
|
||||
plat_io_storage_init();
|
||||
partition_init(PLATFORM_GPT_IMAGE);
|
||||
+#endif
|
||||
|
||||
ret = fwu_metadata_init();
|
||||
if (ret) {
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
From 148d82d0984273b30d8b148f0c4e0ad0d3f23062 Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Mon, 17 Apr 2023 12:07:55 +0100
|
||||
Subject: [PATCH 1/3] Platform: corstone1000: adjust PS asset configuration
|
||||
|
||||
Adjust protected storage asset configuration to be more inline
|
||||
with the one in trusted service side, that would make thinks
|
||||
work when testing and using more than the default variables.
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20560]
|
||||
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Change-Id: I181f9c72a816c727c2170c609100aec1d233fea7
|
||||
---
|
||||
platform/ext/target/arm/corstone1000/config.cmake | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/config.cmake b/platform/ext/target/arm/corstone1000/config.cmake
|
||||
index bec6b84f0..0c91fa59f 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/config.cmake
|
||||
+++ b/platform/ext/target/arm/corstone1000/config.cmake
|
||||
@@ -76,3 +76,4 @@ endif()
|
||||
# Platform-specific configurations
|
||||
set(CONFIG_TFM_USE_TRUSTZONE OFF)
|
||||
set(TFM_MULTI_CORE_TOPOLOGY ON)
|
||||
+set(PS_NUM_ASSETS "40" CACHE STRING "The maximum number of assets to be stored in the Protected Storage area")
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
From 34263d1ea99da7b8a680a80601a73149bc9530e5 Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Fri, 21 Apr 2023 15:17:21 +0100
|
||||
Subject: [PATCH] Platform: corstone1000: Increase number of assets
|
||||
|
||||
As Corstone1000 stores at boot time few efi variables.
|
||||
Therefore, number of assets is increased to compansate this early usage.
|
||||
|
||||
Upstream-Status: Submitted [https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/20656]
|
||||
Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Change-Id: Id8555a09335ce13b80c07a33c4d913f5cb0f9084
|
||||
---
|
||||
platform/ext/target/arm/corstone1000/config_tfm_target.h | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/config_tfm_target.h b/platform/ext/target/arm/corstone1000/config_tfm_target.h
|
||||
index bf8d2f95f..e96836663 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/config_tfm_target.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/config_tfm_target.h
|
||||
@@ -16,4 +16,12 @@
|
||||
#undef PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE
|
||||
#define PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE 256
|
||||
|
||||
+/* The maximum number of assets to be stored in the Internal Trusted Storage. */
|
||||
+#undef ITS_NUM_ASSETS
|
||||
+#define ITS_NUM_ASSETS 20
|
||||
+
|
||||
+/* The maximum number of assets to be stored in the Protected Storage area. */
|
||||
+#undef PS_NUM_ASSETS
|
||||
+#define PS_NUM_ASSETS 20
|
||||
+
|
||||
#endif /* __CONFIG_TFM_TARGET_H__ */
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
From 77c5a3bd090955e48ffca92bf9535185d26e9017 Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Mon, 15 May 2023 10:42:23 +0100
|
||||
Subject: [PATCH 2/4] Platform: corstone1000: Increase BL2 size in flash layout
|
||||
|
||||
Increases BL2 size to align with the flash page size in corstone1000.
|
||||
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Upstream-Status: Pending [Not submitted to upstream yet]
|
||||
---
|
||||
platform/ext/target/arm/corstone1000/partition/flash_layout.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/partition/flash_layout.h b/platform/ext/target/arm/corstone1000/partition/flash_layout.h
|
||||
index 41b4c6323f..bfe8c4fb3c 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/partition/flash_layout.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/partition/flash_layout.h
|
||||
@@ -89,7 +89,7 @@
|
||||
#endif
|
||||
|
||||
/* Static Configurations of the Flash */
|
||||
-#define SE_BL2_PARTITION_SIZE (0x18800) /* 98 KB */
|
||||
+#define SE_BL2_PARTITION_SIZE (0x19000) /* 98 KB */
|
||||
#define SE_BL2_BANK_0_OFFSET (0x9000) /* 72nd LBA */
|
||||
#define SE_BL2_BANK_1_OFFSET (0x1002000) /* 32784th LBA */
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
From 17244ac692495c23008ff784611d0ee1d42c83dc Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Mon, 15 May 2023 10:46:18 +0100
|
||||
Subject: [PATCH 3/4] Platform: Corstone1000: Increase BL2_DATA_SIZE
|
||||
|
||||
Increases BL2_DATA_SIZE to accommodate the changes in
|
||||
metadata_write/read.
|
||||
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Upstream-Status: Pending [Not submitted to upstream yet]
|
||||
---
|
||||
platform/ext/target/arm/corstone1000/partition/region_defs.h | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/partition/region_defs.h b/platform/ext/target/arm/corstone1000/partition/region_defs.h
|
||||
index abfac39b62..e7f0bad2ba 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/partition/region_defs.h
|
||||
+++ b/platform/ext/target/arm/corstone1000/partition/region_defs.h
|
||||
@@ -90,9 +90,10 @@
|
||||
#define BL2_CODE_SIZE (IMAGE_BL2_CODE_SIZE)
|
||||
#define BL2_CODE_LIMIT (BL2_CODE_START + BL2_CODE_SIZE - 1)
|
||||
|
||||
+#define BL2_DATA_ADDITIONAL 448 /* To increase the BL2_DATA_SIZE more than the default value */
|
||||
#define BL2_DATA_START (BOOT_TFM_SHARED_DATA_BASE + \
|
||||
BOOT_TFM_SHARED_DATA_SIZE)
|
||||
-#define BL2_DATA_SIZE (BL2_CODE_START - BL2_HEADER_SIZE - BL2_DATA_START)
|
||||
+#define BL2_DATA_SIZE (BL2_CODE_START - BL2_HEADER_SIZE - BL2_DATA_START + BL2_DATA_ADDITIONAL)
|
||||
#define BL2_DATA_LIMIT (BL2_DATA_START + BL2_DATA_SIZE - 1)
|
||||
|
||||
/* SE BL1 regions */
|
||||
--
|
||||
2.17.1
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
From 83e423497afecc202a3a50c3e472161390056ebd Mon Sep 17 00:00:00 2001
|
||||
From: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Date: Mon, 15 May 2023 10:47:27 +0100
|
||||
Subject: [PATCH 4/4] Platform: Corstone1000: Calculate the new CRC32 value
|
||||
after changing the metadata
|
||||
|
||||
Calculates the new CRC32 value for the metadata struct after chaing a value
|
||||
during the capsule update. It also updates the CRC32 field in the metadata
|
||||
so it doesn't fail the CRC check after a succesfull capsule update.
|
||||
It also skips doing a sanity check the BL2 nv counter after the capsule
|
||||
update since the tfm bl1 does not sync metadata and nv counters in OTP during
|
||||
the boot anymore.
|
||||
|
||||
Signed-off-by: Emekcan Aras <emekcan.aras@arm.com>
|
||||
Upstream-Status: Pending [Not submitted to upstream yet]
|
||||
---
|
||||
.../arm/corstone1000/fw_update_agent/fwu_agent.c | 10 +++++++---
|
||||
1 file changed, 7 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
index afd8d66e42..f564f2902c 100644
|
||||
--- a/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
+++ b/platform/ext/target/arm/corstone1000/fw_update_agent/fwu_agent.c
|
||||
@@ -802,6 +802,8 @@ static enum fwu_agent_error_t flash_full_capsule(
|
||||
}
|
||||
metadata->active_index = previous_active_index;
|
||||
metadata->previous_active_index = active_index;
|
||||
+ metadata->crc_32 = crc32((uint8_t *)&metadata->version,
|
||||
+ sizeof(struct fwu_metadata) - sizeof(uint32_t));
|
||||
|
||||
ret = metadata_write(metadata);
|
||||
if (ret) {
|
||||
@@ -913,6 +915,8 @@ static enum fwu_agent_error_t accept_full_capsule(
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
+ metadata->crc_32 = crc32((uint8_t *)&metadata->version,
|
||||
+ sizeof(struct fwu_metadata) - sizeof(uint32_t));
|
||||
|
||||
ret = metadata_write(metadata);
|
||||
if (ret) {
|
||||
@@ -1007,6 +1011,8 @@ static enum fwu_agent_error_t fwu_select_previous(
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
+ metadata->crc_32 = crc32((uint8_t *)&metadata->version,
|
||||
+ sizeof(struct fwu_metadata) - sizeof(uint32_t));
|
||||
|
||||
ret = metadata_write(metadata);
|
||||
if (ret) {
|
||||
@@ -1119,8 +1125,7 @@ static enum fwu_agent_error_t update_nv_counters(
|
||||
|
||||
FWU_LOG_MSG("%s: enter\n\r", __func__);
|
||||
|
||||
- for (int i = 0; i <= FWU_MAX_NV_COUNTER_INDEX; i++) {
|
||||
-
|
||||
+ for (int i = 1; i <= FWU_MAX_NV_COUNTER_INDEX; i++) {
|
||||
switch (i) {
|
||||
case FWU_BL2_NV_COUNTER:
|
||||
tfm_nv_counter_i = PLAT_NV_COUNTER_BL1_0;
|
||||
@@ -1141,7 +1146,6 @@ static enum fwu_agent_error_t update_nv_counters(
|
||||
if (err != TFM_PLAT_ERR_SUCCESS) {
|
||||
return FWU_AGENT_ERROR;
|
||||
}
|
||||
-
|
||||
if (priv_metadata->nv_counter[i] < security_cnt) {
|
||||
return FWU_AGENT_ERROR;
|
||||
} else if (priv_metadata->nv_counter[i] > security_cnt) {
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
From 1d548c77d07fc9a83e3e9aa28a23aa19a0177e3b Mon Sep 17 00:00:00 2001
|
||||
From: Jon Mason <jon.mason@arm.com>
|
||||
Date: Wed, 18 Jan 2023 15:13:37 -0500
|
||||
Subject: [PATCH] arm/trusted-firmware-m: disable fatal warnings
|
||||
|
||||
Signed-off-by: Jon Mason <jon.mason@arm.com>
|
||||
Upstream-Status: Inappropriate
|
||||
|
||||
---
|
||||
toolchain_GNUARM.cmake | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/toolchain_GNUARM.cmake b/toolchain_GNUARM.cmake
|
||||
index 7978eaca68..88395f922a 100644
|
||||
--- a/toolchain_GNUARM.cmake
|
||||
+++ b/toolchain_GNUARM.cmake
|
||||
@@ -71,7 +71,6 @@ macro(tfm_toolchain_reset_linker_flags)
|
||||
--entry=Reset_Handler
|
||||
-specs=nano.specs
|
||||
LINKER:-check-sections
|
||||
- LINKER:-fatal-warnings
|
||||
LINKER:--gc-sections
|
||||
LINKER:--no-wchar-size-warning
|
||||
${MEMORY_USAGE_FLAG}
|
||||
|
||||
Reference in New Issue
Block a user