From 406a28cc6ab61dacca4cba747c0bb1eef53a3c24 Mon Sep 17 00:00:00 2001 From: Marcin Bukat Date: Wed, 7 Oct 2026 16:03:44 +0200 Subject: [PATCH] rk27xx: boot the OF when it asked for a reboot Before the original firmware resets itself, e.g. at the end of a firmware update, it stores a boot mode in an undocumented GPIO1 register that keeps its value over the reset. The NAND bootloader reads it to decide whether to boot at all, then starts our bootloader, which chose Rockbox or the OF from the buttons alone, so an OF that restarted itself came back up as Rockbox. Rockbox never writes the register and it reads 0 after power-on, so boot the OF whenever it is set. Co-Authored-By: Claude Opus 5.5 Change-Id: I22a98cafad48f66302a8401c9df847a073675a58 --- bootloader/rk27xx.c | 8 ++++++++ firmware/export/rk27xx.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/bootloader/rk27xx.c b/bootloader/rk27xx.c index 4f04bebfc8..db4fd675ac 100644 --- a/bootloader/rk27xx.c +++ b/bootloader/rk27xx.c @@ -139,6 +139,14 @@ void main(void) if (DEV_INFO & (1<<20)) boot = of; + /* The OF asks for a mode before it resets itself, e.g. at the end of + * a firmware update, and the cell survives the reset. Rockbox never + * sets it, so after a cold start it reads 0: anything else is a + * request from the OF, which expects to come back up. + */ + if (GPIO1_BOOTMODE & 0xff) + boot = of; + lcd_clear_display(); ret = storage_init(); diff --git a/firmware/export/rk27xx.h b/firmware/export/rk27xx.h index 4579a8914e..5ec71f3f8c 100644 --- a/firmware/export/rk27xx.h +++ b/firmware/export/rk27xx.h @@ -429,6 +429,8 @@ #define GPIO_PECON (*(volatile unsigned long *)(APB0_GPIO1 + 0x04)) #define GPIO_PFDR (*(volatile unsigned long *)(APB0_GPIO1 + 0x08)) #define GPIO_PFCON (*(volatile unsigned long *)(APB0_GPIO1 + 0x0C)) +/* undocumented, kept over a reset: the OF leaves its boot request here */ +#define GPIO1_BOOTMODE (*(volatile unsigned long *)(APB0_GPIO1 + 0x1C)) #define GPIO1_TEST (*(volatile unsigned long *)(APB0_GPIO1 + 0x20)) #define GPIO_IEE (*(volatile unsigned long *)(APB0_GPIO1 + 0x24))