summaryrefslogtreecommitdiff
path: root/common/fmap.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2012-05-18 18:55:52 -0700
committerBill Richardson <wfrichar@chromium.org>2012-05-21 14:20:02 -0700
commitadd419009fe4f9f6a9f11780a582657c7805d6f0 (patch)
treee0d22b86c569cad9d42a39e981a440b72f7c712d /common/fmap.c
parent1ac197d566d74b5dfd2abbd57c191e464aa46d8b (diff)
downloadchrome-ec-add419009fe4f9f6a9f11780a582657c7805d6f0.tar.gz
Clean up linker scripts; detect out-of-flash problem.
The VMA of the .data segment is in RAM, but we actually put it into FLASH. The linker doesn't notice if it runs out of flash, so it creates an invalid image. This adds an explicit check to be sure it all fits. It also refactors the region declarations to be more explicit. For vboot-enabled configurations, CONFIG_SECTION_* - describes the extent of flash for one entire image CONFIG_FW_* - the region within the SECTION for the firmware only CONFIG_VBLOCK_* - the region within the RW SECTIONs for the vblocks CONFIG_VBOOT_ROOTKEY - the region within the RO SECTION for the root key Look at chip/lm4/config.h for the best example. BUG=chrome-os-partner:9839 TEST=manual Build it, run it. Change-Id: I3c652e82d58a5328115cc750c80ecba6a3fd99a3 Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'common/fmap.c')
-rw-r--r--common/fmap.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/common/fmap.c b/common/fmap.c
index 40524c21ef..00b127a1b7 100644
--- a/common/fmap.c
+++ b/common/fmap.c
@@ -13,7 +13,6 @@
#define FMAP_SIGNATURE_SIZE 8
#define FMAP_VER_MAJOR 1
#define FMAP_VER_MINOR 0
-#define FMAP_SEARCH_STRIDE 64 /* Spec revision 1.01 */
typedef struct _FmapHeader {
char fmap_signature[FMAP_SIGNATURE_SIZE];
@@ -48,8 +47,7 @@ const struct _ec_fmap {
.fmap_ver_major = FMAP_VER_MAJOR,
.fmap_ver_minor = FMAP_VER_MINOR,
.fmap_base = CONFIG_FLASH_BASE,
- /* NOTE: EC implementation reserves one bank for itself */
- .fmap_size = CONFIG_FLASH_SIZE - CONFIG_FLASH_BANK_SIZE,
+ .fmap_size = CONFIG_FLASH_SIZE,
.fmap_name = "EC_FMAP",
.fmap_nareas = NUM_EC_FMAP_AREAS,
},
@@ -58,8 +56,8 @@ const struct _ec_fmap {
/* RO Firmware */
{
.area_name = "RO_SECTION",
- .area_offset = CONFIG_FW_RO_OFF,
- .area_size = CONFIG_FW_IMAGE_SIZE,
+ .area_offset = CONFIG_SECTION_RO_OFF,
+ .area_size = CONFIG_SECTION_RO_SIZE,
.area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO,
},
{
@@ -91,7 +89,7 @@ const struct _ec_fmap {
{
/* A dummy region to identify it as EC firmware */
.area_name = "EC_IMAGE",
- .area_offset = CONFIG_FW_RO_OFF,
+ .area_offset = CONFIG_SECTION_RO_OFF,
.area_size = 0, /* Always zero */
.area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO,
},
@@ -99,31 +97,32 @@ const struct _ec_fmap {
/* The range for write protect, for lagecy firmware
* updater. Should be identical to 'WP_RO'. */
.area_name = "EC_RO",
- .area_offset = CONFIG_FW_RO_OFF,
- .area_size = CONFIG_FW_IMAGE_SIZE,
+ .area_offset = CONFIG_SECTION_RO_OFF,
+ .area_size = CONFIG_SECTION_RO_SIZE,
.area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO,
},
{
/* The range for autoupdate to update A/B at once. */
.area_name = "EC_RW",
- .area_offset = CONFIG_FW_A_OFF,
- .area_size = CONFIG_FW_IMAGE_SIZE * 2,
+ .area_offset = CONFIG_SECTION_A_OFF,
+ .area_size = CONFIG_SECTION_A_SIZE
+ + CONFIG_SECTION_B_SIZE,
.area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO,
},
{
/* The range for write protect, for factory finalize
* test case. Should be identical to 'EC_RO'. */
.area_name = "WP_RO",
- .area_offset = CONFIG_FW_RO_OFF,
- .area_size = CONFIG_FW_IMAGE_SIZE,
+ .area_offset = CONFIG_SECTION_RO_OFF,
+ .area_size = CONFIG_SECTION_RO_SIZE,
.area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO,
},
/* Firmware A */
{
.area_name = "RW_SECTION_A",
- .area_offset = CONFIG_FW_A_OFF,
- .area_size = CONFIG_FW_IMAGE_SIZE,
+ .area_offset = CONFIG_SECTION_A_OFF,
+ .area_size = CONFIG_SECTION_A_SIZE,
.area_flags = FMAP_AREA_STATIC,
},
{
@@ -141,15 +140,15 @@ const struct _ec_fmap {
{
.area_name = "VBLOCK_A",
.area_offset = CONFIG_VBLOCK_A_OFF,
- .area_size = CONFIG_VBLOCK_A_SIZE,
+ .area_size = CONFIG_VBLOCK_SIZE,
.area_flags = FMAP_AREA_STATIC,
},
/* Firmware B */
{
.area_name = "RW_SECTION_B",
- .area_offset = CONFIG_FW_B_OFF,
- .area_size = CONFIG_FW_IMAGE_SIZE,
+ .area_offset = CONFIG_SECTION_B_OFF,
+ .area_size = CONFIG_SECTION_B_SIZE,
.area_flags = FMAP_AREA_STATIC,
},
{
@@ -167,7 +166,7 @@ const struct _ec_fmap {
{
.area_name = "VBLOCK_B",
.area_offset = CONFIG_VBLOCK_B_OFF,
- .area_size = CONFIG_VBLOCK_B_SIZE,
+ .area_size = CONFIG_VBLOCK_SIZE,
.area_flags = FMAP_AREA_STATIC,
},
}