summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/fmap.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/common/fmap.c b/common/fmap.c
index e01591b6fc..3adb1c1c6f 100644
--- a/common/fmap.c
+++ b/common/fmap.c
@@ -18,6 +18,12 @@
#define FMAP_VER_MAJOR 1
#define FMAP_VER_MINOR 0
+/*
+ * For address containing CONFIG_FLASH_BASE (symbols in *.lds.S and variable),
+ * this computes the offset to the start of flash.
+ */
+#define RELATIVE(addr) ((addr) - CONFIG_FLASH_BASE)
+
typedef struct _FmapHeader {
char fmap_signature[FMAP_SIGNATURE_SIZE];
uint8_t fmap_ver_major;
@@ -83,7 +89,7 @@ const struct _ec_fmap {
* ASCIIZ, and padded with \0. */
.area_name = "RO_FRID",
.area_offset = CONFIG_FW_RO_OFF +
- (uint32_t)__version_struct_offset +
+ RELATIVE((uint32_t)__version_struct_offset) +
offsetof(struct version_struct, version),
.area_size = sizeof(version_data.version),
.area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO,
@@ -92,7 +98,8 @@ const struct _ec_fmap {
/* Other RO stuff: FMAP, WP, KEYS, etc. */
{
.area_name = "FMAP",
- .area_offset = (uint32_t)&ec_fmap,
+ .area_offset = CONFIG_FW_RO_OFF +
+ RELATIVE((uint32_t)&ec_fmap),
.area_size = sizeof(ec_fmap),
.area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO,
},
@@ -127,7 +134,7 @@ const struct _ec_fmap {
* ASCIIZ, and padded with \0. */
.area_name = "RW_FWID",
.area_offset = CONFIG_FW_RW_OFF +
- (uint32_t)__version_struct_offset +
+ RELATIVE((uint32_t)__version_struct_offset) +
offsetof(struct version_struct, version),
.area_size = sizeof(version_data.version),
.area_flags = FMAP_AREA_STATIC,