From e71d06699a06481dccd917541ce8908b7ba89b25 Mon Sep 17 00:00:00 2001 From: BetaRays <26482956+BetaRays@users.noreply.github.com> Date: Sun, 10 Aug 2025 10:17:49 +0200 Subject: [PATCH] Add menu option to skip lk2nd_boot This can be useful when dual-booting Android on the internal storage and postmarketOS on an SD card without physically removing it on using fastboot boot with the flashed Android boot image. This can be useful considering Android is required to charge the battery (safely) for some devices. --- app/aboot/aboot.c | 21 +++++++++++++++++++++ lk2nd/device/menu/menu.c | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c index 8ff43f59e..cf0cafd21 100644 --- a/app/aboot/aboot.c +++ b/app/aboot/aboot.c @@ -4680,6 +4680,27 @@ void cmd_continue(const char *arg, void *data, unsigned sz) } } +#if WITH_LK2ND_BOOT +void cmd_continue_skip_lk2ndboot(const char *arg, void *data, unsigned sz) +{ + fastboot_okay(""); + fastboot_stop(); + + if (target_is_emmc_boot()) + { +#if FBCON_DISPLAY_MSG + /* Exit keys' detection thread firstly */ + exit_menu_keys_detection(); +#endif + boot_linux_from_mmc(); + } + else + { + boot_linux_from_flash(); + } +} +#endif + void cmd_reboot(const char *arg, void *data, unsigned sz) { dprintf(INFO, "rebooting the device\n"); diff --git a/lk2nd/device/menu/menu.c b/lk2nd/device/menu/menu.c index 28ab377e7..1f921e9ce 100644 --- a/lk2nd/device/menu/menu.c +++ b/lk2nd/device/menu/menu.c @@ -20,6 +20,9 @@ // Defined in app/aboot/aboot.c extern void cmd_continue(const char *arg, void *data, unsigned sz); +#if WITH_LK2ND_BOOT +extern void cmd_continue_skip_lk2ndboot(const char *arg, void *data, unsigned sz); +#endif #define FONT_WIDTH (5+1) #define FONT_HEIGHT 12 @@ -122,6 +125,9 @@ static uint16_t wait_key(void) #define str(s) #s static void opt_continue(void) { cmd_continue(NULL, NULL, 0); } +#ifdef WITH_LK2ND_BOOT +static void opt_continue_skip_lk2nd(void) { cmd_continue_skip_lk2ndboot(NULL, NULL, 0); } +#endif static void opt_reboot(void) { reboot_device(0); } static void opt_recovery(void) { @@ -141,6 +147,9 @@ static struct { } menu_options[] = { { " Reboot ", GREEN, opt_reboot }, { " Continue ", WHITE, opt_continue }, +#ifdef WITH_LK2ND_BOOT + { "Skip lk2nd", WHITE, opt_continue_skip_lk2nd }, +#endif { " Recovery ", ORANGE, opt_recovery }, { "Bootloader", ORANGE, opt_bootloader }, { " EDL ", RED, opt_edl },