Unify Power menu bootloader entry as 'Reboot to loader' into lk2nd Fastboot menu

This commit is contained in:
Luxferre
2026-10-25 08:36:27 +02:00
parent a117e74452
commit fb5b9c9982
12 changed files with 40 additions and 33 deletions
+3 -3
View File
@@ -52,7 +52,7 @@ sudo ./flash-edl.sh
The script will:
1. Temporarily pause host `ModemManager` so it does not interfere with `05c6:9008`.
2. Wait for the phone to appear in Qualcomm EDL mode (`05c6:9008`):
- **From Bananarchy Linux**: open the **Power** menu (`End / Power` key or `System menu -> Power`) and select **Reboot to EDL** (or run `sxmo_power.sh edl`).
- **From Bananarchy Linux**: open the **Power** menu (`End / Power` key or `System menu -> Power`), select **Reboot to loader** (`sxmo_power.sh loader`) to enter the `lk2nd` Fastboot menu, and select **EDL** (or let `flash-edl.sh` automatically send `fastboot oem edl`).
- **Button combo**: power off the phone, hold **D-Pad up + D-Pad down**, and plug in the USB cable.
- **EDL cable**: hold the EDL cable button while plugging in USB.
- **From ADB / Fastboot**: the script automatically sends `adb reboot edl` or `fastboot oem edl` if detected.
@@ -64,7 +64,7 @@ The script will:
### Method B: Fastboot flashing (once `lk2nd` is installed)
1. Enter `lk2nd` Fastboot mode either by selecting **Reboot to Fastboot** from the **Power** menu (`sxmo_power.sh fastboot`) or by holding **D-Pad up** while powering on the phone.
1. Enter the `lk2nd` Fastboot menu either by selecting **Reboot to loader** from the **Power** menu (`sxmo_power.sh loader`) or by holding **D-Pad up** while powering on the phone.
2. Flash the system image to `userdata`:
```bash
fastboot flash userdata ./images/bananarchy-nokia-argon.img
@@ -129,7 +129,7 @@ All fourteen core phone overlays are compiled as shared-object plugins (`/usr/li
1. **`DMenu` (`dmenu.so` / `dmenu` / `xdmenu`) — Zero-Lag System & Context Menus**:
- **Open / Close**: Press **Left softkey (`Menu`)** for the **System menu** (`sys`) or **Right softkey (`Back`)** inside an application for its **Context menu** (`ctx`); press the same softkey or `Escape` to close.
- **Built-in Native Menus & `< 0.5 ms` In-Place Transitions**: Renders `sys`, `ctx`, `applications` (including **Nano**, **Bantam**, **Files**, **Camera**, **Dialer**, **Contacts**), `scripts`, `modem`, `config`, `power` (with **Reboot**, **Reboot to Fastboot**, **Reboot to EDL**, and **Poweroff** via `sxmo_power.sh`), `audio`, `notifications`, `wm`, `timezone`, `games`, `st`, `nano`, `sthotkeys`, and confirmation prompts directly inside the resident `240x296` plugin window without spawning shell scripts or new X11 connections. Submenu transitions (`@menu:...`) and hardware toggles (`@toggle:flashlight`, `@toggle:brightness`, `@toggle:autosuspend`, `@toggle:autocallscreenoff`, `@toggle:bluetooth`, `@toggle:dnd`) update in place in `< 0.5 ms`.
- **Built-in Native Menus & `< 0.5 ms` In-Place Transitions**: Renders `sys`, `ctx`, `applications` (including **Nano**, **Bantam**, **Files**, **Camera**, **Dialer**, **Contacts**), `scripts`, `modem`, `config`, `power` (with **Reboot**, **Reboot to loader**, and **Poweroff** via `sxmo_power.sh`), `audio`, `notifications`, `wm`, `timezone`, `games`, `st`, `nano`, `sthotkeys`, and confirmation prompts directly inside the resident `240x296` plugin window without spawning shell scripts or new X11 connections. Submenu transitions (`@menu:...`) and hardware toggles (`@toggle:flashlight`, `@toggle:brightness`, `@toggle:autosuspend`, `@toggle:autocallscreenoff`, `@toggle:bluetooth`, `@toggle:dnd`) update in place in `< 0.5 ms`.
- **Client Socket Mode (`/tmp/dwm_plugin_dmenu.sock`)**: Any script piping items into `/usr/bin/dmenu` or `sxmo_dmenu.sh` streams its item list over the Unix domain socket to the resident `dmenu.so` daemon and receives the user's selection instantaneously, while `/tmp/dwm_plugin_dmenu.active` provides zero-overhead `sxmo_dmenu.sh isopen` checks.
2. **`XDrawer` (`xdrawer.so` / `xdrawer`) — Global Phone Controls**:
Binary file not shown.
+1
View File
@@ -31,6 +31,7 @@ permit nopass :wheel as root cmd tee args -a /sys/power/wake_lock
permit nopass :wheel as root cmd tee args -a /sys/power/wake_unlock
permit nopass :wheel as root cmd tee args /sys/power/wakeup_count
permit nopass :wheel as root cmd tee args /sys/module/leds_msm8905_torch/parameters/next_reboot_mode
permit nopass :wheel as root cmd /usr/bin/tee args /sys/module/leds_msm8905_torch/parameters/next_reboot_mode
permit nopass :wheel as root cmd /usr/bin/sxmo_power.sh
permit nopass :wheel as root cmd sxmo_power.sh
permit nopass :wheel as root cmd rc-service args hexagonrpcd-adsp-sensorspd stop
+1 -2
View File
@@ -210,8 +210,7 @@ getprogchoices() {
$icon_lck Lock (Screen off)^0^sxmo_state.sh set screenoff
$icon_out Logout^0^confirm Logout && sxmo_power.sh logout
$icon_rld Reboot^0^confirm Reboot && sxmo_power.sh reboot
$icon_rld Reboot to Fastboot^0^confirm Fastboot && sxmo_power.sh fastboot
$icon_rld Reboot to EDL^0^confirm EDL && sxmo_power.sh edl
$icon_rld Reboot to loader^0^confirm Loader && sxmo_power.sh loader
$icon_pwr Poweroff^0^confirm Poweroff && sxmo_power.sh poweroff"
;;
modem)
+8 -7
View File
@@ -8,7 +8,7 @@ export PATH="/sbin:/usr/sbin:$PATH"
. sxmo_common.sh
usage() {
printf "usage: %s [reboot|fastboot|bootloader|edl|poweroff|logout|togglewm]\n" "$(basename "$0")"
printf "usage: %s [reboot|loader|poweroff|logout|togglewm]\n" "$(basename "$0")"
}
run_polkit_login1() {
@@ -93,8 +93,9 @@ set_kernel_reboot_mode() {
rmode="$1"
param_path="/sys/module/leds_msm8905_torch/parameters/next_reboot_mode"
if [ -e "$param_path" ]; then
printf "%s\n" "$rmode" | /usr/bin/doas tee "$param_path" >/dev/null 2>&1 || \
printf "%s\n" "$rmode" > "$param_path" 2>/dev/null || true
printf "%s\n" "$rmode" > "$param_path" 2>/dev/null || \
printf "%s\n" "$rmode" | /usr/bin/doas /usr/bin/tee "$param_path" >/dev/null 2>&1 || \
printf "%s\n" "$rmode" | /usr/bin/doas tee "$param_path" >/dev/null 2>&1 || true
fi
}
@@ -122,13 +123,13 @@ case "$1" in
fi
sxmo_jobs.sh stop all >/dev/null 2>&1 || true
;;
fastboot|bootloader)
loader|fastboot|bootloader)
sync
set_kernel_reboot_mode "bootloader"
set_kernel_reboot_mode "loader"
sxmo_hook_power.sh reboot || true
(sleep 4; force_reboot_cmd "bootloader") &
(sleep 4; force_reboot_cmd "loader") &
if ! run_priv_power reboot; then
force_reboot_cmd "bootloader"
force_reboot_cmd "loader"
fi
sxmo_jobs.sh stop all >/dev/null 2>&1 || true
;;
Binary file not shown.
@@ -91,8 +91,7 @@ case "$WMCLASS" in
$icon_lck Lock (Screen off) ^ 0 ^ sxmo_state.sh set screenoff
$icon_out Logout ^ 0 ^ confirm Logout && sxmo_power.sh logout
$icon_rld Reboot ^ 0 ^ confirm Reboot && sxmo_power.sh reboot
$icon_rld Reboot to Fastboot ^ 0 ^ confirm Fastboot && sxmo_power.sh fastboot
$icon_rld Reboot to EDL ^ 0 ^ confirm EDL && sxmo_power.sh edl
$icon_rld Reboot to loader ^ 0 ^ confirm Loader && sxmo_power.sh loader
$icon_pwr Poweroff ^ 0 ^ confirm Poweroff && sxmo_power.sh poweroff
"
WINNAME=Power
Binary file not shown.
+21 -8
View File
@@ -62,7 +62,7 @@
static char next_reboot_mode[32];
module_param_string(next_reboot_mode, next_reboot_mode, sizeof(next_reboot_mode), 0644);
MODULE_PARM_DESC(next_reboot_mode, "Next reboot target mode (bootloader, fastboot, edl)");
MODULE_PARM_DESC(next_reboot_mode, "Next reboot target mode (loader, bootloader, fastboot, edl)");
static void __iomem *tlmm_gpio32_base;
static void __iomem *gcc_camss_base;
@@ -192,8 +192,11 @@ static unsigned int msm8905_pon_prepare_restart_mode(const char *cmd)
if ((!mode || !mode[0]) && cmd && cmd[0])
mode = cmd;
if (!mode || !mode[0])
if (!mode || !mode[0]) {
if (pon_regmap)
regmap_write(pon_regmap, QPNP_PON_SOFT_RB_SPARE, 0x00U);
return PON_POWER_OFF_HARD_RESET;
}
strscpy(trimmed, mode, sizeof(trimmed));
len = strlen(trimmed);
@@ -202,21 +205,26 @@ static unsigned int msm8905_pon_prepare_restart_mode(const char *cmd)
trimmed[--len] = '\0';
}
if (strcmp(trimmed, "bootloader") == 0 || strcmp(trimmed, "fastboot") == 0) {
if (strcmp(trimmed, "loader") == 0 ||
strcmp(trimmed, "bootloader") == 0 ||
strcmp(trimmed, "fastboot") == 0) {
if (pon_regmap) {
/*
* Write 0x04 (1 << 2) into PON_SOFT_RB_SPARE (0x088f) matching
* mode-bootloader = <0x02> so lk2nd enters Fastboot mode on reboot.
* Stock Nokia aboot (0x2327c) reads PON_SOFT_RB_SPARE (0x088f), clears
* bits [7:2] via `and r1, r4, #3`, and writes bits [1:0] back to 0x088f
* before chainloading lk2nd from the boot partition.
* Write 0x02 (FASTBOOT_MODE = 2 in bits [1:0], 0 in bits [7:2]) so
* stock aboot boots lk2nd normally and lk2nd enters its Fastboot menu.
*/
regmap_update_bits(pon_regmap, QPNP_PON_SOFT_RB_SPARE, 0xfcU, 0x04U);
regmap_write(pon_regmap, QPNP_PON_SOFT_RB_SPARE, 0x02U);
}
pr_info("leds-msm8905-torch: armed PM8909 PON_SOFT_RB_SPARE for lk2nd Fastboot\n");
pr_info("leds-msm8905-torch: armed PM8909 PON_SOFT_RB_SPARE (0x02) for lk2nd Fastboot menu\n");
return PON_POWER_OFF_HARD_RESET;
}
if (strcmp(trimmed, "edl") == 0) {
if (pon_regmap)
regmap_update_bits(pon_regmap, QPNP_PON_SOFT_RB_SPARE, 0xfcU, 0x00U);
regmap_write(pon_regmap, QPNP_PON_SOFT_RB_SPARE, 0x00U);
ret = qcom_scm_io_writel(MSM8905_TCSR_BOOT_MISC_DETECT, MSM8905_DLOAD_EDL);
if (ret) {
@@ -232,12 +240,17 @@ static unsigned int msm8905_pon_prepare_restart_mode(const char *cmd)
return PON_POWER_OFF_WARM_RESET;
}
if (pon_regmap)
regmap_write(pon_regmap, QPNP_PON_SOFT_RB_SPARE, 0x00U);
return PON_POWER_OFF_HARD_RESET;
}
static int msm8905_pon_sys_poweroff(struct sys_off_data *data)
{
msm8905_torch_hw_disable();
if (pon_regmap)
regmap_write(pon_regmap, QPNP_PON_SOFT_RB_SPARE, 0x00U);
msm8905_pon_config_reset(PON_POWER_OFF_SHUTDOWN);
return NOTIFY_DONE;
}
+5 -11
View File
@@ -2190,10 +2190,8 @@ open_builtin_menu(const char *menu_name, int keep_idx)
add_menu_item(label, "@menu:confirm_logout", 1);
snprintf(label, sizeof(label), "%s Reboot", ICON_RLD);
add_menu_item(label, "@menu:confirm_reboot", 1);
snprintf(label, sizeof(label), "%s Reboot to Fastboot", ICON_RLD);
add_menu_item(label, "@menu:confirm_fastboot", 1);
snprintf(label, sizeof(label), "%s Reboot to EDL", ICON_RLD);
add_menu_item(label, "@menu:confirm_edl", 1);
snprintf(label, sizeof(label), "%s Reboot to loader", ICON_RLD);
add_menu_item(label, "@menu:confirm_loader", 1);
snprintf(label, sizeof(label), "%s Poweroff", ICON_PWR);
add_menu_item(label, "@menu:confirm_poweroff", 1);
snprintf(label, sizeof(label), "%s System Menu", ICON_MNU);
@@ -2208,13 +2206,9 @@ open_builtin_menu(const char *menu_name, int keep_idx)
reset_session_defaults(1, "Confirm Reboot");
add_menu_item("Yes", "sxmo_power.sh reboot", 0);
add_menu_item("No", "@menu:power", 1);
} else if (strcmp(menu_name, "confirm_fastboot") == 0) {
reset_session_defaults(1, "Confirm Fastboot");
add_menu_item("Yes", "sxmo_power.sh fastboot", 0);
add_menu_item("No", "@menu:power", 1);
} else if (strcmp(menu_name, "confirm_edl") == 0) {
reset_session_defaults(1, "Confirm EDL Mode");
add_menu_item("Yes", "sxmo_power.sh edl", 0);
} else if (strcmp(menu_name, "confirm_loader") == 0) {
reset_session_defaults(1, "Confirm Loader");
add_menu_item("Yes", "sxmo_power.sh loader", 0);
add_menu_item("No", "@menu:power", 1);
} else if (strcmp(menu_name, "confirm_poweroff") == 0) {
reset_session_defaults(1, "Confirm Poweroff");