diff --git a/common/fmap.c b/common/fmap.c index 2a2d288d5f..da139f7cc1 100644 --- a/common/fmap.c +++ b/common/fmap.c @@ -4,8 +4,10 @@ * found in the LICENSE file. */ +#include #include #include "config.h" +#include "version.h" /* FMAP structs. See http://code.google.com/p/flashmap/wiki/FmapSpec */ #define FMAP_NAMELEN 32 @@ -68,8 +70,10 @@ const struct _ec_fmap { }, { .area_name = "RO_FRID", /* FIXME: Where is it? */ - .area_offset = CONFIG_FW_RO_OFF, - .area_size = 0, + .area_offset = CONFIG_FW_RO_OFF + + (uint32_t)__version_struct_offset + + offsetof(struct version_struct, version), + .area_size = sizeof(version_data.version), .area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO, }, @@ -133,8 +137,10 @@ const struct _ec_fmap { }, { .area_name = "RW_FWID_A", /* FIXME: Where is it? */ - .area_offset = CONFIG_FW_A_OFF, - .area_size = 0, + .area_offset = CONFIG_FW_A_OFF + + (uint32_t)__version_struct_offset + + offsetof(struct version_struct, version), + .area_size = sizeof(version_data.version), .area_flags = FMAP_AREA_STATIC, }, { @@ -160,8 +166,10 @@ const struct _ec_fmap { }, { .area_name = "RW_FWID_B", /* FIXME: Where is it? */ - .area_offset = CONFIG_FW_B_OFF, - .area_size = 0, + .area_offset = CONFIG_FW_B_OFF + + (uint32_t)__version_struct_offset + + offsetof(struct version_struct, version), + .area_size = sizeof(version_data.version), .area_flags = FMAP_AREA_STATIC, }, { diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index 2b22a76809..2ef091e905 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -24,6 +24,7 @@ SECTIONS .text : { OUTDIR/core/CORE/init.o (.text.vecttable) . = ALIGN(4); + __version_struct_offset = .; *(.rodata.ver) . = ALIGN(4); OUTDIR/core/CORE/init.o (.text) diff --git a/include/version.h b/include/version.h index 0ded5513e1..d168c23490 100644 --- a/include/version.h +++ b/include/version.h @@ -25,5 +25,6 @@ struct version_struct { extern const struct version_struct version_data; extern const char build_info[]; +extern const char __version_struct_offset[]; #endif /* __CROS_EC_VERSION_H */