diff --git a/MODULE.bazel b/MODULE.bazel index 31d6105cc..111ed24cd 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,6 @@ module( name = "pico-sdk", - version = "2.2.0", + version = "2.2.1-develop", ) bazel_dep(name = "platforms", version = "0.0.9") diff --git a/pico_sdk_version.cmake b/pico_sdk_version.cmake index 0a3525873..aca3c585e 100644 --- a/pico_sdk_version.cmake +++ b/pico_sdk_version.cmake @@ -7,10 +7,10 @@ if (NOT DEFINED PICO_SDK_VERSION_MAJOR) set(PICO_SDK_VERSION_MINOR 2) # PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base - set(PICO_SDK_VERSION_REVISION 0) + set(PICO_SDK_VERSION_REVISION 1) # PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base - #set(PICO_SDK_VERSION_PRE_RELEASE_ID develop) + set(PICO_SDK_VERSION_PRE_RELEASE_ID develop) endif() # PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base diff --git a/src/boards/include/boards/waveshare_pico_cam_a.h b/src/boards/include/boards/waveshare_pico_cam_a.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2040_ble.h b/src/boards/include/boards/waveshare_rp2040_ble.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2040_eth.h b/src/boards/include/boards/waveshare_rp2040_eth.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2040_geek.h b/src/boards/include/boards/waveshare_rp2040_geek.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2040_matrix.h b/src/boards/include/boards/waveshare_rp2040_matrix.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2040_pizero.h b/src/boards/include/boards/waveshare_rp2040_pizero.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2040_power_management_hat_b.h b/src/boards/include/boards/waveshare_rp2040_power_management_hat_b.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2040_tiny.h b/src/boards/include/boards/waveshare_rp2040_tiny.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2040_touch_lcd_1.28.h b/src/boards/include/boards/waveshare_rp2040_touch_lcd_1.28.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2350_eth.h b/src/boards/include/boards/waveshare_rp2350_eth.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2350_geek.h b/src/boards/include/boards/waveshare_rp2350_geek.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2350_lcd_0.96.h b/src/boards/include/boards/waveshare_rp2350_lcd_0.96.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2350_lcd_1.28.h b/src/boards/include/boards/waveshare_rp2350_lcd_1.28.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2350_one.h b/src/boards/include/boards/waveshare_rp2350_one.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2350_plus_16mb.h b/src/boards/include/boards/waveshare_rp2350_plus_16mb.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2350_plus_4mb.h b/src/boards/include/boards/waveshare_rp2350_plus_4mb.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2350_tiny.h b/src/boards/include/boards/waveshare_rp2350_tiny.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2350_touch_lcd_1.28.h b/src/boards/include/boards/waveshare_rp2350_touch_lcd_1.28.h old mode 100755 new mode 100644 diff --git a/src/boards/include/boards/waveshare_rp2350_zero.h b/src/boards/include/boards/waveshare_rp2350_zero.h old mode 100755 new mode 100644 diff --git a/src/host/hardware_sync/include/hardware/sync.h b/src/host/hardware_sync/include/hardware/sync.h index ae3865ae2..065cb3e52 100644 --- a/src/host/hardware_sync/include/hardware/sync.h +++ b/src/host/hardware_sync/include/hardware/sync.h @@ -109,8 +109,6 @@ extern "C" { void __sev(); -void __wev(); - void __wfi(); void __wfe(); diff --git a/src/host/hardware_sync/sync_core0_only.c b/src/host/hardware_sync/sync_core0_only.c index 70964c4b0..2578f0413 100644 --- a/src/host/hardware_sync/sync_core0_only.c +++ b/src/host/hardware_sync/sync_core0_only.c @@ -93,23 +93,44 @@ void PICO_WEAK_FUNCTION_IMPL_NAME(spin_unlock)(spin_lock_t *lock, uint32_t saved spin_unlock_unsafe(lock); } -PICO_WEAK_FUNCTION_DEF(__sev) +// These are defined on ARM hosts, but don't do what we want for the host +// since this is a simulated build. + +#if PICO_C_COMPILER_IS_GNU || !__has_builtin(__sev) +#define __sev_c __sev +#else +#pragma redefine_extname __sev_c __sev +#endif + +#if PICO_C_COMPILER_IS_GNU || !__has_builtin(__wfi) +#define __wfi_c __wfi +#else +#pragma redefine_extname __wfi_c __wfi +#endif + +#if PICO_C_COMPILER_IS_GNU || !__has_builtin(__wfe) +#define __wfe_c __wfe +#else +#pragma redefine_extname __wfe_c __wfe +#endif + +PICO_WEAK_FUNCTION_DEF(__sev_c) volatile bool event_fired; -void PICO_WEAK_FUNCTION_IMPL_NAME(__sev)() { +void PICO_WEAK_FUNCTION_IMPL_NAME(__sev_c)() { event_fired = true; } -PICO_WEAK_FUNCTION_DEF(__wfi) +PICO_WEAK_FUNCTION_DEF(__wfi_c) -void PICO_WEAK_FUNCTION_IMPL_NAME(__wfi)() { +void PICO_WEAK_FUNCTION_IMPL_NAME(__wfi_c)() { panic("Can't wait on irq for host core0 only implementation"); } -PICO_WEAK_FUNCTION_DEF(__wfe) +PICO_WEAK_FUNCTION_DEF(__wfe_c) -void PICO_WEAK_FUNCTION_IMPL_NAME(__wfe)() { +void PICO_WEAK_FUNCTION_IMPL_NAME(__wfe_c)() { while (!event_fired) tight_loop_contents(); } @@ -146,4 +167,4 @@ int PICO_WEAK_FUNCTION_IMPL_NAME(spin_lock_claim_unused)(bool required) { PICO_WEAK_FUNCTION_DEF(spin_lock_num) uint PICO_WEAK_FUNCTION_IMPL_NAME(spin_lock_num)(spin_lock_t *lock) { return 0; -} \ No newline at end of file +} diff --git a/src/rp2350/README.md b/src/rp2350/README.md index 7a710171d..528d1932e 100644 --- a/src/rp2350/README.md +++ b/src/rp2350/README.md @@ -1,5 +1,5 @@ This directory contains files specific to the RP2350 hardware. It is only used when building for RP2350 platforms, i.e. -`PICO_PLATFORM=rp2350-arm-s` or `PICO_PLATFORM=rp235-riscv` +`PICO_PLATFORM=rp2350-arm-s` or `PICO_PLATFORM=rp2350-riscv` `hardware_regs` contains low level hardware register #defines autogenerated from the RP2350 chip definition itself. diff --git a/src/rp2_common/hardware_dma/include/hardware/dma.h b/src/rp2_common/hardware_dma/include/hardware/dma.h index 2ae64d5fa..599f8dd2e 100644 --- a/src/rp2_common/hardware_dma/include/hardware/dma.h +++ b/src/rp2_common/hardware_dma/include/hardware/dma.h @@ -556,6 +556,7 @@ static inline uint32_t dma_encode_transfer_count(uint transfer_count) { */ static inline uint32_t dma_encode_transfer_count_with_self_trigger(uint transfer_count) { #if PICO_RP2040 + (void)transfer_count; panic_unsupported(); #else return dma_encode_transfer_count(transfer_count) | (DMA_CH0_TRANS_COUNT_MODE_VALUE_TRIGGER_SELF << DMA_CH0_TRANS_COUNT_MODE_LSB); @@ -578,8 +579,8 @@ static inline uint32_t dma_encode_endless_transfer_count(void) { #if PICO_RP2040 panic_unsupported(); #else - static_assert(DMA_CH0_TRANS_COUNT_MODE_VALUE_ENDLESS == 0xf); - static_assert(DMA_CH0_TRANS_COUNT_MODE_LSB == 28); + static_assert(DMA_CH0_TRANS_COUNT_MODE_VALUE_ENDLESS == 0xf, ""); + static_assert(DMA_CH0_TRANS_COUNT_MODE_LSB == 28, ""); return 0xffffffffu; #endif } diff --git a/src/rp2_common/hardware_gpio/gpio.c b/src/rp2_common/hardware_gpio/gpio.c index 292041a19..a5560bbb8 100644 --- a/src/rp2_common/hardware_gpio/gpio.c +++ b/src/rp2_common/hardware_gpio/gpio.c @@ -196,9 +196,11 @@ void gpio_set_irq_enabled(uint gpio, uint32_t events, bool enabled) { } void gpio_set_irq_enabled_with_callback(uint gpio, uint32_t events, bool enabled, gpio_irq_callback_t callback) { - // first set callback, then enable the interrupt - gpio_set_irq_callback(callback); + // when enabling, first set callback, then enable the interrupt + // when disabling, first disable the interrupt, then clear callback + if (enabled) gpio_set_irq_callback(callback); gpio_set_irq_enabled(gpio, events, enabled); + if (!enabled) gpio_set_irq_callback(callback); if (enabled) irq_set_enabled(IO_IRQ_BANK0, true); } diff --git a/src/rp2_common/hardware_hazard3/include/hardware/hazard3/instructions.h b/src/rp2_common/hardware_hazard3/include/hardware/hazard3/instructions.h index 7abeb5ba6..f14b8c01c 100644 --- a/src/rp2_common/hardware_hazard3/include/hardware/hazard3/instructions.h +++ b/src/rp2_common/hardware_hazard3/include/hardware/hazard3/instructions.h @@ -128,7 +128,7 @@ extern "C" { __h3_bextmi_rd; \ }) #else -#define __hazard3_bextm(nbits, rs1, rs2) (((rs1) >> ((shamt) & 0x1f)) & (0xffu >> (7 - (((nbits) - 1) & 0x7)))) +#define __hazard3_bextmi(nbits, rs1, rs2) (((rs1) >> ((shamt) & 0x1f)) & (0xffu >> (7 - (((nbits) - 1) & 0x7)))) #endif #ifdef __hazard3_extension_xh3power diff --git a/src/rp2_common/hardware_irq/irq.c b/src/rp2_common/hardware_irq/irq.c index fc3d6f12c..fdcbb00fb 100644 --- a/src/rp2_common/hardware_irq/irq.c +++ b/src/rp2_common/hardware_irq/irq.c @@ -128,6 +128,15 @@ void irq_set_pending(uint num) { #endif } +#if !PICO_NO_RAM_VECTOR_TABLE +static void set_raw_irq_handler_and_unlock(uint num, irq_handler_t handler, uint32_t save) { + // update vtable (vtable_handler may be same or updated depending on cases, but we do it anyway for compactness) + get_vtable()[VTABLE_FIRST_IRQ + num] = handler; + __dmb(); + spin_unlock(spin_lock_instance(PICO_SPINLOCK_ID_IRQ), save); +} +#endif + #if !PICO_DISABLE_SHARED_IRQ_HANDLERS && !PICO_NO_RAM_VECTOR_TABLE // limited by 8 bit relative links (and reality) static_assert(PICO_MAX_SHARED_IRQ_HANDLERS >= 1 && PICO_MAX_SHARED_IRQ_HANDLERS < 0x7f, ""); @@ -202,13 +211,6 @@ bool irq_has_shared_handler(uint irq_num) { return is_shared_irq_raw_handler(handler); } -static void set_raw_irq_handler_and_unlock(uint num, irq_handler_t handler, uint32_t save) { - // update vtable (vtable_handler may be same or updated depending on cases, but we do it anyway for compactness) - get_vtable()[VTABLE_FIRST_IRQ + num] = handler; - __dmb(); - spin_unlock(spin_lock_instance(PICO_SPINLOCK_ID_IRQ), save); -} - #else // PICO_DISABLE_SHARED_IRQ_HANDLERS && PICO_NO_RAM_VECTOR_TABLE #define is_shared_irq_raw_handler(h) false bool irq_has_shared_handler(uint irq_num) { diff --git a/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h b/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h index e990a7284..85804f954 100644 --- a/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h +++ b/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h @@ -148,7 +148,7 @@ static inline uint pio_encode_sideset(uint sideset_bit_count, uint value) { * \return the side set bits to be ORed with an instruction encoding */ static inline uint pio_encode_sideset_opt(uint sideset_bit_count, uint value) { - valid_params_if(PIO_INSTRUCTIONS, sideset_bit_count >= 0 && sideset_bit_count <= 4); + valid_params_if(PIO_INSTRUCTIONS, sideset_bit_count <= 4); valid_params_if(PIO_INSTRUCTIONS, value <= ((1u << sideset_bit_count) - 1)); return 0x1000u | value << (12u - sideset_bit_count); } diff --git a/src/rp2_common/hardware_sync/include/hardware/sync.h b/src/rp2_common/hardware_sync/include/hardware/sync.h index 69b3e69a0..14a86c888 100644 --- a/src/rp2_common/hardware_sync/include/hardware/sync.h +++ b/src/rp2_common/hardware_sync/include/hardware/sync.h @@ -94,6 +94,9 @@ __force_inline static void __sev(void) { pico_default_asm_volatile ("sev"); #endif } +#else +// Forward declare so we don't have to #include . +void __sev(void); #endif /*! \brief Insert a WFE instruction in to the code path. @@ -110,6 +113,9 @@ __force_inline static void __wfe(void) { pico_default_asm_volatile ("wfe"); #endif } +#else +// Forward declare so we don't have to #include . +void __wfe(void); #endif /*! \brief Insert a WFI instruction in to the code path. @@ -121,6 +127,9 @@ __force_inline static void __wfe(void) { __force_inline static void __wfi(void) { pico_default_asm_volatile("wfi"); } +#else +// Forward declare so we don't have to #include . +void __wfi(void); #endif /*! \brief Insert a DMB instruction in to the code path. diff --git a/src/rp2_common/pico_mbedtls/include/sha256_alt.h b/src/rp2_common/pico_mbedtls/include/sha256_alt.h index b6658b2a7..78d9a9183 100644 --- a/src/rp2_common/pico_mbedtls/include/sha256_alt.h +++ b/src/rp2_common/pico_mbedtls/include/sha256_alt.h @@ -11,6 +11,6 @@ #include "pico/sha256.h" typedef struct pico_sha256_state mbedtls_sha256_context; -#endif // PICO_RP2350 +#endif // LIB_PICO_SHA256 #endif diff --git a/src/rp2_common/pico_multicore/multicore.c b/src/rp2_common/pico_multicore/multicore.c index 219f24a16..e11595087 100644 --- a/src/rp2_common/pico_multicore/multicore.c +++ b/src/rp2_common/pico_multicore/multicore.c @@ -370,7 +370,7 @@ static bool multicore_doorbell_claim_under_lock(uint doorbell_num, uint core_mas (is_bit_claimed(doorbell_claimed[1], doorbell_num + 1u) << 1)); if (claimed_cores_for_doorbell & core_mask) { if (required) { - panic( "Multicoore doorbell %d already claimed on core mask 0x%x; requested core mask 0x%x\n", + panic( "Multicore doorbell %d already claimed on core mask 0x%x; requested core mask 0x%x\n", claimed_cores_for_doorbell, core_mask); } return false; diff --git a/src/rp2_common/pico_status_led/CMakeLists.txt b/src/rp2_common/pico_status_led/CMakeLists.txt index c14e607bf..cdc30bdf0 100644 --- a/src/rp2_common/pico_status_led/CMakeLists.txt +++ b/src/rp2_common/pico_status_led/CMakeLists.txt @@ -18,5 +18,3 @@ if (PICO_CYW43_SUPPORTED) ) endif() pico_generate_pio_header(pico_status_led ${CMAKE_CURRENT_LIST_DIR}/ws2812.pio) - -get_target_property(OUT pico_status_led LINK_LIBRARIES) diff --git a/src/rp2_common/pico_status_led/include/pico/status_led.h b/src/rp2_common/pico_status_led/include/pico/status_led.h index be7c0bd49..4870bc9b6 100644 --- a/src/rp2_common/pico_status_led/include/pico/status_led.h +++ b/src/rp2_common/pico_status_led/include/pico/status_led.h @@ -109,7 +109,7 @@ bool status_led_init(void); * * \param context An \ref async_context used to communicate with the status LED (e.g. on Pico W or Pico 2 W) * \return Returns true if the LED was initialized successfully, otherwise false on failure - * \sa status_led_init_with_context + * \sa status_led_init */ bool status_led_init_with_context(struct async_context *context); diff --git a/src/rp2_common/pico_status_led/status_led.c b/src/rp2_common/pico_status_led/status_led.c index fc95a9689..309b21e73 100644 --- a/src/rp2_common/pico_status_led/status_led.c +++ b/src/rp2_common/pico_status_led/status_led.c @@ -80,7 +80,8 @@ bool colored_status_led_set_state(bool led_on) { if (colored_status_led_supported()) { #if COLORED_STATUS_LED_USING_WS2812_PIO success = true; - if (led_on && !colored_status_led_on) { + if (led_on) { + // Turn the LED "on" even if it was already on, as the color might have changed success = set_ws2812(colored_status_led_on_color); } else if (!led_on && colored_status_led_on) { success = set_ws2812(0);