diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c index b8337c8721..9f2d2483f8 100644 --- a/app/aboot/aboot.c +++ b/app/aboot/aboot.c @@ -4789,14 +4789,14 @@ void CmdUpdateSnapshot(const char *arg, void *data, unsigned sz) if (command) { command++; - if(!strncmp (command, "merge", AsciiStrLen ("merge"))) { + if(!strncmp (command, "merge", strlen ("merge"))) { if (GetSnapshotMergeStatus () == MERGING) { - cmd_reboot_fastboot(Arg, Data, Size); + cmd_reboot_fastboot(arg, data, sz); } - FastbootOkay (""); + fastboot_okay (""); return; } - else if (!strncmp (Command, "cancel", AsciiStrLen ("cancel"))) { + else if (!strncmp (command, "cancel", strlen ("cancel"))) { if(!device.is_unlocked) { fastboot_fail ("Snapshot Cancel is not allowed in Lock State"); return; diff --git a/app/aboot/recovery.c b/app/aboot/recovery.c index b1ad21cc54..b7f27dc850 100644 --- a/app/aboot/recovery.c +++ b/app/aboot/recovery.c @@ -468,13 +468,17 @@ int _emmc_recovery_init(void) static int read_misc(unsigned page_offset, void *buf, unsigned size) { const char *ptn_name = "misc"; - uint32_t pagesize = get_page_size(); unsigned offset; if (size == 0 || buf == NULL) return -1; - offset = page_offset * pagesize; +#if VIRTUAL_AB_OTA + offset = page_offset; +#else + uint32_t pagesize = get_page_size(); + offset = page_offset * pagesize; +#endif if (target_is_emmc_boot()) { diff --git a/app/aboot/rules.mk b/app/aboot/rules.mk index de0a3c8ca3..ccb777e511 100644 --- a/app/aboot/rules.mk +++ b/app/aboot/rules.mk @@ -13,7 +13,6 @@ OBJS += \ ifeq ($(ABOOT_STANDALONE), 1) DEFINES += ABOOT_STANDALONE=1 -OBJS := $(filter-out $(LOCAL_DIR)/recovery.o, $(OBJS)) DEFINES := $(filter-out SSD_ENABLE TZ_SAVE_KERNEL_HASH TZ_TAMPER_FUSE, $(DEFINES)) endif diff --git a/lk2nd/device/menu/menu.c b/lk2nd/device/menu/menu.c index 064f669f41..153ce83aee 100644 --- a/lk2nd/device/menu/menu.c +++ b/lk2nd/device/menu/menu.c @@ -15,7 +15,6 @@ #include #include #include - #include "../device.h" // Defined in app/aboot/aboot.c @@ -127,6 +126,13 @@ static void opt_recoery(void) { reboot_device(RECOVERY_MODE); } static void opt_bootloader(void) { reboot_device(FASTBOOT_MODE); } static void opt_edl(void) { reboot_device(EMERGENCY_DLOAD); } static void opt_shutdown(void) { shutdown_device(); } +#if SLOTS_SUPPORTED +static void opt_switch_slot(void){ + int current_active_slot = partition_find_active_slot(); + partition_switch_slots(current_active_slot, !current_active_slot, true); + reboot_device(FASTBOOT_MODE); +} +#endif static struct { char *name; @@ -137,6 +143,9 @@ static struct { { " Continue ", WHITE, opt_continue }, { " Recovery ", ORANGE, opt_recoery }, { "Bootloader", ORANGE, opt_bootloader }, +#if SLOTS_SUPPORTED + { "Switch Slot", RED, opt_switch_slot }, +#endif { " EDL ", RED, opt_edl }, { " Shutdown ", RED, opt_shutdown }, }; @@ -147,6 +156,11 @@ static struct { y += incr; \ } while(0) +#define fbcon_printfn(color, y, incr, x...) \ + do { \ + fbcon_printf(color, y, x); \ + } while(0) + #define fbcon_puts_ln(color, y, incr, center, str) \ do { \ fbcon_puts(str, color, y, center); \ @@ -228,6 +242,11 @@ void display_fastboot_menu(void) if (lk2nd_dev.bootloader) fbcon_printf_ln(SILVER, y, incr, false, " Bootloader: %s", lk2nd_dev.bootloader); #endif +#if SLOTS_SUPPORTED + int current_active_slot = partition_find_active_slot(); + fbcon_printfn(SILVER, y, incr, false, " Active Slot: "); + fbcon_printf_ln(current_active_slot ? GREEN : RED, y, incr, false, " %s", current_active_slot ? "B" : "A"); +#endif fbcon_printf_ln(armv8 ? GREEN : YELLOW, y, incr, false, " ARM64: %s", armv8 ? "available" : "unavailable"); diff --git a/makefile b/makefile index 11224ad6c2..67a3561926 100644 --- a/makefile +++ b/makefile @@ -134,6 +134,14 @@ ifeq ($(DYNAMIC_PARTITION_SUPPORT),1) DEFINES += DYNAMIC_PARTITION_SUPPORT=1 endif +ifeq ($(SLOTS_SUPPORTED),1) + DEFINES += SLOTS_SUPPORTED=1 +endif + +ifeq ($(VIRTUAL_AB_OTA),1) + DEFINES += VIRTUAL_AB_OTA=1 +endif + ifeq ($(TARGET_DTBO_NOT_SUPPORTED),1) DEFINES += TARGET_DTBO_NOT_SUPPORTED=1 endif diff --git a/platform/msm_shared/include/ab_partition_parser.h b/platform/msm_shared/include/ab_partition_parser.h index 9145ebf504..c7c138b4af 100644 --- a/platform/msm_shared/include/ab_partition_parser.h +++ b/platform/msm_shared/include/ab_partition_parser.h @@ -79,7 +79,11 @@ int partition_fill_partition_meta(char has_slot_pname[][MAX_GET_VAR_NAME_SIZE], char has_slot_reply[][MAX_RSP_SIZE], int array_size); /* Fill partition slot info meta*/ -static inline bool partition_multislot_is_supported(void) -{ - return target_is_emmc_boot() && _partition_multislot_is_supported(); +static inline bool partition_multislot_is_supported(void){ +#if SLOTS_SUPPORTED + return true; +#else + return false; +#endif } +