From 8df3191beed34f7cbfc0bfd4041c692f8b98d9a2 Mon Sep 17 00:00:00 2001 From: Matt Mower Date: Wed, 9 Jul 2014 11:50:05 -0500 Subject: Allow custom bootloader msg offset in block misc Globally define BOARD_RECOVERY_BLDRMSG_OFFSET with a decimal integer to offset the read/write location in misc where the bootloader message should appear. Example: BOARD_GLOBAL_CFLAGS := -DBOARD_RECOVERY_BLDRMSG_OFFSET=2048 Edify commands get_stage and set_stage need to be aware of the custom bootloader msg offset because they write the stage directly to the BCB. Change-Id: Ifdb5ffe3e893a651be59ae63e3a0ebadd828c9f2 --- updater/install.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'updater') diff --git a/updater/install.cpp b/updater/install.cpp index b17c34fb2..d4ae64ee5 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -1456,6 +1456,7 @@ Value* RebootNowFn(const char* name, State* state, int argc, Expr* argv[]) { memset(buffer, 0, sizeof(((struct bootloader_message*)0)->command)); FILE* f = fopen(filename, "r+b"); fseek(f, offsetof(struct bootloader_message, command), SEEK_SET); + fseek(f, BOOTLOADER_MESSAGE_OFFSET_IN_MISC, SEEK_CUR); ota_fwrite(buffer, sizeof(((struct bootloader_message*)0)->command), 1, f); fclose(f); free(filename); @@ -1498,6 +1499,7 @@ Value* SetStageFn(const char* name, State* state, int argc, Expr* argv[]) { // package installation. FILE* f = fopen(filename, "r+b"); fseek(f, offsetof(struct bootloader_message, stage), SEEK_SET); + fseek(f, BOOTLOADER_MESSAGE_OFFSET_IN_MISC, SEEK_CUR); int to_write = strlen(stagestr)+1; int max_size = sizeof(((struct bootloader_message*)0)->stage); if (to_write > max_size) { @@ -1524,6 +1526,7 @@ Value* GetStageFn(const char* name, State* state, int argc, Expr* argv[]) { char buffer[sizeof(((struct bootloader_message*)0)->stage)]; FILE* f = fopen(filename, "rb"); fseek(f, offsetof(struct bootloader_message, stage), SEEK_SET); + fseek(f, BOOTLOADER_MESSAGE_OFFSET_IN_MISC, SEEK_CUR); ota_fread(buffer, sizeof(buffer), 1, f); fclose(f); buffer[sizeof(buffer)-1] = '\0'; -- cgit v1.2.3