From 11092dba5f091e04adf7a04a83b2362819754ec1 Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Tue, 17 Nov 2026 07:05:24 -0800 Subject: [PATCH 1/4] raspberrypi: power up the CYW43 before printing the MAC in boot_out.txt cyw43_state.mac is only filled in when the CYW43 chip powers up, and cyw43_arch_init() doesn't power it up. port_boot_info() printed whatever was there, so the MAC was right only when something else had already touched the chip: a status LED on CYW0, the web workflow starting WiFi, or, until finalizer cleanup removed it, reset_all_pins() in main(). A board with a NeoPixel status LED and no WiFi credentials in settings.toml has none of those, so boot_out.txt showed MAC:00:00:00:00:00:00. Read CYW43 GPIO 2 (VBUS sense) first, which powers the chip up and changes nothing. Fixes #10777. Co-Authored-By: Claude Opus 5.5 --- ports/raspberrypi/supervisor/port.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/raspberrypi/supervisor/port.c b/ports/raspberrypi/supervisor/port.c index 5cceeafc736..6758dd9d967 100644 --- a/ports/raspberrypi/supervisor/port.c +++ b/ports/raspberrypi/supervisor/port.c @@ -698,6 +698,12 @@ void port_task_yield(void) { void port_boot_info(void) { #if CIRCUITPY_CYW43 + // cyw43_state.mac is filled in when the chip powers up, which + // cyw43_arch_init() doesn't do. Any CYW43 GPIO access powers it up, and + // reading VBUS sense changes nothing. + if (cyw_ever_init) { + cyw43_arch_gpio_get(pin_CYW2.number); + } mp_printf(&mp_plat_print, "MAC"); for (int i = 0; i < 6; i++) { mp_printf(&mp_plat_print, ":%02X", cyw43_state.mac[i]); From 35ffd233401e48eb2a04e002ddbd8c5447aa9c80 Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Tue, 17 Nov 2026 16:45:49 -0800 Subject: [PATCH 2/4] raspberrypi: shorten the CYW43 power-up comment Co-Authored-By: Claude Opus 5.5 --- ports/raspberrypi/supervisor/port.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ports/raspberrypi/supervisor/port.c b/ports/raspberrypi/supervisor/port.c index 6758dd9d967..b6da410d002 100644 --- a/ports/raspberrypi/supervisor/port.c +++ b/ports/raspberrypi/supervisor/port.c @@ -698,9 +698,7 @@ void port_task_yield(void) { void port_boot_info(void) { #if CIRCUITPY_CYW43 - // cyw43_state.mac is filled in when the chip powers up, which - // cyw43_arch_init() doesn't do. Any CYW43 GPIO access powers it up, and - // reading VBUS sense changes nothing. + // Access CYW43 GPIO to power it up before reading the MAC if (cyw_ever_init) { cyw43_arch_gpio_get(pin_CYW2.number); } From 1e265885b5f3cdcf1c907e7c9f1f3e53d710f25d Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Tue, 17 Nov 2026 16:49:09 -0800 Subject: [PATCH 3/4] raspberrypi: rename cyw_ever_init to cyw_init_succeeded The flag records that cyw43_arch_init() succeeded, which sets up the driver but leaves the chip off. The old name read as if the chip was already on. Co-Authored-By: Claude Opus 5.5 --- ports/raspberrypi/common-hal/microcontroller/Pin.c | 4 ++-- ports/raspberrypi/common-hal/microcontroller/Pin.h | 2 +- ports/raspberrypi/supervisor/port.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ports/raspberrypi/common-hal/microcontroller/Pin.c b/ports/raspberrypi/common-hal/microcontroller/Pin.c index 257e1ee08ff..bf3367e3837 100644 --- a/ports/raspberrypi/common-hal/microcontroller/Pin.c +++ b/ports/raspberrypi/common-hal/microcontroller/Pin.c @@ -17,7 +17,7 @@ static uint64_t gpio_bank0_pin_claimed; #include "bindings/cyw43/__init__.h" #include "pico/cyw43_arch.h" -bool cyw_ever_init; +bool cyw_init_succeeded; static uint32_t cyw_pin_claimed; void reset_pin_number_cyw(uint8_t pin_no) { @@ -25,7 +25,7 @@ void reset_pin_number_cyw(uint8_t pin_no) { // Drive the LED (GPIO 0) and SMPS_MODE (GPIO 1) low. Don't touch // VBUS_SENSE (GPIO 2): writing it would switch it to an output for good. - if (cyw_ever_init && pin_no <= 1) { + if (cyw_init_succeeded && pin_no <= 1) { cyw43_arch_gpio_put(pin_no, false); } } diff --git a/ports/raspberrypi/common-hal/microcontroller/Pin.h b/ports/raspberrypi/common-hal/microcontroller/Pin.h index fe2191e8f25..3ecb22eddd8 100644 --- a/ports/raspberrypi/common-hal/microcontroller/Pin.h +++ b/ports/raspberrypi/common-hal/microcontroller/Pin.h @@ -29,6 +29,6 @@ bool pin_number_is_free(uint8_t pin_number); uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t *pin); #if CIRCUITPY_CYW43 -extern bool cyw_ever_init; +extern bool cyw_init_succeeded; void reset_pin_number_cyw(uint8_t pin_number); #endif diff --git a/ports/raspberrypi/supervisor/port.c b/ports/raspberrypi/supervisor/port.c index b6da410d002..9140656d858 100644 --- a/ports/raspberrypi/supervisor/port.c +++ b/ports/raspberrypi/supervisor/port.c @@ -475,7 +475,7 @@ safe_mode_t port_init(void) { if (cyw43_arch_init_with_country(PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE)) { serial_write("WiFi init failed\n"); } else { - cyw_ever_init = true; + cyw_init_succeeded = true; } #endif if (board_requests_safe_mode()) { @@ -699,7 +699,7 @@ void port_task_yield(void) { void port_boot_info(void) { #if CIRCUITPY_CYW43 // Access CYW43 GPIO to power it up before reading the MAC - if (cyw_ever_init) { + if (cyw_init_succeeded) { cyw43_arch_gpio_get(pin_CYW2.number); } mp_printf(&mp_plat_print, "MAC"); From dcf2f66b472789f0d7c8726dd692d52ed5ff2727 Mon Sep 17 00:00:00 2001 From: Mikey Sklar Date: Wed, 18 Nov 2026 09:59:40 -0800 Subject: [PATCH 4/4] raspberrypi: rename cyw_init_succeeded to cyw_driver_ready Co-Authored-By: Claude Opus 5.5 --- ports/raspberrypi/common-hal/microcontroller/Pin.c | 4 ++-- ports/raspberrypi/common-hal/microcontroller/Pin.h | 4 +++- ports/raspberrypi/supervisor/port.c | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ports/raspberrypi/common-hal/microcontroller/Pin.c b/ports/raspberrypi/common-hal/microcontroller/Pin.c index bf3367e3837..60245ff6b5f 100644 --- a/ports/raspberrypi/common-hal/microcontroller/Pin.c +++ b/ports/raspberrypi/common-hal/microcontroller/Pin.c @@ -17,7 +17,7 @@ static uint64_t gpio_bank0_pin_claimed; #include "bindings/cyw43/__init__.h" #include "pico/cyw43_arch.h" -bool cyw_init_succeeded; +bool cyw_driver_ready; static uint32_t cyw_pin_claimed; void reset_pin_number_cyw(uint8_t pin_no) { @@ -25,7 +25,7 @@ void reset_pin_number_cyw(uint8_t pin_no) { // Drive the LED (GPIO 0) and SMPS_MODE (GPIO 1) low. Don't touch // VBUS_SENSE (GPIO 2): writing it would switch it to an output for good. - if (cyw_init_succeeded && pin_no <= 1) { + if (cyw_driver_ready && pin_no <= 1) { cyw43_arch_gpio_put(pin_no, false); } } diff --git a/ports/raspberrypi/common-hal/microcontroller/Pin.h b/ports/raspberrypi/common-hal/microcontroller/Pin.h index 3ecb22eddd8..fd6f77c6ced 100644 --- a/ports/raspberrypi/common-hal/microcontroller/Pin.h +++ b/ports/raspberrypi/common-hal/microcontroller/Pin.h @@ -29,6 +29,8 @@ bool pin_number_is_free(uint8_t pin_number); uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t *pin); #if CIRCUITPY_CYW43 -extern bool cyw_init_succeeded; +// True once cyw43_arch_init() succeeded in port_init(). The driver is ready, +// but the chip may still be powered down until something accesses it. +extern bool cyw_driver_ready; void reset_pin_number_cyw(uint8_t pin_number); #endif diff --git a/ports/raspberrypi/supervisor/port.c b/ports/raspberrypi/supervisor/port.c index 9140656d858..7e6a58f9ac2 100644 --- a/ports/raspberrypi/supervisor/port.c +++ b/ports/raspberrypi/supervisor/port.c @@ -475,7 +475,7 @@ safe_mode_t port_init(void) { if (cyw43_arch_init_with_country(PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE)) { serial_write("WiFi init failed\n"); } else { - cyw_init_succeeded = true; + cyw_driver_ready = true; } #endif if (board_requests_safe_mode()) { @@ -699,7 +699,7 @@ void port_task_yield(void) { void port_boot_info(void) { #if CIRCUITPY_CYW43 // Access CYW43 GPIO to power it up before reading the MAC - if (cyw_init_succeeded) { + if (cyw_driver_ready) { cyw43_arch_gpio_get(pin_CYW2.number); } mp_printf(&mp_plat_print, "MAC");