From 8174ab064002edadaaffa50607e7bcbb6802cf82 Mon Sep 17 00:00:00 2001 From: subsonicpulse Date: Thu, 7 Nov 2024 12:16:42 +0100 Subject: [PATCH 1/2] Fix Usage of Bootsel Button for Pico 2 see code from https://github.com/raspberrypi/pico-examples/blob/master/picoboard/button/button.c --- hw/bsp/rp2040/family.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c index ccc1e1f706..47d729ea39 100644 --- a/hw/bsp/rp2040/family.c +++ b/hw/bsp/rp2040/family.c @@ -79,7 +79,13 @@ bool __no_inline_not_in_flash_func(get_bootsel_button)(void) { // The HI GPIO registers in SIO can observe and control the 6 QSPI pins. // Note the button pulls the pin *low* when pressed. - bool button_state = (sio_hw->gpio_hi_in & (1u << CS_PIN_INDEX)); + + #if PICO_RP2040 + #define CS_BIT (1u << 1) + #else + #define CS_BIT SIO_GPIO_HI_IN_QSPI_CSN_BITS + #endif + bool button_state = (sio_hw->gpio_hi_in & CS_BIT); // Need to restore the state of chip select, else we are going to have a // bad time when we return to code in flash! From 3a89442dbaf7f56b0be06c324d4bc9db02fbaf06 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 11 Nov 2024 21:55:30 +0700 Subject: [PATCH 2/2] use arm arch to detect rp2040 --- hw/bsp/rp2040/family.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/bsp/rp2040/family.c b/hw/bsp/rp2040/family.c index 47d729ea39..452a5568f8 100644 --- a/hw/bsp/rp2040/family.c +++ b/hw/bsp/rp2040/family.c @@ -80,9 +80,9 @@ bool __no_inline_not_in_flash_func(get_bootsel_button)(void) { // The HI GPIO registers in SIO can observe and control the 6 QSPI pins. // Note the button pulls the pin *low* when pressed. - #if PICO_RP2040 + #ifdef __ARM_ARCH_6M__ // CM0 for rp2040 #define CS_BIT (1u << 1) - #else + #else // rp2350 (cm33/risv) #define CS_BIT SIO_GPIO_HI_IN_QSPI_CSN_BITS #endif bool button_state = (sio_hw->gpio_hi_in & CS_BIT);