Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b6f0aa0 authored by Matt Mower's avatar Matt Mower Committed by Dan Pasanen
Browse files

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
parent 5982e794
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@ LOCAL_STATIC_LIBRARIES += \
LOCAL_C_INCLUDES += external/e2fsprogs/lib
LOCAL_STATIC_LIBRARIES += libext2_blkid libext2_uuid

ifneq ($(BOARD_RECOVERY_BLDRMSG_OFFSET),)
    LOCAL_CFLAGS += -DBOARD_RECOVERY_BLDRMSG_OFFSET=$(BOARD_RECOVERY_BLDRMSG_OFFSET)
endif

ifeq ($(BOARD_SUPPRESS_EMMC_WIPE),true)
    LOCAL_CFLAGS += -DSUPPRESS_EMMC_WIPE
endif
+9 −0
Original line number Diff line number Diff line
@@ -1554,6 +1554,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
    ota_fwrite(buffer, sizeof(((struct bootloader_message*)0)->command), 1, f);
    fclose(f);
    free(filename);
@@ -1601,6 +1604,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) {
@@ -1627,6 +1633,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
    ota_fread(buffer, sizeof(buffer), 1, f);
    fclose(f);
    buffer[sizeof(buffer)-1] = '\0';