Skip to contentSkip to conversation

arm: rockchip: spl: Add hotkey detection support.

PATCH Superseded Valentin Liu 4 participants 13 messages Aug 15 – Aug 21

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: rockchip: spl: Add hotkey detection support.

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.

---
 arch/arm/mach-rockchip/Kconfig | 15 ++++++++++++
 arch/arm/mach-rockchip/spl.c   | 42 ++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)
arch/arm/mach-rockchip/Kconfig +15 -0
index 1a2e7847c9e..a5de483bbb9 100644
@@ -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
arch/arm/mach-rockchip/spl.c +42 -0

60 lines not on this page · raw message

Signature · 1 line
2.53.0
#1 lore raw
Quoted 21 lines · 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.

---
 arch/arm/mach-rockchip/Kconfig | 15 ++++++++++++
 arch/arm/mach-rockchip/spl.c    | 42 ++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)
arch/arm/mach-rockchip/Kconfig +0 -0
index 1a2e7847c9e..a5de483bbb9 100644

arch/arm/mach-rockchip/Kconfig config TPL_ROCKCHIP_EARLYRETURN_TO_BROM · line 750

Quoted 8 lines
arch/arm/mach-rockchip/Kconfig +5 -0
@@ -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]

arch/arm/mach-rockchip/spl.c line 26

Quoted 13 lines
arch/arm/mach-rockchip/spl.c +5 -0
index e989c148079..46140e5af3c 100644
@@ -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.

Signature · 1 line
Tom
#2 lore raw

PATCH v2 1/1 arm: rockchip: spl: Add hotkey detection support.

In reply to 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.

---
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(+)
arch/arm/mach-rockchip/Kconfig +13 -0
index 1a2e7847c9e..f2d2b5520ef 100644
@@ -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
arch/arm/mach-rockchip/spl.c +40 -0
index e989c148079..0422415b06e 100644
@@ -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)
Signature · 1 line
2.53.0
#3 lore raw

PATCH v3 1/1 arm: rockchip: spl: Add hotkey detection support.

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.

---
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(+)
arch/arm/mach-rockchip/Kconfig +13 -0
index 1a2e7847c9e..f2d2b5520ef 100644
@@ -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
arch/arm/mach-rockchip/spl.c +44 -0

67 lines not on this page · raw message

Signature · 1 line
2.53.0
#4 lore raw

Hi Valentin,

Quoted 29 lines · 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.

---
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(+)
arch/arm/mach-rockchip/Kconfig +0 -0
index 1a2e7847c9e..f2d2b5520ef 100644

arch/arm/mach-rockchip/Kconfig config TPL_ROCKCHIP_EARLYRETURN_TO_BROM · line 747

Quoted 5 lines
arch/arm/mach-rockchip/Kconfig +2 -0
@@ -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?

arch/arm/mach-rockchip/Kconfig config TPL_ROCKCHIP_EARLYRETURN_TO_BROM · line 758

