blob: d834e95bd79ce786921c6ca8a03d4a230329aa62 [file] [log] [blame]
Andrew Geissler80d41842023-09-11 08:36:15 -04001From 360aa32846a97e775750e06865d462c6258179fa Mon Sep 17 00:00:00 2001
Andrew Geissler2daf84b2023-03-31 09:57:23 -05002From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
3Date: Mon, 9 Jan 2023 13:59:06 +0000
4Subject: [PATCH] feat(corstone1000): bl2 loads fip based on metadata
5
6Previously bl2 was reading the boot_index directly with a hard coded
7address and then set the fip image spec with fip offsets base based on
8the boot_index value.
9This commit removes this logic and rely on PSA_FWU_SUPPORT
10which reads the fip partition based on the active firmware bank written in
11metadata.
12
13Note: fip partition contains signature area at the begining. Hence, the fip
14image starts at fip partition + fip signature area size.
15
16Upstream-Status: Pending
17Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
Andrew Geissler80d41842023-09-11 08:36:15 -040018
Andrew Geissler2daf84b2023-03-31 09:57:23 -050019---
20 bl2/bl2_main.c | 4 +++
21 .../corstone1000/common/corstone1000_plat.c | 32 ++++++-------------
22 .../common/include/platform_def.h | 12 +++----
23 tools/cert_create/Makefile | 4 +--
24 tools/fiptool/Makefile | 4 +--
25 5 files changed, 24 insertions(+), 32 deletions(-)
26
27diff --git a/bl2/bl2_main.c b/bl2/bl2_main.c
Andrew Geissler80d41842023-09-11 08:36:15 -040028index 5da803795..f25dc3029 100644
Andrew Geissler2daf84b2023-03-31 09:57:23 -050029--- a/bl2/bl2_main.c
30+++ b/bl2/bl2_main.c
Andrew Geissler80d41842023-09-11 08:36:15 -040031@@ -86,6 +86,10 @@ void bl2_main(void)
Andrew Geissler2daf84b2023-03-31 09:57:23 -050032 /* Perform remaining generic architectural setup in S-EL1 */
33 bl2_arch_setup();
34
35+#if ARM_GPT_SUPPORT
36+ partition_init(GPT_IMAGE_ID);
37+#endif
38+
39 #if PSA_FWU_SUPPORT
40 fwu_init();
41 #endif /* PSA_FWU_SUPPORT */
42diff --git a/plat/arm/board/corstone1000/common/corstone1000_plat.c b/plat/arm/board/corstone1000/common/corstone1000_plat.c
Andrew Geissler80d41842023-09-11 08:36:15 -040043index 0235f8b84..7f9708a82 100644
Andrew Geissler2daf84b2023-03-31 09:57:23 -050044--- a/plat/arm/board/corstone1000/common/corstone1000_plat.c
45+++ b/plat/arm/board/corstone1000/common/corstone1000_plat.c
46@@ -33,36 +33,17 @@ const mmap_region_t plat_arm_mmap[] = {
47 static void set_fip_image_source(void)
48 {
49 const struct plat_io_policy *policy;
50- /*
51- * metadata for firmware update is written at 0x0000 offset of the flash.
52- * PLAT_ARM_BOOT_BANK_FLAG contains the boot bank that TF-M is booted.
53- * As per firmware update spec, at a given point of time, only one bank
54- * is active. This means, TF-A should boot from the same bank as TF-M.
55- */
56- volatile uint32_t *boot_bank_flag = (uint32_t *)(PLAT_ARM_BOOT_BANK_FLAG);
57-
58- if (*boot_bank_flag > 1) {
59- VERBOSE("Boot_bank is set higher than possible values");
60- }
61-
62- VERBOSE("Boot bank flag = %u.\n\r", *boot_bank_flag);
63
64 policy = FCONF_GET_PROPERTY(arm, io_policies, FIP_IMAGE_ID);
65
66 assert(policy != NULL);
67 assert(policy->image_spec != 0UL);
68
69+ /* FIP Partition contains Signature area at the begining which TF-A doesn't expect */
70 io_block_spec_t *spec = (io_block_spec_t *)policy->image_spec;
71+ spec->offset += FIP_SIGNATURE_AREA_SIZE;
72+ spec->length -= FIP_SIGNATURE_AREA_SIZE;
73
74- if ((*boot_bank_flag) == 0) {
75- VERBOSE("Booting from bank 0: fip offset = 0x%lx\n\r",
76- PLAT_ARM_FIP_BASE_BANK0);
77- spec->offset = PLAT_ARM_FIP_BASE_BANK0;
78- } else {
79- VERBOSE("Booting from bank 1: fip offset = 0x%lx\n\r",
80- PLAT_ARM_FIP_BASE_BANK1);
81- spec->offset = PLAT_ARM_FIP_BASE_BANK1;
82- }
83 }
84
85 void bl2_platform_setup(void)
86@@ -75,6 +56,13 @@ void bl2_platform_setup(void)
87 set_fip_image_source();
88 }
89
90+void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1,
91+ u_register_t arg2, u_register_t arg3)
92+{
93+ arm_bl2_early_platform_setup((uintptr_t)arg0, (meminfo_t *)arg1);
94+ NOTICE("CS1k: early at bl2_platform_setup\n");
95+}
96+
97 /* corstone1000 only has one always-on power domain and there
98 * is no power control present
99 */
100diff --git a/plat/arm/board/corstone1000/common/include/platform_def.h b/plat/arm/board/corstone1000/common/include/platform_def.h
Andrew Geissler80d41842023-09-11 08:36:15 -0400101index 584d485f3..0bfab05a4 100644
Andrew Geissler2daf84b2023-03-31 09:57:23 -0500102--- a/plat/arm/board/corstone1000/common/include/platform_def.h
103+++ b/plat/arm/board/corstone1000/common/include/platform_def.h
104@@ -173,16 +173,16 @@
105
106 /* NOR Flash */
107
108-#define PLAT_ARM_BOOT_BANK_FLAG UL(0x08002000)
109-#define PLAT_ARM_FIP_BASE_BANK0 UL(0x081EF000)
110-#define PLAT_ARM_FIP_BASE_BANK1 UL(0x0916F000)
111-#define PLAT_ARM_FIP_MAX_SIZE UL(0x1ff000) /* 1.996 MB */
112-
113 #define PLAT_ARM_NVM_BASE V2M_FLASH0_BASE
114 #define PLAT_ARM_NVM_SIZE (SZ_32M) /* 32 MB */
115+#define PLAT_ARM_FIP_MAX_SIZE UL(0x1ff000) /* 1.996 MB */
116
117-#define PLAT_ARM_FLASH_IMAGE_BASE PLAT_ARM_FIP_BASE_BANK0
118+#define PLAT_ARM_FLASH_IMAGE_BASE UL(0x08000000)
119 #define PLAT_ARM_FLASH_IMAGE_MAX_SIZE PLAT_ARM_FIP_MAX_SIZE
120+#define PLAT_ARM_FIP_OFFSET_IN_GPT (0x86000)
121+
122+/* FIP Information */
123+#define FIP_SIGNATURE_AREA_SIZE (0x1000) /* 4 KB */
124
125 /*
126 * Some data must be aligned on the biggest cache line size in the platform.
127diff --git a/tools/cert_create/Makefile b/tools/cert_create/Makefile
Andrew Geissler80d41842023-09-11 08:36:15 -0400128index ca548b836..32b5486a0 100644
Andrew Geissler2daf84b2023-03-31 09:57:23 -0500129--- a/tools/cert_create/Makefile
130+++ b/tools/cert_create/Makefile
Andrew Geissler80d41842023-09-11 08:36:15 -0400131@@ -69,8 +69,8 @@ INC_DIR += -I ./include -I ${PLAT_INCLUDE} -I ${OPENSSL_DIR}/include
Andrew Geissler2daf84b2023-03-31 09:57:23 -0500132 # directory. However, for a local build of OpenSSL, the built binaries are
133 # located under the main project directory (i.e.: ${OPENSSL_DIR}, not
134 # ${OPENSSL_DIR}/lib/).
135-LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR}
136-LIB := -lssl -lcrypto
137+LIB_DIR := -L ${OPENSSL_DIR}/lib -L ${OPENSSL_DIR} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS}
138+LIB := -lssl -lcrypto ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS}
139
140 HOSTCC ?= gcc
141
142diff --git a/tools/fiptool/Makefile b/tools/fiptool/Makefile
Andrew Geissler80d41842023-09-11 08:36:15 -0400143index e6aeba95b..7c047479e 100644
Andrew Geissler2daf84b2023-03-31 09:57:23 -0500144--- a/tools/fiptool/Makefile
145+++ b/tools/fiptool/Makefile
Andrew Geissler80d41842023-09-11 08:36:15 -0400146@@ -29,7 +29,7 @@ endif
Andrew Geissler2daf84b2023-03-31 09:57:23 -0500147 # directory. However, for a local build of OpenSSL, the built binaries are
148 # located under the main project directory (i.e.: ${OPENSSL_DIR}, not
149 # ${OPENSSL_DIR}/lib/).
150-LDLIBS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto
151+LDLIBS := -L${OPENSSL_DIR}/lib -L${OPENSSL_DIR} -lcrypto ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS} ${BUILD_LDFLAGS}
152
153 ifeq (${V},0)
154 Q := @
Andrew Geissler80d41842023-09-11 08:36:15 -0400155@@ -37,7 +37,7 @@ else
Andrew Geissler2daf84b2023-03-31 09:57:23 -0500156 Q :=
157 endif
158
159-INCLUDE_PATHS := -I../../include/tools_share -I${OPENSSL_DIR}/include
160+INCLUDE_PATHS := -I../../include/tools_share -I${OPENSSL_DIR}/include ${BUILD_CFLAGS} ${BUILD_CFLAGS} ${BUILD_CFLAGS} ${BUILD_CFLAGS} ${BUILD_CFLAGS} ${BUILD_CFLAGS}
161
162 HOSTCC ?= gcc
163
Andrew Geissler80d41842023-09-11 08:36:15 -0400164--
1652.25.1
166