From d0d50b6da7b826c0aa13391d6794b66e1c0f1303 Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Wed, 11 Jul 2012 17:12:34 +0800 Subject: Change some FMAP area_offset to be related to the start of flash. The area_offset of following area are wrong which is related to the CPU view in the STM32 chip: FMAP RO_FRID RW_FWID Add a macro RELATIVE() to calculate the real offset in flash. BUG=chrome-os-partner:11269 TEST=build in chroot for link and snow. Those fmap afddress are related to the start of flash. Change-Id: I691814e2f53b1de0ecf9fd385bed8d5c598373a7 Signed-off-by: Louis Yung-Chieh Lo Reviewed-on: https://gerrit.chromium.org/gerrit/28388 Commit-Ready: Yung-Chieh Lo Reviewed-by: Yung-Chieh Lo Tested-by: Yung-Chieh Lo --- common/fmap.c | 13 ++++++++++--- 1 file 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, -- cgit v1.2.1