glitch-free clock not glitch-free #1239
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#1239
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 took inspiration from clocks_init() for switching clocks for entering and leaving power-save sleeping.
clocks_init() first switches clk_ref and clk_sys to a save input, specifically rosc.
But in the order of clk_sys to clk_ref, and afterwards clk_ref to rosc.
It then switches clk_ref to xosc and thus clk_sys indirectly as well.
I have observed that switching clk_ref and indirectly clk_sys in such a way will introduce glitches into clk_sys.
To avoid you'd have to switch clk_sys to anything else first.
(c.f. https://forums.raspberrypi.com/viewtopic.php?t=347154)
Please provide a minimal C SDK testcase example that demonstrates the lockup.
I'll come up with an example...
But just to be clear: I have no way of observing clk_sys directly, I can only see the aftermath of the glitching: xip cache and memory corruption.
Switching clk_sys away from clk_ref first makes all the problems go away.
The pseudo code looks like:
This crashes after a few seconds:
maybe related: should xosc_init() at https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2_common/hardware_clocks/clocks.c#L138 move below the while loops?
xosc_init should be benign if called on an already-enabled xosc.
One thing to note is that if you have clksrc -> clk_ref -> clk_sys, and you switch clk_ref between its two glitchless sources, then there is a period of time where the whole chip is not clocked.
I think that pause should be ok... as long as there's no pheripheral i/o depending on that (sys-)clock.
edit: and in the case of xip, I was expecting the pause to not matter because there is an explicit clock signal to the flash.
any thoughts? was this reproducible on your end?
Unfortunately not. Works fine on a Pico (B1 step) that I have here, in either relwithdebuginfo or debug builds.
dang...
I only have B2s here.
I can reproduce this on a B1 board every time. Example GDB session, starting with it paused on entry to main():
Note that the disassembly is of a function in XIP cache and the disassembly is correct. Now wait for it to crash, which takes less than one second:
Note that the disassembly of the function has changed and is incorrect, suggesting that XIP read bogus data from flash.
Please post the full project directory (including cmakelists.txt) as a zip.
Project attached.
repro.zip
any luck reproducing this on your end?
Negative. Across 4 Picos of random vintage, none of them exhibit the failure mode. Can you upload a .elf with debug symbols that you know will hang on your board? Removes a lot of guesswork.
Edit: In the meantime, is the failure sensitive to core voltage - e.g. hardware/structs/vreg_and_chip_reset.h
This has been open for more than a year and we can't reproduce so closing.