* [PATCH] arm: rockchip: spl: Add hotkey detection support.
@ 2026-08-15 17:08 Valentin Liu
2026-08-15 17:59 ` Tom Rini
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Valentin Liu @ 2026-08-15 17:08 UTC (permalink / raw)
To: u-boot, Tom Rini, Ilias Apalodimas, Quentin Schulz, Kever Yang
Cc: Simon Glass, Valentin Liu
Add a configurable Rockchip SPL hotkey feature that checks the
serial console during SPL startup.
Ctrl+B can be used to enter BootROM download (MASKROM) mode and
be widely used. We can add more boot mode support in future.
Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
the serial port to be ready to receive input before checking for
hotkeys.
Signed-off-by: Valentin Liu <valentinliu@icloud.com>
---
arch/arm/mach-rockchip/Kconfig | 15 ++++++++++++
arch/arm/mach-rockchip/spl.c | 42 ++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 1a2e7847c9e..a5de483bbb9 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -743,6 +743,21 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
config SPL_MMC
default y if !SPL_ROCKCHIP_BACK_TO_BROM
+config SPL_ROCKCHIP_HOTKEY
+ bool "SPL hotkey support"
+ depends on SPL
+ depends on SPL_DM_RESET
+ depends on SPL_SERIAL
+ help
+ Enable hotkey detection during SPL booting stage.
+
+ When enabled, SPL checks the serial console for a control
+ character and can execute Rockchip-specific hotkey actions,
+ such as entering BootROM download mode (MASKROM) with Ctrl+B.
+
+ The hotkey is checked after the SPL console has been
+ initialized.
+
config ROCKCHIP_SPI_IMAGE
bool "Build a SPI image for rockchip"
help
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
index e989c148079..46140e5af3c 100644
--- a/arch/arm/mach-rockchip/spl.c
+++ b/arch/arm/mach-rockchip/spl.c
@@ -19,6 +19,11 @@
#include <asm/global_data.h>
#include <asm/io.h>
#include <linux/bitops.h>
+#if IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY)
+#include <serial.h>
+#include <asm/arch-rockchip/boot_mode.h>
+#include <linux/delay.h>
+#endif
DECLARE_GLOBAL_DATA_PTR;
@@ -107,6 +112,40 @@ __weak int arch_cpu_init(void)
return 0;
}
+#if IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY)
+static void rockchip_reset_from_hotkey(const int code)
+{
+ switch (code) {
+ case 0x02:
+ printf("SPL Hotkey: Ctrl+B: BootROM download!\n");
+ writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG);
+ do_reset(NULL, 0, 0, NULL);
+ /*NOTREACHED*/
+ default:
+ if (code <= 0x1a) /* 'z' */
+ printf("SPL Hotkey: Ctrl+%c\n", code + 'A' - 1);
+ else
+ printf("SPL Hotkey: Unknown code: 0x%x, ignore\n", code);
+ }
+}
+
+static void spl_hotkey_init(void)
+{
+ if (!gd || !(gd->flags & GD_FLG_HAVE_CONSOLE))
+ return;
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return;
+
+ /* Wait for the serial port to be ready to receive data. */
+ mdelay(100);
+
+ if (serial_tstc())
+ rockchip_reset_from_hotkey(serial_getc());
+ else
+ printf("SPL Hotkey: No key pressed, continue\n");
+}
+#endif
+
void board_init_f(ulong dummy)
{
int ret;
@@ -143,6 +182,9 @@ void board_init_f(ulong dummy)
}
#endif
preloader_console_init();
+
+ if (IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY))
+ spl_hotkey_init();
}
void spl_board_prepare_for_boot(void)
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] arm: rockchip: spl: Add hotkey detection support.
2026-08-15 17:08 [PATCH] arm: rockchip: spl: Add hotkey detection support Valentin Liu
@ 2026-08-15 17:59 ` Tom Rini
2026-08-15 18:23 ` [PATCH v2] " Valentin Liu
2026-08-15 18:34 ` Valentin Liu
2 siblings, 0 replies; 13+ messages in thread
From: Tom Rini @ 2026-08-15 17:59 UTC (permalink / raw)
To: Valentin Liu
Cc: u-boot, Ilias Apalodimas, Quentin Schulz, Kever Yang, Simon Glass
[-- Attachment #1: Type: text/plain, Size: 1806 bytes --]
On Sun, Aug 16, 2026 at 01:08:44AM +0800, Valentin Liu wrote:
> Add a configurable Rockchip SPL hotkey feature that checks the
> serial console during SPL startup.
>
> Ctrl+B can be used to enter BootROM download (MASKROM) mode and
> be widely used. We can add more boot mode support in future.
>
> Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
> the serial port to be ready to receive input before checking for
> hotkeys.
>
> Signed-off-by: Valentin Liu <valentinliu@icloud.com>
> ---
> arch/arm/mach-rockchip/Kconfig | 15 ++++++++++++
> arch/arm/mach-rockchip/spl.c | 42 ++++++++++++++++++++++++++++++++++
> 2 files changed, 57 insertions(+)
>
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index 1a2e7847c9e..a5de483bbb9 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -743,6 +743,21 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
> config SPL_MMC
> default y if !SPL_ROCKCHIP_BACK_TO_BROM
>
> +config SPL_ROCKCHIP_HOTKEY
> + bool "SPL hotkey support"
> + depends on SPL
> + depends on SPL_DM_RESET
> + depends on SPL_SERIAL
This can just be:
depends on SPL_DM_RESET && SPL_SERIAL
[snip]
> diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
> index e989c148079..46140e5af3c 100644
> --- a/arch/arm/mach-rockchip/spl.c
> +++ b/arch/arm/mach-rockchip/spl.c
> @@ -19,6 +19,11 @@
> #include <asm/global_data.h>
> #include <asm/io.h>
> #include <linux/bitops.h>
> +#if IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY)
> +#include <serial.h>
> +#include <asm/arch-rockchip/boot_mode.h>
> +#include <linux/delay.h>
> +#endif
Guarding includes like this isn't a good practice and should be avoided
unless strictly needed.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2] arm: rockchip: spl: Add hotkey detection support.
2026-08-15 17:08 [PATCH] arm: rockchip: spl: Add hotkey detection support Valentin Liu
2026-08-15 17:59 ` Tom Rini
@ 2026-08-15 18:23 ` Valentin Liu
2026-08-15 18:34 ` Valentin Liu
2 siblings, 0 replies; 13+ messages in thread
From: Valentin Liu @ 2026-08-15 18:23 UTC (permalink / raw)
To: Tom Rini, Ilias Apalodimas, Quentin Schulz, Kever Yang
Cc: Simon Glass, u-boot, Valentin Liu
Add a configurable Rockchip SPL hotkey feature that checks the
serial console during SPL startup.
Ctrl+B can be used to enter BootROM download (MASKROM) mode and
be widely used. We can add more boot mode support in future.
Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
the serial port to be ready to receive input before checking for
hotkeys.
Signed-off-by: Valentin Liu <valentinliu@icloud.com>
---
Changes for v2:
- Simplify the dependencies of SPL_ROCKCHIP_HOTKEY.
- Remove the conditions for the newly added includes.
arch/arm/mach-rockchip/Kconfig | 13 +++++++++++
arch/arm/mach-rockchip/spl.c | 40 ++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 1a2e7847c9e..f2d2b5520ef 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -743,6 +743,19 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
config SPL_MMC
default y if !SPL_ROCKCHIP_BACK_TO_BROM
+config SPL_ROCKCHIP_HOTKEY
+ bool "SPL hotkey support"
+ depends on SPL_DM_RESET && SPL_SERIAL
+ help
+ Enable hotkey detection during SPL booting stage.
+
+ When enabled, SPL checks the serial console for a control
+ character and can execute Rockchip-specific hotkey actions,
+ such as entering BootROM download mode (MASKROM) with Ctrl+B.
+
+ The hotkey is checked after the SPL console has been
+ initialized.
+
config ROCKCHIP_SPI_IMAGE
bool "Build a SPI image for rockchip"
help
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
index e989c148079..0422415b06e 100644
--- a/arch/arm/mach-rockchip/spl.c
+++ b/arch/arm/mach-rockchip/spl.c
@@ -13,12 +13,15 @@
#include <log.h>
#include <mapmem.h>
#include <ram.h>
+#include <serial.h>
#include <spl.h>
+#include <asm/arch-rockchip/boot_mode.h>
#include <asm/arch-rockchip/bootrom.h>
#include <asm/arch-rockchip/timer.h>
#include <asm/global_data.h>
#include <asm/io.h>
#include <linux/bitops.h>
+#include <linux/delay.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -107,6 +110,40 @@ __weak int arch_cpu_init(void)
return 0;
}
+#if IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY)
+static void rockchip_reset_from_hotkey(const int code)
+{
+ switch (code) {
+ case 0x02:
+ printf("SPL Hotkey: Ctrl+B: BootROM download!\n");
+ writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG);
+ do_reset(NULL, 0, 0, NULL);
+ /*NOTREACHED*/
+ default:
+ if (code <= 0x1a) /* 'z' */
+ printf("SPL Hotkey: Ctrl+%c\n", code + 'A' - 1);
+ else
+ printf("SPL Hotkey: Unknown code: 0x%x, ignore\n", code);
+ }
+}
+
+static void spl_hotkey_init(void)
+{
+ if (!gd || !(gd->flags & GD_FLG_HAVE_CONSOLE))
+ return;
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return;
+
+ /* Wait for the serial port to be ready to receive data. */
+ mdelay(100);
+
+ if (serial_tstc())
+ rockchip_reset_from_hotkey(serial_getc());
+ else
+ printf("SPL Hotkey: No key pressed, continue\n");
+}
+#endif
+
void board_init_f(ulong dummy)
{
int ret;
@@ -143,6 +180,9 @@ void board_init_f(ulong dummy)
}
#endif
preloader_console_init();
+
+ if (IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY))
+ spl_hotkey_init();
}
void spl_board_prepare_for_boot(void)
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2] arm: rockchip: spl: Add hotkey detection support.
2026-08-15 17:08 [PATCH] arm: rockchip: spl: Add hotkey detection support Valentin Liu
2026-08-15 17:59 ` Tom Rini
2026-08-15 18:23 ` [PATCH v2] " Valentin Liu
@ 2026-08-15 18:34 ` Valentin Liu
2026-08-18 16:55 ` [PATCH v3] " Valentin Liu
2 siblings, 1 reply; 13+ messages in thread
From: Valentin Liu @ 2026-08-15 18:34 UTC (permalink / raw)
To: u-boot, Tom Rini, Ilias Apalodimas, Quentin Schulz, Kever Yang
Cc: Simon Glass, Valentin Liu
Add a configurable Rockchip SPL hotkey feature that checks the
serial console during SPL startup.
Ctrl+B can be used to enter BootROM download (MASKROM) mode and
be widely used. We can add more boot mode support in future.
Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
the serial port to be ready to receive input before checking for
hotkeys.
Signed-off-by: Valentin Liu <valentinliu@icloud.com>
---
Changes for v2:
- Simplify the dependencies of SPL_ROCKCHIP_HOTKEY.
- Remove the conditions for the newly added includes.
arch/arm/mach-rockchip/Kconfig | 13 +++++++++++
arch/arm/mach-rockchip/spl.c | 40 ++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 1a2e7847c9e..f2d2b5520ef 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -743,6 +743,19 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
config SPL_MMC
default y if !SPL_ROCKCHIP_BACK_TO_BROM
+config SPL_ROCKCHIP_HOTKEY
+ bool "SPL hotkey support"
+ depends on SPL_DM_RESET && SPL_SERIAL
+ help
+ Enable hotkey detection during SPL booting stage.
+
+ When enabled, SPL checks the serial console for a control
+ character and can execute Rockchip-specific hotkey actions,
+ such as entering BootROM download mode (MASKROM) with Ctrl+B.
+
+ The hotkey is checked after the SPL console has been
+ initialized.
+
config ROCKCHIP_SPI_IMAGE
bool "Build a SPI image for rockchip"
help
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
index e989c148079..0422415b06e 100644
--- a/arch/arm/mach-rockchip/spl.c
+++ b/arch/arm/mach-rockchip/spl.c
@@ -13,12 +13,15 @@
#include <log.h>
#include <mapmem.h>
#include <ram.h>
+#include <serial.h>
#include <spl.h>
+#include <asm/arch-rockchip/boot_mode.h>
#include <asm/arch-rockchip/bootrom.h>
#include <asm/arch-rockchip/timer.h>
#include <asm/global_data.h>
#include <asm/io.h>
#include <linux/bitops.h>
+#include <linux/delay.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -107,6 +110,40 @@ __weak int arch_cpu_init(void)
return 0;
}
+#if IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY)
+static void rockchip_reset_from_hotkey(const int code)
+{
+ switch (code) {
+ case 0x02:
+ printf("SPL Hotkey: Ctrl+B: BootROM download!\n");
+ writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG);
+ do_reset(NULL, 0, 0, NULL);
+ /*NOTREACHED*/
+ default:
+ if (code <= 0x1a) /* 'z' */
+ printf("SPL Hotkey: Ctrl+%c\n", code + 'A' - 1);
+ else
+ printf("SPL Hotkey: Unknown code: 0x%x, ignore\n", code);
+ }
+}
+
+static void spl_hotkey_init(void)
+{
+ if (!gd || !(gd->flags & GD_FLG_HAVE_CONSOLE))
+ return;
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return;
+
+ /* Wait for the serial port to be ready to receive data. */
+ mdelay(100);
+
+ if (serial_tstc())
+ rockchip_reset_from_hotkey(serial_getc());
+ else
+ printf("SPL Hotkey: No key pressed, continue\n");
+}
+#endif
+
void board_init_f(ulong dummy)
{
int ret;
@@ -143,6 +180,9 @@ void board_init_f(ulong dummy)
}
#endif
preloader_console_init();
+
+ if (IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY))
+ spl_hotkey_init();
}
void spl_board_prepare_for_boot(void)
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v3] arm: rockchip: spl: Add hotkey detection support.
2026-08-15 18:34 ` Valentin Liu
@ 2026-08-18 16:55 ` Valentin Liu
2026-08-20 15:37 ` Quentin Schulz
2026-08-20 16:27 ` [PATCH v4] " Valentin Liu
0 siblings, 2 replies; 13+ messages in thread
From: Valentin Liu @ 2026-08-18 16:55 UTC (permalink / raw)
To: u-boot
Cc: trini, ilias.apalodimas, u-boot, kever.yang, sjg, jbx6244, jonas,
Valentin Liu
Add a configurable Rockchip SPL hotkey feature that checks the
serial console during SPL startup.
Ctrl+B can be used to enter BootROM download (MASKROM) mode and
be widely used. We can add more boot mode support in future.
Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
the serial port to be ready to receive input before checking for
hotkeys.
Signed-off-by: Valentin Liu <valentinliu@icloud.com>
---
Changes for v2:
- Simplify the dependencies of SPL_ROCKCHIP_HOTKEY.
- Remove the conditions for the newly added includes.
---
Changes for v3:
- Add a dummy spl_hotkey_init() to avoid undefined reference errors
when building without CONFIG_SPL_ROCKCHIP_HOTKEY.
arch/arm/mach-rockchip/Kconfig | 13 ++++++++++
arch/arm/mach-rockchip/spl.c | 44 ++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 1a2e7847c9e..f2d2b5520ef 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -743,6 +743,19 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
config SPL_MMC
default y if !SPL_ROCKCHIP_BACK_TO_BROM
+config SPL_ROCKCHIP_HOTKEY
+ bool "SPL hotkey support"
+ depends on SPL_DM_RESET && SPL_SERIAL
+ help
+ Enable hotkey detection during SPL booting stage.
+
+ When enabled, SPL checks the serial console for a control
+ character and can execute Rockchip-specific hotkey actions,
+ such as entering BootROM download mode (MASKROM) with Ctrl+B.
+
+ The hotkey is checked after the SPL console has been
+ initialized.
+
config ROCKCHIP_SPI_IMAGE
bool "Build a SPI image for rockchip"
help
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
index e989c148079..0bcfb42c306 100644
--- a/arch/arm/mach-rockchip/spl.c
+++ b/arch/arm/mach-rockchip/spl.c
@@ -13,11 +13,14 @@
#include <log.h>
#include <mapmem.h>
#include <ram.h>
+#include <serial.h>
#include <spl.h>
+#include <asm/arch-rockchip/boot_mode.h>
#include <asm/arch-rockchip/bootrom.h>
#include <asm/arch-rockchip/timer.h>
#include <asm/global_data.h>
#include <asm/io.h>
+#include <linux/delay.h>
#include <linux/bitops.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -107,6 +110,44 @@ __weak int arch_cpu_init(void)
return 0;
}
+#if IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY)
+static void rockchip_reset_from_hotkey(const int code)
+{
+ switch (code) {
+ case 0x02:
+ printf("SPL Hotkey: Ctrl+B: BootROM download!\n");
+ writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG);
+ do_reset(NULL, 0, 0, NULL);
+ /*NOTREACHED*/
+ default:
+ if (code <= 0x1a) /* 'z' */
+ printf("SPL Hotkey: Ctrl+%c\n", code + 'A' - 1);
+ else
+ printf("SPL Hotkey: Unknown code: 0x%x, ignore\n", code);
+ }
+}
+
+static void spl_hotkey_init(void)
+{
+ if (!gd || !(gd->flags & GD_FLG_HAVE_CONSOLE))
+ return;
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return;
+
+ /* Wait for the serial port to be ready to receive data. */
+ mdelay(100);
+
+ if (serial_tstc())
+ rockchip_reset_from_hotkey(serial_getc());
+ else
+ printf("SPL Hotkey: No key pressed, continue\n");
+}
+#else
+static void spl_hotkey_init(void)
+{
+}
+#endif
+
void board_init_f(ulong dummy)
{
int ret;
@@ -143,6 +184,9 @@ void board_init_f(ulong dummy)
}
#endif
preloader_console_init();
+
+ if (IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY))
+ spl_hotkey_init();
}
void spl_board_prepare_for_boot(void)
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v3] arm: rockchip: spl: Add hotkey detection support.
2026-08-18 16:55 ` [PATCH v3] " Valentin Liu
@ 2026-08-20 15:37 ` Quentin Schulz
2026-08-20 16:29 ` Re:Re: " 刘垣辰
2026-08-20 16:27 ` [PATCH v4] " Valentin Liu
1 sibling, 1 reply; 13+ messages in thread
From: Quentin Schulz @ 2026-08-20 15:37 UTC (permalink / raw)
To: Valentin Liu, u-boot
Cc: trini, ilias.apalodimas, kever.yang, sjg, jbx6244, jonas
Hi Valentin,
On 8/18/26 6:55 PM, Valentin Liu wrote:
> Add a configurable Rockchip SPL hotkey feature that checks the
> serial console during SPL startup.
>
> Ctrl+B can be used to enter BootROM download (MASKROM) mode and
> be widely used. We can add more boot mode support in future.
>
> Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
> the serial port to be ready to receive input before checking for
> hotkeys.
>
> Signed-off-by: Valentin Liu <valentinliu@icloud.com>
> ---
> Changes for v2:
> - Simplify the dependencies of SPL_ROCKCHIP_HOTKEY.
> - Remove the conditions for the newly added includes.
> ---
> Changes for v3:
> - Add a dummy spl_hotkey_init() to avoid undefined reference errors
> when building without CONFIG_SPL_ROCKCHIP_HOTKEY.
>
> arch/arm/mach-rockchip/Kconfig | 13 ++++++++++
> arch/arm/mach-rockchip/spl.c | 44 ++++++++++++++++++++++++++++++++++
> 2 files changed, 57 insertions(+)
>
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index 1a2e7847c9e..f2d2b5520ef 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -743,6 +743,19 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
> config SPL_MMC
> default y if !SPL_ROCKCHIP_BACK_TO_BROM
>
> +config SPL_ROCKCHIP_HOTKEY
> + bool "SPL hotkey support"
The symbol name and prompt is not clear enough on what it does.
config SPL_ROCKCHIP_ENTER_MASKROM_ON_KEY
bool "Enter MaskROM on key press during SPL"
maybe?
> + depends on SPL_DM_RESET && SPL_SERIAL
> + help
> + Enable hotkey detection during SPL booting stage.
> +
> + When enabled, SPL checks the serial console for a control
> + character and can execute Rockchip-specific hotkey actions,
> + such as entering BootROM download mode (MASKROM) with Ctrl+B.
> +
> + The hotkey is checked after the SPL console has been
> + initialized.
> +
Simplify to:
"""
When enabled, the SPL will check whether Ctrl+B is pressed and enter
MaskROM in that case.
"""
> config ROCKCHIP_SPI_IMAGE
> bool "Build a SPI image for rockchip"
> help
> diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
> index e989c148079..0bcfb42c306 100644
> --- a/arch/arm/mach-rockchip/spl.c
> +++ b/arch/arm/mach-rockchip/spl.c
> @@ -13,11 +13,14 @@
> #include <log.h>
> #include <mapmem.h>
> #include <ram.h>
> +#include <serial.h>
> #include <spl.h>
> +#include <asm/arch-rockchip/boot_mode.h>
> #include <asm/arch-rockchip/bootrom.h>
> #include <asm/arch-rockchip/timer.h>
> #include <asm/global_data.h>
> #include <asm/io.h>
> +#include <linux/delay.h>
> #include <linux/bitops.h>
>
> DECLARE_GLOBAL_DATA_PTR;
> @@ -107,6 +110,44 @@ __weak int arch_cpu_init(void)
> return 0;
> }
>
> +#if IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY)
Please use CONFIG_IS_ENABLED() instead.
> +static void rockchip_reset_from_hotkey(const int code)
> +{
> + switch (code) {
> + case 0x02:
Please add a small comment after 0x02: to specify which key combination
triggers this code. E.g.:
case 0x02: /* Ctrl+B */
> + printf("SPL Hotkey: Ctrl+B: BootROM download!\n");
Please be consistent with what we have in
arch/arm/mach-rockchip/boot_mode.c, that is:
"Ctrl+B pressed, entering download mode..."
I don't like it, as it's typically called MaskROM, but it's something we
can fix later on and I prefer being consistent with what we currently have.
> + writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG);
We *really* shouldn't be doing this if CONFIG_ROCKCHIP_BOOT_MODE_REG is
0 (the case for most boards).
> + do_reset(NULL, 0, 0, NULL);
> + /*NOTREACHED*/
> + default:
> + if (code <= 0x1a) /* 'z' */
> + printf("SPL Hotkey: Ctrl+%c\n", code + 'A' - 1);
> + else
> + printf("SPL Hotkey: Unknown code: 0x%x, ignore\n", code);> + }> +}
> +
> +static void spl_hotkey_init(void)
> +{
> + if (!gd || !(gd->flags & GD_FLG_HAVE_CONSOLE))
> + return;
> + if (gd->flags & GD_FLG_DISABLE_CONSOLE)
> + return;
> +
> + /* Wait for the serial port to be ready to receive data. */
> + mdelay(100);
> +
Is it not ready by the time we call this function? How did you come up
with 100ms?
> + if (serial_tstc())
> + rockchip_reset_from_hotkey(serial_getc());
> + else
> + printf("SPL Hotkey: No key pressed, continue\n");
We don't need to print on the standard path. If you reaaaaaaally want to
have something, then use log_debug/debug instead so it isn't printed by
default except if you build with debug logging enabled.
> +}
> +#else
> +static void spl_hotkey_init(void)
> +{
> +}
> +#endif
> +
> void board_init_f(ulong dummy)
> {
> int ret;
> @@ -143,6 +184,9 @@ void board_init_f(ulong dummy)
> }
> #endif
> preloader_console_init();
> +
> + if (IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY))
> + spl_hotkey_init();
Can we merge with the very similar logic we have for an ADC button in
arch/arm/mach-rockchip/boot_mode.c instead? I believe it makes more
sense to have everything capable of entering MaskROM mode in the same
place, with the same logic. I could see an else if() block in
rockchip_dnl_mode_check() for example.
Cheers,
Quentin
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v4] arm: rockchip: spl: Add hotkey detection support.
2026-08-18 16:55 ` [PATCH v3] " Valentin Liu
2026-08-20 15:37 ` Quentin Schulz
@ 2026-08-20 16:27 ` Valentin Liu
2026-08-20 16:36 ` Jonas Karlman
2026-08-21 14:06 ` [PATCH v5] " Valentin Liu
1 sibling, 2 replies; 13+ messages in thread
From: Valentin Liu @ 2026-08-20 16:27 UTC (permalink / raw)
To: u-boot
Cc: Tom Rini, Ilias Apalodimas, Quentin Schulz, Kever Yang,
Simon Glass, Johan Jonker, Jonas Karlman, Valentin Liu
Add a configurable Rockchip SPL hotkey feature that checks the
serial console during SPL startup.
Ctrl+B can be used to enter MaskROM mode and be widely used.
Ctrl+D can be used to enter Loader mode, Ctrl+F for Fastboot mode.
We can add more boot mode support in future.
Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
the serial port to be ready to receive input before checking for
hotkeys.
Signed-off-by: Valentin Liu <valentinliu@icloud.com>
---
Changes for v2:
- Simplify the dependencies of SPL_ROCKCHIP_HOTKEY.
- Remove the conditions for the newly added includes.
---
Changes for v3:
- Add a dummy spl_hotkey_init() to avoid undefined reference errors
when building without CONFIG_SPL_ROCKCHIP_HOTKEY.
---
Changes for v4:
- Add condition of CONFIG_ROCKCHIP_BOOT_MODE_REG != 0 to prevent
SPL hotkey be compiled and used on unsupported platforms.
- Add more hotkey support (Ctrl+D and Ctrl+F).
- Remove prints on the standard path.
- Add some code comment.
arch/arm/mach-rockchip/Kconfig | 14 +++++++++
arch/arm/mach-rockchip/spl.c | 54 ++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 1a2e7847c9e..0e485e8caf6 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -743,6 +743,20 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
config SPL_MMC
default y if !SPL_ROCKCHIP_BACK_TO_BROM
+config SPL_ROCKCHIP_HOTKEY
+ bool "SPL hotkey support"
+ depends on SPL_DM_RESET && SPL_SERIAL
+ help
+ Enable hotkey detection during SPL booting stage.
+
+ When enabled, SPL checks the serial console for a control
+ character and can execute Rockchip-specific hotkey actions,
+ such as entering MaskROM mode with Ctrl+B, entering Loader
+ mode with Ctrl+D, entering Fastboot mode with Ctrl+F.
+
+ The hotkey is checked after the SPL console has been
+ initialized.
+
config ROCKCHIP_SPI_IMAGE
bool "Build a SPI image for rockchip"
help
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
index e989c148079..8d0f605040f 100644
--- a/arch/arm/mach-rockchip/spl.c
+++ b/arch/arm/mach-rockchip/spl.c
@@ -13,11 +13,14 @@
#include <log.h>
#include <mapmem.h>
#include <ram.h>
+#include <serial.h>
#include <spl.h>
+#include <asm/arch-rockchip/boot_mode.h>
#include <asm/arch-rockchip/bootrom.h>
#include <asm/arch-rockchip/timer.h>
#include <asm/global_data.h>
#include <asm/io.h>
+#include <linux/delay.h>
#include <linux/bitops.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -107,6 +110,54 @@ __weak int arch_cpu_init(void)
return 0;
}
+#if CONFIG_IS_ENABLED(SPL_ROCKCHIP_HOTKEY) && (CONFIG_ROCKCHIP_BOOT_MODE_REG != 0)
+static void rockchip_reset_from_hotkey(const int code)
+{
+ switch (code) {
+ case 0x02: /* Ctrl+B */
+ printf("Ctrl+B pressed, entering download mode...\n");
+ writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG);
+ do_reset(NULL, 0, 0, NULL);
+ /* NOTREACHED */
+ case 0x04: /* Ctrl+D */
+ printf("Ctrl+D pressed, entering loader mode...\n");
+ writel(BOOT_LOADER, CONFIG_ROCKCHIP_BOOT_MODE_REG);
+ do_reset(NULL, 0, 0, NULL);
+ /* NOTREACHED */
+ case 0x06: /* Ctrl+F */
+ printf("Ctrl+F pressed, entering fastboot mode...\n");
+ writel(BOOT_FASTBOOT, CONFIG_ROCKCHIP_BOOT_MODE_REG);
+ do_reset(NULL, 0, 0, NULL);
+ /* NOTREACHED */
+ default:
+ if (code <= 0x1a) /* 'z' */
+ log_debug("SPL Hotkey: Ctrl+%c\n", code + 'A' - 1);
+ else
+ log_debug("SPL Hotkey: Unknown code: 0x%x, ignore\n", code);
+ }
+}
+
+static void spl_hotkey_init(void)
+{
+ if (!gd || !(gd->flags & GD_FLG_HAVE_CONSOLE))
+ return;
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return;
+
+ /* Wait for the serial port to be ready to receive data. */
+ mdelay(100);
+
+ if (serial_tstc())
+ rockchip_reset_from_hotkey(serial_getc());
+ else
+ log_debug("SPL Hotkey: No key pressed, continue\n");
+}
+#else
+static void spl_hotkey_init(void)
+{
+}
+#endif
+
void board_init_f(ulong dummy)
{
int ret;
@@ -143,6 +194,9 @@ void board_init_f(ulong dummy)
}
#endif
preloader_console_init();
+
+ if (CONFIG_IS_ENABLED(SPL_ROCKCHIP_HOTKEY))
+ spl_hotkey_init();
}
void spl_board_prepare_for_boot(void)
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re:Re: [PATCH v3] arm: rockchip: spl: Add hotkey detection support.
2026-08-20 15:37 ` Quentin Schulz
@ 2026-08-20 16:29 ` 刘垣辰
0 siblings, 0 replies; 13+ messages in thread
From: 刘垣辰 @ 2026-08-20 16:29 UTC (permalink / raw)
To: Quentin Schulz
Cc: u-boot, trini, ilias.apalodimas, kever.yang, sjg, jbx6244, jonas
[-- Attachment #1: Type: text/plain, Size: 5965 bytes --]
Hi Quentin, Thanks for your reviewing and suggestions. I think the config name shouldn't be changed to " SPL_ROCKCHIP_ENTER_MASKROM_ON_KEY ". Because this function is aim to provide a way to enter the MaskROM, Loader and more mode (supported by Rockchip chips directly) in SPL by pressing hotkey (like Ctrl+B, Ctrl+D) in serial. This function is dependent on a working serial port and not dependent a physical button. About merging code to rockchip_dnl_mode_check() and same places: The SPL hotkey support is aim to provide a way to enter MaskROM and more mode without ADC keys support. That's meaning we didn't need a physical button in board to enter MaskROM. About delay 100ms: I have tested this function on my Mekotronics R58X-4G board, this is the shortest time that the hotkey can be detected. (Even though, I still need to press Ctrl+B before SPL running) Sorry for my poor English, I'm trying my best to describe the function of this config in Kconfig. The other suggestions have been accepted in v4 patch. Like checking CONFIG_ROCKCHIP_BOOT_MODE_REG, adding a small comment. etc. Best regards, Valentin Liu 2026年8月20日下午11:38,Quentin Schulz <u-boot@0leil.net> 写道: Hi Valentin, On 8/18/26 6:55 PM, Valentin Liu wrote: Add a configurable Rockchip SPL hotkey feature that checks the serial console during SPL startup. Ctrl+B can be used to enter BootROM download (MASKROM) mode and be widely used. We can add more boot mode support in future. Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for the serial port to be ready to receive input before checking for hotkeys. Signed-off-by: Valentin Liu <valentinliu@icloud.com> --- Changes for v2: - Simplify the dependencies of SPL_ROCKCHIP_HOTKEY. - Remove the conditions for the newly added includes. --- Changes for v3: - Add a dummy spl_hotkey_init() to avoid undefined reference errors when building without CONFIG_SPL_ROCKCHIP_HOTKEY. arch/arm/mach-rockchip/Kconfig | 13 ++++++++++ arch/arm/mach-rockchip/spl.c | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index 1a2e7847c9e..f2d2b5520ef 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -743,6 +743,19 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM config SPL_MMC default y if !SPL_ROCKCHIP_BACK_TO_BROM +config SPL_ROCKCHIP_HOTKEY + bool "SPL hotkey support" The symbol name and prompt is not clear enough on what it does. config SPL_ROCKCHIP_ENTER_MASKROM_ON_KEY bool "Enter MaskROM on key press during SPL" maybe? + depends on SPL_DM_RESET && SPL_SERIAL + help + Enable hotkey detection during SPL booting stage. + + When enabled, SPL checks the serial console for a control + character and can execute Rockchip-specific hotkey actions, + such as entering BootROM download mode (MASKROM) with Ctrl+B. + + The hotkey is checked after the SPL console has been + initialized. + Simplify to: """ When enabled, the SPL will check whether Ctrl+B is pressed and enter MaskROM in that case. """ config ROCKCHIP_SPI_IMAGE bool "Build a SPI image for rockchip" help diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c index e989c148079..0bcfb42c306 100644 --- a/arch/arm/mach-rockchip/spl.c +++ b/arch/arm/mach-rockchip/spl.c @@ -13,11 +13,14 @@ #include <log.h> #include <mapmem.h> #include <ram.h> +#include <serial.h> #include <spl.h> +#include <asm/arch-rockchip/boot_mode.h> #include <asm/arch-rockchip/bootrom.h> #include <asm/arch-rockchip/timer.h> #include <asm/global_data.h> #include <asm/io.h> +#include <linux/delay.h> #include <linux/bitops.h> DECLARE_GLOBAL_DATA_PTR; @@ -107,6 +110,44 @@ __weak int arch_cpu_init(void) return 0; } +#if IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY) Please use CONFIG_IS_ENABLED() instead. +static void rockchip_reset_from_hotkey(const int code) +{ + switch (code) { + case 0x02: Please add a small comment after 0x02: to specify which key combination triggers this code. E.g.: case 0x02: /* Ctrl+B */ + printf("SPL Hotkey: Ctrl+B: BootROM download!\n"); Please be consistent with what we have in arch/arm/mach-rockchip/boot_mode.c, that is: "Ctrl+B pressed, entering download mode..." I don't like it, as it's typically called MaskROM, but it's something we can fix later on and I prefer being consistent with what we currently have. + writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG); We *really* shouldn't be doing this if CONFIG_ROCKCHIP_BOOT_MODE_REG is 0 (the case for most boards). + do_reset(NULL, 0, 0, NULL); + /*NOTREACHED*/ + default: + if (code <= 0x1a) /* 'z' */ + printf("SPL Hotkey: Ctrl+%c\n", code + 'A' - 1); + else + printf("SPL Hotkey: Unknown code: 0x%x, ignore\n", code);> + }> +} + +static void spl_hotkey_init(void) +{ + if (!gd || !(gd->flags & GD_FLG_HAVE_CONSOLE)) + return; + if (gd->flags & GD_FLG_DISABLE_CONSOLE) + return; + + /* Wait for the serial port to be ready to receive data. */ + mdelay(100); + Is it not ready by the time we call this function? How did you come up with 100ms? + if (serial_tstc()) + rockchip_reset_from_hotkey(serial_getc()); + else + printf("SPL Hotkey: No key pressed, continue\n"); We don't need to print on the standard path. If you reaaaaaaally want to have something, then use log_debug/debug instead so it isn't printed by default except if you build with debug logging enabled. +} +#else +static void spl_hotkey_init(void) +{ +} +#endif + void board_init_f(ulong dummy) { int ret; @@ -143,6 +184,9 @@ void board_init_f(ulong dummy) } #endif preloader_console_init(); + + if (IS_ENABLED(CONFIG_SPL_ROCKCHIP_HOTKEY)) + spl_hotkey_init(); Can we merge with the very similar logic we have for an ADC button in arch/arm/mach-rockchip/boot_mode.c instead? I believe it makes more sense to have everything capable of entering MaskROM mode in the same place, with the same logic. I could see an else if() block in rockchip_dnl_mode_check() for example. Cheers, Quentin
[-- Attachment #2.1: Type: text/html, Size: 11338 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4] arm: rockchip: spl: Add hotkey detection support.
2026-08-20 16:27 ` [PATCH v4] " Valentin Liu
@ 2026-08-20 16:36 ` Jonas Karlman
2026-08-20 16:52 ` Re:Re: " 刘垣辰
2026-08-21 14:06 ` [PATCH v5] " Valentin Liu
1 sibling, 1 reply; 13+ messages in thread
From: Jonas Karlman @ 2026-08-20 16:36 UTC (permalink / raw)
To: Valentin Liu, Quentin Schulz
Cc: Tom Rini, Ilias Apalodimas, Kever Yang, Simon Glass, Johan Jonker,
u-boot
Hi Valentin,
On 8/20/2026 6:27 PM, Valentin Liu wrote:
> Add a configurable Rockchip SPL hotkey feature that checks the
> serial console during SPL startup.
>
> Ctrl+B can be used to enter MaskROM mode and be widely used.
> Ctrl+D can be used to enter Loader mode, Ctrl+F for Fastboot mode.
> We can add more boot mode support in future.
Why the need to have special hotkey handling in SPL?
I would rather see that we extend TPL/SPL/proper with support for
reading any 'syscon-reboot-mode' reg and act according to that.
Also think there is a series on list to extend the reset command to
accept a reboot-mode.
That way we would be able to reboot from OS or U-Boot proper into
maskrom (or any other) mode, instead of trying to implement platform
specific hotkey handling.
Regards,
Jonas
>
> Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
> the serial port to be ready to receive input before checking for
> hotkeys.
>
> Signed-off-by: Valentin Liu <valentinliu@icloud.com>
> ---
> Changes for v2:
> - Simplify the dependencies of SPL_ROCKCHIP_HOTKEY.
> - Remove the conditions for the newly added includes.
> ---
> Changes for v3:
> - Add a dummy spl_hotkey_init() to avoid undefined reference errors
> when building without CONFIG_SPL_ROCKCHIP_HOTKEY.
> ---
> Changes for v4:
> - Add condition of CONFIG_ROCKCHIP_BOOT_MODE_REG != 0 to prevent
> SPL hotkey be compiled and used on unsupported platforms.
> - Add more hotkey support (Ctrl+D and Ctrl+F).
> - Remove prints on the standard path.
> - Add some code comment.
>
> arch/arm/mach-rockchip/Kconfig | 14 +++++++++
> arch/arm/mach-rockchip/spl.c | 54 ++++++++++++++++++++++++++++++++++
> 2 files changed, 68 insertions(+)
[snip]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re:Re: [PATCH v4] arm: rockchip: spl: Add hotkey detection support.
2026-08-20 16:36 ` Jonas Karlman
@ 2026-08-20 16:52 ` 刘垣辰
2026-08-20 17:46 ` Jonas Karlman
0 siblings, 1 reply; 13+ messages in thread
From: 刘垣辰 @ 2026-08-20 16:52 UTC (permalink / raw)
To: Jonas Karlman
Cc: Quentin Schulz, Tom Rini, Ilias Apalodimas, Kever Yang,
Simon Glass, Johan Jonker, u-boot
[-- Attachment #1: Type: text/plain, Size: 2508 bytes --]
Hi Jonas, I really consider your idea before writing this patch, however, this patch is a standalone function. The Rockchip U-Boot branch has the same function If you want to use "reset" command to reboot into MaskROM or any other mode, you must be able to enter the U-Boot (not SPL) or higher level OS. But sometime, we will unable to enter them (Like booting failure on out our control of firmware), we just need to rely on the physical buttons to hard (or cold) reset device. But if we haven't the physical button, there will be harder. Absolutely, we also can't rely the fallback of firmwares, so the SPL hotkey can control what mode we want to enter in SPL stage. I also like the unified "reset," but that is unrelated to the functionality provided by this patch. Best regards, Valentin Liu 2026年8月21日上午12:36,Jonas Karlman <jonas@kwiboo.se> 写道: Hi Valentin, On 8/20/2026 6:27 PM, Valentin Liu wrote: Add a configurable Rockchip SPL hotkey feature that checks the serial console during SPL startup. Ctrl+B can be used to enter MaskROM mode and be widely used. Ctrl+D can be used to enter Loader mode, Ctrl+F for Fastboot mode. We can add more boot mode support in future. Why the need to have special hotkey handling in SPL? I would rather see that we extend TPL/SPL/proper with support for reading any 'syscon-reboot-mode' reg and act according to that. Also think there is a series on list to extend the reset command to accept a reboot-mode. That way we would be able to reboot from OS or U-Boot proper into maskrom (or any other) mode, instead of trying to implement platform specific hotkey handling. Regards, Jonas Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for the serial port to be ready to receive input before checking for hotkeys. Signed-off-by: Valentin Liu <valentinliu@icloud.com> --- Changes for v2: - Simplify the dependencies of SPL_ROCKCHIP_HOTKEY. - Remove the conditions for the newly added includes. --- Changes for v3: - Add a dummy spl_hotkey_init() to avoid undefined reference errors when building without CONFIG_SPL_ROCKCHIP_HOTKEY. --- Changes for v4: - Add condition of CONFIG_ROCKCHIP_BOOT_MODE_REG != 0 to prevent SPL hotkey be compiled and used on unsupported platforms. - Add more hotkey support (Ctrl+D and Ctrl+F). - Remove prints on the standard path. - Add some code comment. arch/arm/mach-rockchip/Kconfig | 14 +++++++++ arch/arm/mach-rockchip/spl.c | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) [snip]
[-- Attachment #2.1: Type: text/html, Size: 4272 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Re:Re: [PATCH v4] arm: rockchip: spl: Add hotkey detection support.
2026-08-20 16:52 ` Re:Re: " 刘垣辰
@ 2026-08-20 17:46 ` Jonas Karlman
2026-08-20 18:31 ` 刘垣辰
0 siblings, 1 reply; 13+ messages in thread
From: Jonas Karlman @ 2026-08-20 17:46 UTC (permalink / raw)
To: 刘垣辰
Cc: Quentin Schulz, Tom Rini, Ilias Apalodimas, Kever Yang,
Simon Glass, Johan Jonker, u-boot
On 8/20/2026 6:52 PM, 刘垣辰 wrote:
> Hi Jonas,
>
> I really consider your idea before writing this patch, however, this patch is a standalone function. The Rockchip U-Boot branch has the same function
Vendor U-Boot having a feature is not always a good reason for including
it in mainline.
>
> If you want to use "reset" command to reboot into MaskROM or any other mode, you must be able to enter the U-Boot (not SPL) or higher level OS. But sometime, we will unable to enter them (Like booting failure on out our control of firmware), we just need to rely on the physical buttons to hard (or cold) reset device. But if we haven't the physical button, there will be harder.
In case SPL fails to load the payload we could implement some kind of
hang() fallback to BROM [1].
We probably would want to use a watchdog to truly recover from the event
that next stage crashes/fails/hangs. Possible something like write value
to boot-mode, start watchdog, try to load payload, re-arm watchdog in
U-Boot proper and clear out boot-mode.
Btw, there is nothing that acts on BOOT_LOADER and BOOT_FASTMODE is only
handled in U-Boot proper, so those are not really useful in SPL.
Some SoCs also clears out the boot-mode reg during reset, see [1].
[1] https://patch.msgid.link/20240202001221.531207-1-jonas@kwiboo.se/
>
> Absolutely, we also can't rely the fallback of firmwares, so the SPL hotkey can control what mode we want to enter in SPL stage.
Are you having issues with U-Boot proper crashing, or SPL fails to load
the payload, or it becoming corrupt or similar? What issues are you
facing that prompts the need for this SPL hotkey feature?
Normal boot path for Rockchip is to use a FIT and let SPL checksum
validate any payload before it gets executed. So as long as working
firmware is loaded reaching U-Boot proper is typically not an issue.
And SPL can typically fallback to load payload from a different boot
media, so recovery into a working U-Boot proper it typically easy.
At least those fallback options is something I validate for each SoC
and/or board that I contribute on.
Regards,
Jonas
>
> I also like the unified "reset," but that is unrelated to the functionality provided by this patch.
>
> Best regards,
> Valentin Liu
>
>> 2026年8月21日上午12:36,Jonas Karlman <jonas@kwiboo.se> 写道:
>>
>>
>> Hi Valentin,
>>
>> On 8/20/2026 6:27 PM, Valentin Liu wrote:
>>> Add a configurable Rockchip SPL hotkey feature that checks the
>>> serial console during SPL startup.
>>>
>>> Ctrl+B can be used to enter MaskROM mode and be widely used.
>>> Ctrl+D can be used to enter Loader mode, Ctrl+F for Fastboot mode.
>>> We can add more boot mode support in future.
>>
>> Why the need to have special hotkey handling in SPL?
>>
>> I would rather see that we extend TPL/SPL/proper with support for
>> reading any 'syscon-reboot-mode' reg and act according to that.
>>
>> Also think there is a series on list to extend the reset command to
>> accept a reboot-mode.
>>
>> That way we would be able to reboot from OS or U-Boot proper into
>> maskrom (or any other) mode, instead of trying to implement platform
>> specific hotkey handling.
>>
>> Regards,
>> Jonas
>>
>>>
>>> Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
>>> the serial port to be ready to receive input before checking for
>>> hotkeys.
>>>
>>> Signed-off-by: Valentin Liu <valentinliu@icloud.com>
>>> ---
>>> Changes for v2:
>>> - Simplify the dependencies of SPL_ROCKCHIP_HOTKEY.
>>> - Remove the conditions for the newly added includes.
>>> ---
>>> Changes for v3:
>>> - Add a dummy spl_hotkey_init() to avoid undefined reference errors
>>> when building without CONFIG_SPL_ROCKCHIP_HOTKEY.
>>> ---
>>> Changes for v4:
>>> - Add condition of CONFIG_ROCKCHIP_BOOT_MODE_REG != 0 to prevent
>>> SPL hotkey be compiled and used on unsupported platforms.
>>> - Add more hotkey support (Ctrl+D and Ctrl+F).
>>> - Remove prints on the standard path.
>>> - Add some code comment.
>>>
>>> arch/arm/mach-rockchip/Kconfig | 14 +++++++++
>>> arch/arm/mach-rockchip/spl.c | 54 ++++++++++++++++++++++++++++++++++
>>> 2 files changed, 68 insertions(+)
>>
>> [snip]
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v4] arm: rockchip: spl: Add hotkey detection support.
2026-08-20 17:46 ` Jonas Karlman
@ 2026-08-20 18:31 ` 刘垣辰
0 siblings, 0 replies; 13+ messages in thread
From: 刘垣辰 @ 2026-08-20 18:31 UTC (permalink / raw)
To: Jonas Karlman
Cc: Quentin Schulz, Tom Rini, Ilias Apalodimas, Yang Kever,
Simon Glass, Johan Jonker, u-boot
Hi Jonas,
I am not suggesting that this feature should be added to the mainline simply because Rockchip's U-Boot includes it.
Even if the firmware is loaded after verification (via hash comparison), that only confirms it hasn't suffered accidental corruption; if the firmware itself is flawed—such as issues arising during ATF/OP-TEE development— the boot process might stall before reaching U-Boot, and it also unable to trigger an automatic reset (even though the SPL successfully loaded the payload). Therefore, the SPL hotkey function is not intended to handle SPL firmware loading failures; rather, it provides a way to enter modes like MaskROM without relying on physical buttons. It is an optional feature.
As for watchdog-based status monitoring and automatic resetting, I haven't delved deeply into the watchdog mechanism, but I think this would be a separate, independent feature.
Additionally, we should consider adding SPL support for Loader mode and Fastboot mode in the future.
Best regards,
Valentin Liu
>
> 在 2026年8月21日,凌晨1:46,Jonas Karlman <jonas@kwiboo.se> 写道:
>
> On 8/20/2026 6:52 PM, 刘垣辰 wrote:
>> Hi Jonas,
>>
>> I really consider your idea before writing this patch, however, this patch is a standalone function. The Rockchip U-Boot branch has the same function
>
> Vendor U-Boot having a feature is not always a good reason for including
> it in mainline.
>
>>
>> If you want to use "reset" command to reboot into MaskROM or any other mode, you must be able to enter the U-Boot (not SPL) or higher level OS. But sometime, we will unable to enter them (Like booting failure on out our control of firmware), we just need to rely on the physical buttons to hard (or cold) reset device. But if we haven't the physical button, there will be harder.
>
> In case SPL fails to load the payload we could implement some kind of
> hang() fallback to BROM [1].
>
> We probably would want to use a watchdog to truly recover from the event
> that next stage crashes/fails/hangs. Possible something like write value
> to boot-mode, start watchdog, try to load payload, re-arm watchdog in
> U-Boot proper and clear out boot-mode.
>
> Btw, there is nothing that acts on BOOT_LOADER and BOOT_FASTMODE is only
> handled in U-Boot proper, so those are not really useful in SPL.
>
> Some SoCs also clears out the boot-mode reg during reset, see [1].
>
> [1] https://patch.msgid.link/20240202001221.531207-1-jonas@kwiboo.se/
>
>>
>> Absolutely, we also can't rely the fallback of firmwares, so the SPL hotkey can control what mode we want to enter in SPL stage.
>
> Are you having issues with U-Boot proper crashing, or SPL fails to load
> the payload, or it becoming corrupt or similar? What issues are you
> facing that prompts the need for this SPL hotkey feature?
>
> Normal boot path for Rockchip is to use a FIT and let SPL checksum
> validate any payload before it gets executed. So as long as working
> firmware is loaded reaching U-Boot proper is typically not an issue.
> And SPL can typically fallback to load payload from a different boot
> media, so recovery into a working U-Boot proper it typically easy.
>
> At least those fallback options is something I validate for each SoC
> and/or board that I contribute on.
>
> Regards,
> Jonas
>
>>
>> I also like the unified "reset," but that is unrelated to the functionality provided by this patch.
>>
>> Best regards,
>> Valentin Liu
>>
>>> 2026年8月21日上午12:36,Jonas Karlman <jonas@kwiboo.se> 写道:
>>>
>>>
>>> Hi Valentin,
>>>
>>>> On 8/20/2026 6:27 PM, Valentin Liu wrote:
>>>>> Add a configurable Rockchip SPL hotkey feature that checks the
>>>>> serial console during SPL startup.
>>>>>
>>>>> Ctrl+B can be used to enter MaskROM mode and be widely used.
>>>>> Ctrl+D can be used to enter Loader mode, Ctrl+F for Fastboot mode.
>>>>> We can add more boot mode support in future.
>>>
>>> Why the need to have special hotkey handling in SPL?
>>>
>>> I would rather see that we extend TPL/SPL/proper with support for
>>> reading any 'syscon-reboot-mode' reg and act according to that.
>>>
>>> Also think there is a series on list to extend the reset command to
>>> accept a reboot-mode.
>>>
>>> That way we would be able to reboot from OS or U-Boot proper into
>>> maskrom (or any other) mode, instead of trying to implement platform
>>> specific hotkey handling.
>>>
>>> Regards,
>>> Jonas
>>>
>>>>
>>>> Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
>>>> the serial port to be ready to receive input before checking for
>>>> hotkeys.
>>>>
>>>> Signed-off-by: Valentin Liu <valentinliu@icloud.com>
>>>> ---
>>>> Changes for v2:
>>>> - Simplify the dependencies of SPL_ROCKCHIP_HOTKEY.
>>>> - Remove the conditions for the newly added includes.
>>>> ---
>>>> Changes for v3:
>>>> - Add a dummy spl_hotkey_init() to avoid undefined reference errors
>>>> when building without CONFIG_SPL_ROCKCHIP_HOTKEY.
>>>> ---
>>>> Changes for v4:
>>>> - Add condition of CONFIG_ROCKCHIP_BOOT_MODE_REG != 0 to prevent
>>>> SPL hotkey be compiled and used on unsupported platforms.
>>>> - Add more hotkey support (Ctrl+D and Ctrl+F).
>>>> - Remove prints on the standard path.
>>>> - Add some code comment.
>>>>
>>>> arch/arm/mach-rockchip/Kconfig | 14 +++++++++
>>>> arch/arm/mach-rockchip/spl.c | 54 ++++++++++++++++++++++++++++++++++
>>>> 2 files changed, 68 insertions(+)
>>>
>>> [snip]
>>
>>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v5] arm: rockchip: spl: Add hotkey detection support.
2026-08-20 16:27 ` [PATCH v4] " Valentin Liu
2026-08-20 16:36 ` Jonas Karlman
@ 2026-08-21 14:06 ` Valentin Liu
1 sibling, 0 replies; 13+ messages in thread
From: Valentin Liu @ 2026-08-21 14:06 UTC (permalink / raw)
To: u-boot
Cc: Tom Rini, Ilias Apalodimas, Quentin Schulz, Kever Yang,
Simon Glass, Johan Jonker, Jonas Karlman, Valentin Liu
Add a configurable Rockchip SPL hotkey feature that checks the
serial console during SPL startup.
Ctrl+B can be used to enter MaskROM mode and be widely used.
Ctrl+D can be used to enter Loader mode, Ctrl+F for Fastboot mode.
We can add more boot mode support in future.
Add CONFIG_SPL_ROCKCHIP_HOTKEY to enable the feature and wait for
the serial port to be ready to receive input before checking for
hotkeys.
Signed-off-by: Valentin Liu <valentinliu@icloud.com>
---
Changes for v2:
- Simplify the dependencies of SPL_ROCKCHIP_HOTKEY.
- Remove the conditions for the newly added includes.
---
Changes for v3:
- Add a dummy spl_hotkey_init() to avoid undefined reference errors
when building without CONFIG_SPL_ROCKCHIP_HOTKEY.
---
Changes for v4:
- Add condition of CONFIG_ROCKCHIP_BOOT_MODE_REG != 0 to prevent
SPL hotkey be compiled and used on unsupported platforms.
- Add more hotkey support (Ctrl+D and Ctrl+F).
- Remove prints on the standard path.
- Add some code comment.
---
Changes for v5:
- Fixup the CONFIG_IS_ENABLED() call.
arch/arm/mach-rockchip/Kconfig | 14 +++++++++
arch/arm/mach-rockchip/spl.c | 54 ++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 1a2e7847c9e..0e485e8caf6 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -743,6 +743,20 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
config SPL_MMC
default y if !SPL_ROCKCHIP_BACK_TO_BROM
+config SPL_ROCKCHIP_HOTKEY
+ bool "SPL hotkey support"
+ depends on SPL_DM_RESET && SPL_SERIAL
+ help
+ Enable hotkey detection during SPL booting stage.
+
+ When enabled, SPL checks the serial console for a control
+ character and can execute Rockchip-specific hotkey actions,
+ such as entering MaskROM mode with Ctrl+B, entering Loader
+ mode with Ctrl+D, entering Fastboot mode with Ctrl+F.
+
+ The hotkey is checked after the SPL console has been
+ initialized.
+
config ROCKCHIP_SPI_IMAGE
bool "Build a SPI image for rockchip"
help
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
index e989c148079..b61ccc30a22 100644
--- a/arch/arm/mach-rockchip/spl.c
+++ b/arch/arm/mach-rockchip/spl.c
@@ -13,11 +13,14 @@
#include <log.h>
#include <mapmem.h>
#include <ram.h>
+#include <serial.h>
#include <spl.h>
+#include <asm/arch-rockchip/boot_mode.h>
#include <asm/arch-rockchip/bootrom.h>
#include <asm/arch-rockchip/timer.h>
#include <asm/global_data.h>
#include <asm/io.h>
+#include <linux/delay.h>
#include <linux/bitops.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -107,6 +110,54 @@ __weak int arch_cpu_init(void)
return 0;
}
+#if CONFIG_IS_ENABLED(ROCKCHIP_HOTKEY) && (CONFIG_ROCKCHIP_BOOT_MODE_REG != 0)
+static void rockchip_reset_from_hotkey(const int code)
+{
+ switch (code) {
+ case 0x02: /* Ctrl+B */
+ printf("Ctrl+B pressed, entering download mode...\n");
+ writel(BOOT_BROM_DOWNLOAD, CONFIG_ROCKCHIP_BOOT_MODE_REG);
+ do_reset(NULL, 0, 0, NULL);
+ /* NOTREACHED */
+ case 0x04: /* Ctrl+D */
+ printf("Ctrl+D pressed, entering loader mode...\n");
+ writel(BOOT_LOADER, CONFIG_ROCKCHIP_BOOT_MODE_REG);
+ do_reset(NULL, 0, 0, NULL);
+ /* NOTREACHED */
+ case 0x06: /* Ctrl+F */
+ printf("Ctrl+F pressed, entering fastboot mode...\n");
+ writel(BOOT_FASTBOOT, CONFIG_ROCKCHIP_BOOT_MODE_REG);
+ do_reset(NULL, 0, 0, NULL);
+ /* NOTREACHED */
+ default:
+ if (code <= 0x1a) /* 'z' */
+ log_debug("SPL Hotkey: Ctrl+%c\n", code + 'A' - 1);
+ else
+ log_debug("SPL Hotkey: Unknown code: 0x%x, ignore\n", code);
+ }
+}
+
+static void spl_hotkey_init(void)
+{
+ if (!gd || !(gd->flags & GD_FLG_HAVE_CONSOLE))
+ return;
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return;
+
+ /* Wait for the serial port to be ready to receive data. */
+ mdelay(100);
+
+ if (serial_tstc())
+ rockchip_reset_from_hotkey(serial_getc());
+ else
+ log_debug("SPL Hotkey: No key pressed, continue\n");
+}
+#else
+static void spl_hotkey_init(void)
+{
+}
+#endif
+
void board_init_f(ulong dummy)
{
int ret;
@@ -143,6 +194,9 @@ void board_init_f(ulong dummy)
}
#endif
preloader_console_init();
+
+ if (CONFIG_IS_ENABLED(ROCKCHIP_HOTKEY))
+ spl_hotkey_init();
}
void spl_board_prepare_for_boot(void)
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-08-21 14:13 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-15 17:08 [PATCH] arm: rockchip: spl: Add hotkey detection support Valentin Liu
2026-08-15 17:59 ` Tom Rini
2026-08-15 18:23 ` [PATCH v2] " Valentin Liu
2026-08-15 18:34 ` Valentin Liu
2026-08-18 16:55 ` [PATCH v3] " Valentin Liu
2026-08-20 15:37 ` Quentin Schulz
2026-08-20 16:29 ` Re:Re: " 刘垣辰
2026-08-20 16:27 ` [PATCH v4] " Valentin Liu
2026-08-20 16:36 ` Jonas Karlman
2026-08-20 16:52 ` Re:Re: " 刘垣辰
2026-08-20 17:46 ` Jonas Karlman
2026-08-20 18:31 ` 刘垣辰
2026-08-21 14:06 ` [PATCH v5] " Valentin Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox