Hardware timer not working after reset under debugger #1152
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#1152
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?
Hello,
During testing some examples I noticed SDK Timer functions are not working when I'm debugging my program.
It seems like they are waiting indefinitely for hw timer, which has value 0.
But if I power cycle my target and then attach debugger (just attach - not resetting core or touching anything in flash) I can see that code is definitely progressing and timer is no longer stuck.
if I step though the code I can see that now timer is progressing normally.
If I then reset target using debugger I can see core staring from 0x000000ee. After some initialization (I cannot track it, it's before runtime_init function) timer registers seem to be reset:
And after full initialization (after runtime_init - I verified core is performing that function), registers are a little different, but timer is stuck at 0:
My code no longer functions, all timer-related functions are blocking infinitely.
Of course power-cycling whole board is fixing this issue, until next target reset.
I'm using OpenOCD, Picoprobe with Cortex Debug plugin in VSCode.
Is this a known issue? Am I am doing anything wrong?
I'm fighting with this issue second day, any help is highly appreciated. Thanks!
Is this the same thing as https://github.com/raspberrypi/picoprobe/issues/45 ?
@lurch you're right, it's the same thing. After adding USE_CORE 0 to openocd configuration I no longer have that problem.
Thanks!
I would say it's still very confusing timer is configured like that? Can you point me to documentation which register should I change to have counter still running when core is halted?
I've not run any code, but a quick look at https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf suggests that
TIMER: DBGPAUSElooks like a likely candidate?I had the same problem and can confirm that adding
timer_hw->dbgpause = 0;to my code fixed the problem for me.Dumb question... It looks timer_hw->dbgpause defaults to 0x7 (DBG1/DBG0) enabled. Turning off DBG1 appears to fix the issue... Should pico_runtime/runtime.c::runtime_init set the timer_hw->dbgpause to 0x2 or 0x0 until the second core is "turned" on, then clear it again if the second core is disabled?
Re-opening to investigate suggestion
@kilograham - Directing your attention regarding this issue here in case you haven't seen it recently. I believe the cause of this problem is users using official releases of OpenOCD 0.12.0 as directed to in the getting started guide, but doing so on non-Raspberry Pi systems. Raspberry Pi appears to serve a more up-to-date build of OpenOCD through
apt, as 0.12.0 official does not contain SMP support.Solution for me was to DL OpenOCD's current snapshot build for Windows, and building OpenOCD from source on Debian to achieve SMP support and resolve timers from freezing. See the linked comment/issue for details.
@recursivenomad Our current recommended setup is to use the Raspberry Pi Pico VSCode extension, which downloads the tools that it needs from https://github.com/raspberrypi/pico-sdk-tools
@will-v-pi Do you think it's worth updating https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf to suggest that people always use pico-sdk-tools rather than installing OpenOCD via other methods?
Specifically this section still recommends using
apt:https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf#_install_openocd
Until OpenOCD 1.0.0 releases later this year, it would also be nice if it could state that OpenOCD 0.12.0 is not supported.
The guide does already state as the first thing that building from source or downloading from pico-sdk-tools is necessary after RP2350 release, so I think that guidance will just need to persist until the next OpenOCD release, and then we can fix the guide to use OpenOCD 1.0.0
I think the confusion stems from the section immediately below that, titled "Install OpenOCD", which recommends installing from
apt. I think a lot of users might click that on the table of contents, and not see the section above it.FWIW, I think the "Install OpenOCD" section isn't necessary, with the how clear the information provided in "Building OpenOCD" is.
I stumbled into the very same problem. But this time with pyocd, not with openocd.
I observed that FreeRTOS with dual core worked in pyocd (even if the application did not use both cores), but single core made the program hang in timer_busy_wait_until() because TIMER0 does not count. Running free worked.
My personal solution was to give core1 a reset at start of my application when in single core mode. But perhaps the correct solution would be to set TIMER.DBGPAUSE to the correct value on startup in SDK?
This docs fix has been merged internally, so will be in the next docs release