diff options
author | Matt Mower <mowerm@gmail.com> | 2014-07-08 22:25:38 -0500 |
---|---|---|
committer | Tom Marshall <tdm@cyngn.com> | 2015-11-25 15:35:47 -0800 |
commit | 21d3a8f8230ae4f1f9210d6ec40f92ae023ec43a (patch) | |
tree | 3a927f574cdadc1793342fbb1bbdef7c3af63e10 | |
parent | bea646deee644f24384caf321fb497dd530ba2f0 (diff) | |
download | bootable_recovery-21d3a8f8230ae4f1f9210d6ec40f92ae023ec43a.zip bootable_recovery-21d3a8f8230ae4f1f9210d6ec40f92ae023ec43a.tar.gz bootable_recovery-21d3a8f8230ae4f1f9210d6ec40f92ae023ec43a.tar.bz2 |
Allow custom bootloader msg offset in block misc
Use board define BOARD_RECOVERY_BLDRMSG_OFFSET with a decimal integer
to define a custom offset where the bootloader message should be
read/written.
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: Id13a23dd41bb7d907b96d657b8e21eb839dfeaa9
-rw-r--r-- | Android.mk | 4 | ||||
-rw-r--r-- | bootloader.cpp | 6 | ||||
-rw-r--r-- | updater/Android.mk | 4 | ||||
-rw-r--r-- | updater/install.c | 9 |
4 files changed, 23 insertions, 0 deletions
@@ -123,6 +123,10 @@ ifeq ($(TARGET_USE_MDTP), true) LOCAL_CFLAGS += -DUSE_MDTP endif +ifneq ($(BOARD_RECOVERY_BLDRMSG_OFFSET),) + LOCAL_CFLAGS += -DBOARD_RECOVERY_BLDRMSG_OFFSET=$(BOARD_RECOVERY_BLDRMSG_OFFSET) +endif + LOCAL_CFLAGS += -DUSE_EXT4 -DMINIVOLD LOCAL_C_INCLUDES += system/extras/ext4_utils system/core/fs_mgr/include external/fsck_msdos LOCAL_C_INCLUDES += system/vold diff --git a/bootloader.cpp b/bootloader.cpp index dec296f..9e91b27 100644 --- a/bootloader.cpp +++ b/bootloader.cpp @@ -168,6 +168,9 @@ static int get_bootloader_message_block(struct bootloader_message *out, LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } +#ifdef BOARD_RECOVERY_BLDRMSG_OFFSET + fseek(f, BOARD_RECOVERY_BLDRMSG_OFFSET, SEEK_SET); +#endif struct bootloader_message temp; int count = fread(&temp, sizeof(temp), 1, f); if (count != 1) { @@ -190,6 +193,9 @@ static int set_bootloader_message_block(const struct bootloader_message *in, LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; } +#ifdef BOARD_RECOVERY_BLDRMSG_OFFSET + fseek(f, BOARD_RECOVERY_BLDRMSG_OFFSET, SEEK_SET); +#endif int count = fwrite(in, sizeof(*in), 1, f); if (count != 1) { LOGE("Failed writing %s\n(%s)\n", v->blk_device, strerror(errno)); diff --git a/updater/Android.mk b/updater/Android.mk index c936d0d..9f9da06 100644 --- a/updater/Android.mk +++ b/updater/Android.mk @@ -28,6 +28,10 @@ LOCAL_STATIC_LIBRARIES += \ libsparse_static \ libz +ifneq ($(BOARD_RECOVERY_BLDRMSG_OFFSET),) + LOCAL_CFLAGS += -DBOARD_RECOVERY_BLDRMSG_OFFSET=$(BOARD_RECOVERY_BLDRMSG_OFFSET) +endif + LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UPDATER_LIBS) $(TARGET_RECOVERY_UPDATER_EXTRA_LIBS) LOCAL_STATIC_LIBRARIES += libapplypatch libedify libmtdutils libminzip libz LOCAL_STATIC_LIBRARIES += libmincrypt libbz diff --git a/updater/install.c b/updater/install.c index bae8959..68cd7e0 100644 --- a/updater/install.c +++ b/updater/install.c @@ -1503,6 +1503,9 @@ 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); +#ifdef BOARD_RECOVERY_BLDRMSG_OFFSET + fseek(f, BOARD_RECOVERY_BLDRMSG_OFFSET, SEEK_CUR); +#endif fwrite(buffer, sizeof(((struct bootloader_message*)0)->command), 1, f); fclose(f); free(filename); @@ -1545,6 +1548,9 @@ 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); +#ifdef BOARD_RECOVERY_BLDRMSG_OFFSET + fseek(f, BOARD_RECOVERY_BLDRMSG_OFFSET, SEEK_CUR); +#endif int to_write = strlen(stagestr)+1; int max_size = sizeof(((struct bootloader_message*)0)->stage); if (to_write > max_size) { @@ -1571,6 +1577,9 @@ 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); +#ifdef BOARD_RECOVERY_BLDRMSG_OFFSET + fseek(f, BOARD_RECOVERY_BLDRMSG_OFFSET, SEEK_CUR); +#endif fread(buffer, sizeof(buffer), 1, f); fclose(f); buffer[sizeof(buffer)-1] = '\0'; |