Quoted 11 lines
arch/arm/mach-rockchip/Kconfig +11 -0
+	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. """

Quoted 23 lines
arch/arm/mach-rockchip/Kconfig +0 -0
  config ROCKCHIP_SPI_IMAGE
  	bool "Build a SPI image for rockchip"
  	help
arch/arm/mach-rockchip/spl.c +3 -0
index e989c148079..0bcfb42c306 100644
@@ -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;

arch/arm/mach-rockchip/spl.c __weak int arch_cpu_init(void) · line 113

Quoted 4 lines
arch/arm/mach-rockchip/spl.c +1 -0
@@ -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.

arch/arm/mach-rockchip/spl.c __weak int arch_cpu_init(void) · line 117

Quoted 4 lines
arch/arm/mach-rockchip/spl.c +4 -0
+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 */

arch/arm/mach-rockchip/spl.c __weak int arch_cpu_init(void) · line 118

Quoted 1 line
arch/arm/mach-rockchip/spl.c +1 -0
+		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.

arch/arm/mach-rockchip/spl.c __weak int arch_cpu_init(void) · line 119

Quoted 1 line
arch/arm/mach-rockchip/spl.c +1 -0
+		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).

Quoted 8 lines
arch/arm/mach-rockchip/spl.c +8 -0
+		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);> +	}> +}
+

arch/arm/mach-rockchip/spl.c __weak int arch_cpu_init(void) · line 139

Quoted 10 lines
arch/arm/mach-rockchip/spl.c +10 -0
+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?

arch/arm/mach-rockchip/spl.c __weak int arch_cpu_init(void) · line 143

Quoted 4 lines
arch/arm/mach-rockchip/spl.c +4 -0
+	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.

Quoted 11 lines
arch/arm/mach-rockchip/spl.c +7 -0
+}
+#else
+static void spl_hotkey_init(void)
+{
+}
+#endif
+
  void board_init_f(ulong dummy)
  {
  	int ret;

arch/arm/mach-rockchip/spl.c void board_init_f(ulong dummy) · line 189

Quoted 6 lines
arch/arm/mach-rockchip/spl.c +3 -0
@@ -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

author
#5 lore raw

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 <[email protected]> 写道: 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 <[email protected]> --- 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

#6 lore raw

PATCH v4 1/1 arm: rockchip: spl: Add hotkey detection support.

In reply to 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.

---
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(+)
arch/arm/mach-rockchip/Kconfig +14 -0
index 1a2e7847c9e..0e485e8caf6 100644
@@ -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
arch/arm/mach-rockchip/spl.c +54 -0

77 lines not on this page · raw message

Signature · 1 line
2.53.0
#7 lore raw

Hi Valentin,

Quoted 6 lines · 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.

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

Quoted 25 lines

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.

---
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]

author
#8 lore raw

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 <[email protected]> 写道: 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 <[email protected]> --- 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]

#9 lore raw
Quoted 3 lines · 刘垣辰

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.

Quoted 2 lines

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/[email protected]/

Quoted 2 lines

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

Quoted 63 lines

I also like the unified "reset," but that is unrelated to the functionality provided by this patch.

Best regards,
Valentin Liu

Quoted 55 lines

2026年8月21日上午12:36,Jonas Karlman <[email protected]> 写道:

Hi Valentin,

Quoted 6 lines · 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.

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

Quoted 25 lines

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.

---
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]

author
#10 lore raw

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

Quoted 112 lines · 在 2026年8月21日,凌晨1:46,Jonas Karlman <[email protected]> 写道:
Quoted 3 lines · 刘垣辰

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.

Quoted 2 lines

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/[email protected]/

Quoted 2 lines

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

Quoted 63 lines

I also like the unified "reset," but that is unrelated to the functionality provided by this patch.

Best regards,
Valentin Liu

Quoted 55 lines

2026年8月21日上午12:36,Jonas Karlman <[email protected]> 写道:

Hi Valentin,

Quoted 7 lines · Valentin Liu
Quoted 6 lines

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

Quoted 25 lines

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.

---
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]

#11 lore raw

PATCH v5 1/1 arm: rockchip: spl: Add hotkey detection support.

In reply to 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.

---
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(+)
arch/arm/mach-rockchip/Kconfig +14 -0
index 1a2e7847c9e..0e485e8caf6 100644
@@ -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
arch/arm/mach-rockchip/spl.c +54 -0

77 lines not on this page · raw message

Signature · 1 line
2.53.0
#12 lore raw

PATCH v2 1/1 arm: rockchip: spl: Add hotkey detection support.

In reply to 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.

---
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(+)
arch/arm/mach-rockchip/Kconfig +13 -0
index 1a2e7847c9e..f2d2b5520ef 100644
@@ -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
arch/arm/mach-rockchip/spl.c +40 -0
index e989c148079..0422415b06e 100644
@@ -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)
Signature · 1 line
2.53.0