From 71499bd66ea1eb8220bcf7983c5bd97506e3f9c0 Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Fri, 4 Sep 2026 22:09:18 +0800 Subject: [PATCH] boards/rp2040: support reboot bootloader via reset_usb_boot() Add reset_usb_boot ROM function typedef and wire it into board_reset() so that 'nsh> reboot bootloader' (BOARDIOC_SOFTRESETCAUSE_ENTER_BOOTLOADER) on RP2040 boards enters BOOTSEL USB mass-storage mode directly, matching the behavior already available on rp23xx boards. All other status values keep the existing up_systemreset() behavior. This affects all boards under boards/arm/rp2040/common (pico, pico-w, feather-rp2040, xiao-rp2040, w5500-evb-pico, etc.) since the change is in the shared board_reset() implementation. Assisted-by: GitHubCopilot:claude-4.6-opus Signed-off-by: wangjianyu3 --- arch/arm/src/rp2040/rp2040_rom.h | 2 ++ boards/arm/rp2040/common/src/rp2040_reset.c | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/rp2040/rp2040_rom.h b/arch/arm/src/rp2040/rp2040_rom.h index 40eacb6ff22..8e89ac417d4 100644 --- a/arch/arm/src/rp2040/rp2040_rom.h +++ b/arch/arm/src/rp2040/rp2040_rom.h @@ -63,3 +63,5 @@ ****************************************************************************/ typedef void *(*rom_table_lookup_fn)(uint16_t *table, uint32_t code); +typedef void (*rom_reset_usb_boot_fn)(uint32_t usb_activity_gpio_pin_mask, + uint32_t disable_interface_mask); diff --git a/boards/arm/rp2040/common/src/rp2040_reset.c b/boards/arm/rp2040/common/src/rp2040_reset.c index e59d2d65d90..97f382be2e0 100644 --- a/boards/arm/rp2040/common/src/rp2040_reset.c +++ b/boards/arm/rp2040/common/src/rp2040_reset.c @@ -28,6 +28,10 @@ #include #include +#include + +#include "rp2040_rom.h" + #ifdef CONFIG_BOARDCTL_RESET /**************************************************************************** @@ -56,7 +60,18 @@ int board_reset(int status) { - up_systemreset(); + if (status == BOARDIOC_SOFTRESETCAUSE_ENTER_BOOTLOADER) + { + rom_reset_usb_boot_fn reset_usb_boot; + + reset_usb_boot = (rom_reset_usb_boot_fn)ROM_LOOKUP(ROM_RESET_USB_BOOT); + reset_usb_boot(0, 0); + } + else + { + up_systemreset(); + } + return 0; }