Revert "version: Store image size data in version struct"
This is a dependency of the uderlyaing patch which breaks header
composition of g chip based boards.
This reverts commit 7cbb815732d7434f5985d3b50a869aa71ba5c507.
Change-Id: I4d94647cf5cb09fd338e5a581c956df6b5d83081
Reviewed-on: https://chromium-review.googlesource.com/435551
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
diff --git a/board/plankton/usb_pd_policy.c b/board/plankton/usb_pd_policy.c
index 6db20d3..d1f0a84 100644
--- a/board/plankton/usb_pd_policy.c
+++ b/board/plankton/usb_pd_policy.c
@@ -289,7 +289,7 @@
*rpayload = payload;
switch (cmd) {
case VDO_CMD_VERSION:
- memcpy(payload + 1, ¤t_image_data.version, 24);
+ memcpy(payload + 1, &version_data.version, 24);
rsize = 7;
break;
default:
diff --git a/chip/g/system.c b/chip/g/system.c
index 041ee8e..ad55316 100644
--- a/chip/g/system.c
+++ b/chip/g/system.c
@@ -259,7 +259,7 @@
const char *system_get_version(enum system_image_copy_t copy)
{
- const struct image_data *data;
+ const struct version_struct *v;
const struct SignedHeader *h;
enum system_image_copy_t this_copy;
uintptr_t vaddr, delta;
@@ -290,7 +290,7 @@
if (copy == this_copy) {
snprintf(vers_str, sizeof(vers_str), "%d.%d.%d/%s",
h->epoch_, h->major_, h->minor_,
- current_image_data.version);
+ version_data.version);
return vers_str;
}
@@ -299,7 +299,7 @@
* puts the version string right after the reset vectors, so
* it's at the same relative offset. Measure that offset here.
*/
- delta = (uintptr_t)¤t_image_data - vaddr;
+ delta = (uintptr_t)&version_data - vaddr;
/* Now look at that offset in the requested image */
vaddr = get_program_memory_addr(copy);
@@ -307,18 +307,17 @@
break;
h = (const struct SignedHeader *)vaddr;
vaddr += delta;
- data = (const struct image_data *)vaddr;
+ v = (const struct version_struct *)vaddr;
/*
* Make sure the version struct cookies match before returning
* the version string.
*/
- if (data->cookie1 == current_image_data.cookie1 &&
- data->cookie2 == current_image_data.cookie2 &&
+ if (v->cookie1 == version_data.cookie1 &&
+ v->cookie2 == version_data.cookie2 &&
h->magic) { /* Corrupted header's magic is set to zero. */
snprintf(vers_str, sizeof(vers_str), "%d.%d.%d/%s",
- h->epoch_, h->major_, h->minor_,
- data->version);
+ h->epoch_, h->major_, h->minor_, v->version);
return vers_str;
}
default:
diff --git a/chip/mec1322/lfw/ec_lfw.c b/chip/mec1322/lfw/ec_lfw.c
index b99d33d..6824d10 100644
--- a/chip/mec1322/lfw/ec_lfw.c
+++ b/chip/mec1322/lfw/ec_lfw.c
@@ -256,7 +256,7 @@
spi_enable(CONFIG_SPI_FLASH_PORT, 1);
uart_puts("littlefw ");
- uart_puts(current_image_data.version);
+ uart_puts(version_data.version);
uart_puts("\n");
switch (system_get_image_copy()) {
diff --git a/chip/mec1322/lfw/ec_lfw.ld b/chip/mec1322/lfw/ec_lfw.ld
index adb8b30..55b5fda 100644
--- a/chip/mec1322/lfw/ec_lfw.ld
+++ b/chip/mec1322/lfw/ec_lfw.ld
@@ -53,6 +53,4 @@
. = ORIGIN(SRAM) + LENGTH(SRAM) - 1;
BYTE(0xFF); /* emit at least a byte to make linker happy */
}
-
- __image_size = LOADADDR(.text) + SIZEOF(.text) - ORIGIN(VECTOR);
}
diff --git a/common/fmap.c b/common/fmap.c
index 9ddd670..6f84c37 100644
--- a/common/fmap.c
+++ b/common/fmap.c
@@ -109,9 +109,9 @@
.area_name = "RO_FRID",
.area_offset = CONFIG_EC_PROTECTED_STORAGE_OFF -
FMAP_REGION_START + CONFIG_RO_STORAGE_OFF +
- RELATIVE_RO((uint32_t)__image_data_offset) +
- offsetof(struct image_data, version),
- .area_size = sizeof(current_image_data.version),
+ RELATIVE_RO((uint32_t)__version_struct_offset) +
+ offsetof(struct version_struct, version),
+ .area_size = sizeof(version_data.version),
.area_flags = FMAP_AREA_STATIC | FMAP_AREA_RO,
},
@@ -151,15 +151,15 @@
* RW firmware version ID. Must be NULL terminated
* ASCII, and padded with \0.
* TODO: Get the relative offset of
- * __image_data_offset within our RW image to
+ * __version_struct_offset within our RW image to
* accommodate image asymmetry.
*/
.area_name = "RW_FWID",
.area_offset = CONFIG_EC_WRITABLE_STORAGE_OFF -
FMAP_REGION_START + CONFIG_RW_STORAGE_OFF +
- RELATIVE_RO((uint32_t)__image_data_offset) +
- offsetof(struct image_data, version),
- .area_size = sizeof(current_image_data.version),
+ RELATIVE_RO((uint32_t)__version_struct_offset) +
+ offsetof(struct version_struct, version),
+ .area_size = sizeof(version_data.version),
.area_flags = FMAP_AREA_STATIC,
},
}
diff --git a/common/system.c b/common/system.c
index 28d846c..ddabe3a 100644
--- a/common/system.c
+++ b/common/system.c
@@ -616,14 +616,14 @@
__attribute__((weak)) /* Weird chips may need their own implementations */
const char *system_get_version(enum system_image_copy_t copy)
{
- static struct image_data data;
+ static struct version_struct v;
uintptr_t addr;
enum system_image_copy_t active_copy = system_get_image_copy();
/* Handle version of current image */
if (copy == active_copy || copy == SYSTEM_IMAGE_UNKNOWN)
- return ¤t_image_data.version[0];
+ return &version_data.version[0];
if (active_copy == SYSTEM_IMAGE_UNKNOWN)
return "";
@@ -632,7 +632,7 @@
* The version string is always located after the reset vectors, so
* it's the same offset as in the current image. Find that offset.
*/
- addr = ((uintptr_t)¤t_image_data -
+ addr = ((uintptr_t)&version_data -
get_program_memory_addr(active_copy));
/*
@@ -646,19 +646,19 @@
#ifdef CONFIG_MAPPED_STORAGE
addr += CONFIG_MAPPED_STORAGE_BASE;
flash_lock_mapped_storage(1);
- memcpy(&data, (const void *)addr, sizeof(data));
+ memcpy(&v, (const void *)addr, sizeof(v));
flash_lock_mapped_storage(0);
#else
/* Read the version struct from flash into a buffer. */
- if (flash_read(addr, sizeof(data), (char *)&data))
+ if (flash_read(addr, sizeof(v), (char *)&v))
return "";
#endif
/* Make sure the version struct cookies match before returning the
* version string. */
- if (data.cookie1 == current_image_data.cookie1 &&
- data.cookie2 == current_image_data.cookie2)
- return data.version;
+ if (v.cookie1 == version_data.cookie1 &&
+ v.cookie2 == version_data.cookie2)
+ return v.version;
return "";
}
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index 5e5ce71..97e7718 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -959,7 +959,7 @@
switch (PD_VDO_CMD(payload[0])) {
case VDO_CMD_VERSION:
- memcpy(payload + 1, ¤t_image_data.version, 24);
+ memcpy(payload + 1, &version_data.version, 24);
rsize = 7;
break;
case VDO_CMD_REBOOT:
diff --git a/common/version.c b/common/version.c
index ff8207b..3757c9d 100644
--- a/common/version.c
+++ b/common/version.c
@@ -10,14 +10,11 @@
#include "ec_version.h"
#include "version.h"
-const struct image_data __keep current_image_data
+const struct version_struct __keep version_data
__attribute__((section(".rodata.ver"))) = {
- .cookie1 = CROS_EC_IMAGE_DATA_COOKIE1,
- .version = CROS_EC_VERSION32,
-#ifndef TEST_BUILD
- .size = (const uintptr_t)&__image_size,
-#endif
- .cookie2 = CROS_EC_IMAGE_DATA_COOKIE2,
+ CROS_EC_VERSION_COOKIE1,
+ CROS_EC_VERSION32,
+ CROS_EC_VERSION_COOKIE2
};
const char build_info[] __keep __attribute__((section(".rodata.buildinfo"))) =
@@ -35,7 +32,7 @@
* we want to return the numcommits as an int.
*/
for (i = 0; i < 32; i++) {
- if (current_image_data.version[i] == '.') {
+ if (version_data.version[i] == '.') {
numperiods++;
if (numperiods == 2)
break;
@@ -44,11 +41,12 @@
i++;
for (; i < 32; i++) {
- if (current_image_data.version[i] == '-')
+ if (version_data.version[i] == '-')
break;
ret *= 10;
- ret += current_image_data.version[i] - '0';
+ ret += version_data.version[i] - '0';
}
return (i == 32 ? 0 : ret);
}
+
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S
index 803845c..90212a5 100644
--- a/core/cortex-m/ec.lds.S
+++ b/core/cortex-m/ec.lds.S
@@ -79,7 +79,7 @@
#endif
STRINGIFY(OUTDIR/core/CORE/init.o) (.text.vecttable)
. = ALIGN(4);
- __image_data_offset = .;
+ __version_struct_offset = .;
KEEP(*(.rodata.ver))
. = ALIGN(4);
@@ -357,12 +357,6 @@
) >= (LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION)),
"No room left in the flash")
-#if defined(SECTION_IS_RO) && defined(NPCX_RO_HEADER)
- __image_size = __hey_flash_used - FW_SIZE(RO_HDR);
-#else
- __image_size = __hey_flash_used;
-#endif
-
#ifdef CONFIG_USB_RAM_SIZE
.usb_ram (NOLOAD) : {
__usb_ram_start = .;
diff --git a/core/cortex-m0/ec.lds.S b/core/cortex-m0/ec.lds.S
index ee65cb3..6102bfa 100644
--- a/core/cortex-m0/ec.lds.S
+++ b/core/cortex-m0/ec.lds.S
@@ -41,7 +41,7 @@
.text : {
STRINGIFY(OUTDIR/core/CORE/init.o) (.text.vecttable)
. = ALIGN(4);
- __image_data_offset = .;
+ __version_struct_offset = .;
KEEP(*(.rodata.ver))
. = ALIGN(4);
@@ -245,8 +245,6 @@
) >= (LOADADDR(.data) + SIZEOF(.data) - FW_OFF(SECTION)),
"No room left in the flash")
- __image_size = __hey_flash_used;
-
#ifdef CONFIG_USB_RAM_SIZE
.usb_ram (NOLOAD) : {
__usb_ram_start = .;
diff --git a/core/nds32/ec.lds.S b/core/nds32/ec.lds.S
index 978f652..1f12524 100644
--- a/core/nds32/ec.lds.S
+++ b/core/nds32/ec.lds.S
@@ -36,7 +36,7 @@
"__flash_dma_start has to be 4k-byte aligned");
KEEP(STRINGIFY(OUTDIR/core/CORE/init.o) (.text.vecttable))
. = ALIGN(4);
- __image_data_offset = .;
+ __version_struct_offset = .;
KEEP(*(.rodata.ver))
. = ALIGN(4);
KEEP(STRINGIFY(OUTDIR/core/CORE/init.o) (.text.vectirq))
diff --git a/include/version.h b/include/version.h
index 94e8dd9..8853d76 100644
--- a/include/version.h
+++ b/include/version.h
@@ -10,20 +10,18 @@
#include "common.h"
-#define CROS_EC_IMAGE_DATA_COOKIE1 0xce778899
-#define CROS_EC_IMAGE_DATA_COOKIE2 0xceaabbcc
+#define CROS_EC_VERSION_COOKIE1 0xce112233
+#define CROS_EC_VERSION_COOKIE2 0xce445566
-struct image_data {
+struct version_struct {
uint32_t cookie1;
char version[32];
- uint32_t size;
uint32_t cookie2;
} __packed;
-extern const struct image_data current_image_data;
+extern const struct version_struct version_data;
extern const char build_info[];
-extern const char __image_data_offset[];
-extern const void *__image_size;
+extern const char __version_struct_offset[];
/**
* Get the number of commits field from version string.