sleep_us()/sleep_until() hangs forever on RP2350 (SDK 2.3.0): sleep_until() waits indefinitely with hardware alarm unarmed #3078
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#3078
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Environment
arm-none-eabi-gcc (Arm GNU Toolchain 15.2.Rel1 (Build arm-15.86)) 15.2.1 20251203-O3 -DNDEBUG(CMAKE_BUILD_TYPE=Release)-Og(CMAKE_BUILD_TYPE=Debug)Debugging setup used during investigation (not required to reproduce):
raspberrypi/openocd, branchrpi-common, commitacff23ffd100479d6481a1155123774b79a990b9(
0.12.0+dev-00004-gacff23ffd)Comparison test:
Minimal repro
CMakeLists.txtmain.cSteps to reproduce
PICO_BOARD=pico2)Expected behavior
startis printed, followed shortly byend.Actual behavior
startis printed, butendnever appears.When inspected with a debugger, execution is stuck in the
sleep_us()→sleep_until()path and does not return from the sleep call.Reproduction characteristics
The issue is sensitive to the number of consecutive
sleep_us()calls.Observed on my setup:
The loop in the reproducer is only intended to make the failure more reproducible.
The issue is not specific to the
forloop itself. Replacing the loop with multiple consecutivesleep_us()calls produces the same behavior.Debugging details
Backtrace obtained via OpenOCD + GDB (
-Ogbuild):The PC is consistently observed around the
__wfe()wait path reached from:With
-O3, more code is inlined, but repeated debugger interrupts still place execution immediately after awfeinstruction inside the same wait path.Register dump while hung (TIMER0 @ 0x400B0000)
Observed state:
alarm[3](default alarm pool hardware alarm) contains0x528(1,320 us).timerawlcontains0x49ace2(4,828,386 us), far past the programmed alarm value.armed == 0x0; alarm 3 is not armed.inte == 0x8; alarm 3 interrupts are enabled.ints == 0x0; no alarm interrupt is pending.timerawlwas observed to continue incrementing across multiple reads, indicating that the timer itself is still running.At the point where execution is stuck in
sleep_until(), the timer counter continues to advance, the programmed alarm value lies far in the past, and the corresponding hardware alarm is not armed.I have not yet determined how this state is reached.
Additional notes
sleep_us()withbusy_wait_us()avoids the hang.Question
Given the observed state:
sleep_until()wait path,does this match any known RP2350 or pico-sdk alarm scheduling issue?
fix merged into develop