From 6cb45fc1b952657aff82a1b9ba9e5b434b8d0abd Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Sun, 11 Oct 2026 18:14:38 -0700 Subject: [PATCH 1/3] zephyr-cp: name the Pico W and Pico 2 W boards Zephyr names these boards after the base Pico and Pico 2, because the W is a board variant and its board.yml full_name has no variant. The banner, USB product string and board_info then lose the W. Set NAME in circuitpython.toml, as the Adafruit zephyr boards do, to match the names the raspberrypi port uses. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../raspberrypi/rpi_pico2_w_zephyr/autogen_board_info.toml | 2 +- .../boards/raspberrypi/rpi_pico2_w_zephyr/circuitpython.toml | 1 + .../raspberrypi/rpi_pico_w_zephyr/autogen_board_info.toml | 2 +- .../boards/raspberrypi/rpi_pico_w_zephyr/circuitpython.toml | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ports/zephyr-cp/boards/raspberrypi/rpi_pico2_w_zephyr/autogen_board_info.toml b/ports/zephyr-cp/boards/raspberrypi/rpi_pico2_w_zephyr/autogen_board_info.toml index e55f5dc393b..207876cfdb8 100644 --- a/ports/zephyr-cp/boards/raspberrypi/rpi_pico2_w_zephyr/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/raspberrypi/rpi_pico2_w_zephyr/autogen_board_info.toml @@ -1,5 +1,5 @@ # This file is autogenerated when a board is built. Do not edit. Do commit it to git. Other scripts use its info. -name = "Raspberry Pi Foundation Raspberry Pi Pico 2" +name = "Raspberry Pi Foundation Raspberry Pi Pico 2 W" [modules] __future__ = true diff --git a/ports/zephyr-cp/boards/raspberrypi/rpi_pico2_w_zephyr/circuitpython.toml b/ports/zephyr-cp/boards/raspberrypi/rpi_pico2_w_zephyr/circuitpython.toml index bd0e3ca07ca..2441882956e 100644 --- a/ports/zephyr-cp/boards/raspberrypi/rpi_pico2_w_zephyr/circuitpython.toml +++ b/ports/zephyr-cp/boards/raspberrypi/rpi_pico2_w_zephyr/circuitpython.toml @@ -1,5 +1,6 @@ CIRCUITPY_BUILD_EXTENSIONS = ["hex", "uf2"] BLOBS=["hal_infineon"] +NAME="Raspberry Pi Pico 2 W" # Non-Zephyr build of the same board; nvm and CIRCUITPY must sit where it puts them. counterpart = "raspberrypi/raspberry_pi_pico2_w" diff --git a/ports/zephyr-cp/boards/raspberrypi/rpi_pico_w_zephyr/autogen_board_info.toml b/ports/zephyr-cp/boards/raspberrypi/rpi_pico_w_zephyr/autogen_board_info.toml index 2290a8243d9..0d27e909592 100644 --- a/ports/zephyr-cp/boards/raspberrypi/rpi_pico_w_zephyr/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/raspberrypi/rpi_pico_w_zephyr/autogen_board_info.toml @@ -1,5 +1,5 @@ # This file is autogenerated when a board is built. Do not edit. Do commit it to git. Other scripts use its info. -name = "Raspberry Pi Foundation Raspberry Pi Pico" +name = "Raspberry Pi Foundation Raspberry Pi Pico W" [modules] __future__ = true diff --git a/ports/zephyr-cp/boards/raspberrypi/rpi_pico_w_zephyr/circuitpython.toml b/ports/zephyr-cp/boards/raspberrypi/rpi_pico_w_zephyr/circuitpython.toml index 4b5d2df0800..73c240baeb5 100644 --- a/ports/zephyr-cp/boards/raspberrypi/rpi_pico_w_zephyr/circuitpython.toml +++ b/ports/zephyr-cp/boards/raspberrypi/rpi_pico_w_zephyr/circuitpython.toml @@ -1,5 +1,6 @@ CIRCUITPY_BUILD_EXTENSIONS = ["hex", "uf2"] BLOBS=["hal_infineon"] +NAME="Raspberry Pi Pico W" # Non-Zephyr build of the same board; nvm and CIRCUITPY must sit where it puts them. counterpart = "raspberrypi/raspberry_pi_pico_w" From ad2ea578852284a9442da4253bfb3c54c02a8243 Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Sun, 11 Oct 2026 19:43:23 -0700 Subject: [PATCH 2/3] zephyr-cp: reset RP2 boards through the watchdog On RP2040, microcontroller.reset() restarted the CPU but the board never left the USB bus: the host kept the same device number and only issued a bus reset to recover. sys_reboot() ends in the Arm SYSRESETREQ, which on RP2 does not reset the USB controller. Reset the chip through the watchdog with every power-on state machine domain but the oscillators selected. This matches pico-sdk's watchdog_reboot(0, 0, 0), which the raspberrypi port's reset_cpu() uses, except that it leaves the debug-pause bits alone; those only pause a counting watchdog, not an immediate trigger. scratch[4] is cleared so the boot ROM takes the normal flash boot. The guard covers RP2350 too, using the same registers; only RP2040 was tested on hardware. Co-Authored-By: Claude Opus 5.5 (1M context) --- ports/zephyr-cp/supervisor/port.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ports/zephyr-cp/supervisor/port.c b/ports/zephyr-cp/supervisor/port.c index bcf4996772e..51dce2df063 100644 --- a/ports/zephyr-cp/supervisor/port.c +++ b/ports/zephyr-cp/supervisor/port.c @@ -47,6 +47,11 @@ #include #endif +#if defined(CONFIG_SOC_FAMILY_RPI_PICO) +#include +#include +#endif + #if defined(CONFIG_TRACING_PERFETTO) && defined(CONFIG_BOARD_NATIVE_SIM) #include "perfetto_encoder.h" #include @@ -254,6 +259,17 @@ void reset_cpu(void) { cp_retained_save(); #endif + #if defined(CONFIG_SOC_FAMILY_RPI_PICO) + // On RP2 the Arm system reset leaves the USB controller running, so the + // host never sees the board go away. Reset the whole chip through the + // watchdog instead, as pico-sdk's watchdog_reboot() does. Zephyr's + // hal_rpi_pico does not build watchdog.c, so write the registers here. + hw_clear_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS); + watchdog_hw->scratch[4] = 0; + hw_set_bits(&psm_hw->wdsel, PSM_WDSEL_BITS & ~(PSM_WDSEL_ROSC_BITS | PSM_WDSEL_XOSC_BITS)); + hw_set_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_TRIGGER_BITS); + #endif + // Try a warm reboot first. It won't return if it works but isn't always // implemented. sys_reboot(SYS_REBOOT_WARM); From 9f6eb8b24549201d482c1b8a3db8bd1f7582c90f Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Sun, 11 Oct 2026 19:43:48 -0700 Subject: [PATCH 3/3] zephyr-cp: make cpu.uid 8 bytes on RP2 The RP2 hwinfo driver returns an 8-byte ID: the flash unique ID, or the chip ID on RP2350 with CONFIG_HWINFO_RPI_PICO_CHIP_ID. Every SoC but nRF got the 32-byte placeholder length, so cpu.uid on a Pico W was the ID followed by 24 zero bytes. Use 8 bytes, matching the raspberrypi port's cpu.uid on the same boards. Co-Authored-By: Claude Opus 5.5 (1M context) --- ports/zephyr-cp/common-hal/microcontroller/Processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/zephyr-cp/common-hal/microcontroller/Processor.h b/ports/zephyr-cp/common-hal/microcontroller/Processor.h index f47f582a1ce..890bca2a2e8 100644 --- a/ports/zephyr-cp/common-hal/microcontroller/Processor.h +++ b/ports/zephyr-cp/common-hal/microcontroller/Processor.h @@ -6,7 +6,7 @@ #pragma once -#if CONFIG_HWINFO_NRF +#if CONFIG_HWINFO_NRF || CONFIG_HWINFO_RPI_PICO #define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 8 #else // Extra long and the remainder will be left empty. Will print out the actual length.