Documentation update for watchdog_get_time_remaining_xx() functions. (Suggestion) #2819
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#2819
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?
I've been playing with the 2.2.0 SDK and the watchdog. I notice from sections 5.1.32.3.5 and 5.1.32.3.6 describing
watchdog_get_time_remaining_ms()andwatchdog_get_time_remaining_usthat they return the last value set and not, as hoped for, the time remaining. (I've seen and noted issue #1492)In my test app, I noticed that irrespective of how often I changed and re-flashed with the debug-probe, it continued to give me the original (first) setting I used. I eventually worked out that a re-flash doesn't (appear to) reboot the device, unlike the Arduinos I'm used to, so the value reported stays stuck at whatever value was current when the last power cycle took place.
Example:
watchdog_enable(4000,1);.watchdog_get_time_remaining_ms()reports 4000.watchdog_enable(5000,1);.watchdog_get_time_remaining_ms()still reports 4000.watchdog_enable(6000,1);.watchdog_get_time_remaining_ms()still reports 4000.watchdog_get_time_remaining_ms()now reports 6000.I know, I know, it's not a huge problem, given that the hardware bug causes the wrong result anyway, but it drove me mad for ages until I hit reset (I have a push-button between
RUNandGNDpins to save me ripping (another) Micro USB off of a Pico board!Perhaps, the docs could mention something like "On RP2040 this method returns the value set
prior to the most recent power cycleinstead of the remaining time due to a h/w bug. Re-flashing doesn't perform a power cycle, so changes will not be reported."My testing code:
Cheers,
Norm.
What do you do when you "reflash" exactly?
Do you do "monitor reset init"?
Morning.
I'm using the VSCode extension, to refresh I simply click the Pico icon over on the left toolbar, then click the "Flash project (SWD)" option. That refreshes the board, but if the board has already had a watchdog timeout, any amended watchdog delay is misreported.
Cheers,
Norm.
Hmmm, I think I see a problem. Here's the output from the "Flash Project (SWD)" command:
Error: Invalid command argument
Error: [rp2040.core0] Execution of event reset-init failed:
args[i] option value ('CX') is not valid
However, that appears to be before the programming started. Plus, the taska.json file doesn't show a "CX" parameter for the flash command:
You seem to be claiming that the time set with
watchdog_enableis getting "latched", and if you set a different time with another call towatchdog_enable, then the value returned bywatchdog_get_time_remaining_msis still reporting the first time that you set, and not the updated time. And that a power-cycle is needed to actually clear this "latched" value. Is that correct? If so, you may have discovered a new hardware bug?Looking at the code in https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2_common/hardware_watchdog/watchdog.c ,
watchdog_enablecalls_watchdog_enable, which updatesload_valueand then callswatchdog_updatewhich finally loads theload_valueinto the watchdog'sLOADregister. Andwatchdog_get_time_remaining_msthen reads theTIMEfield of the watchdog'sCTRLregister.I'd expect an update of the watchdog's
LOADregister to be reflected by theTIMEfield of the watchdog'sCTRLregister (see section 4.7.6 of the RP2040 Datasheet).Update: Oh, I see from your newly-added comment that the problem might be that your Pico isn't getting reflashed correctly, which is a much more likely explanation for the behaviour you're seeing 😉
pinging @will-v-pi as he's the person most familiar with the inner workings of our Pico VS Code extension.
I was wondering if it's being reflashed but not reset
Afternoon @lurch,
My complete code is somewhere above, if you feel the urge to try it! But pretty much what happens is I allow the watchdog to timeout and reset the board with value, say, 4000 ms. I decided that was too short, and made it 6000 ms, and reflashed, but it still reported 4000.
After playing around, I found that no matter how many times I changed the timeout and reflashed the board, if I didn't do a power cycle, the value was never reported as the current timeout. Here's the Serial Monitor output from an initial 8000 ms, reflashed with 4000.
Finally, we get the new value, but only after the power cycle.
Cheers,
Norm.
Looking at the tail end of the reflash, after the error I noted above, I see this:
So, the error came before flashing started, and after flashing and verification, the board was indeed reset.
Weird.
Cheers,
Norm.
Just to add more confusion, I wondered what would be reported if I uploaded the new code with the bootloader, rather than the Debug-Probe. That should reset the board after all? It's even more confusing.
Cheers,
Norm.
Just a guess, but maybe the 250ms value is from the watchdog-reboot triggered by the bootloader at the end of flash writing, and you're somehow reading the old value? And see also https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2_common/hardware_watchdog/include/hardware/watchdog.h#L147
Hi @Lurch.
I have no idea, to be honest! I was just wondering if the "don't show me the current setting, show me the old one" feature still happened when the board was programmed with the bootloader. The resulting 250 mS confused me! (Easily done, to be honest!)
Cheers,
Norm.
@lurch is there anything to do here?
Not sure, but I don't have time to investigate right now, so I changed the milestone.