Add ability to specify which clocks are re-initialized in 'clock_init()', after microPython 'lightsleep()' #1668
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#1668
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?
From thread:
https://github.com/orgs/micropython/discussions/14087
I am looking to keep the PIOs running during 'lightsleep()', as this will help my project save power. The CPU can pre-fill the FIFOs and then sleep, whilst the PIOs are processing the data.
ATM microPython 'lightsleep()' function calls the 'clock_init()' func after the CPU re-awakes, which causes the clocks to be reinitialized. This is 'bad' for me, as it overwrites the prior 'machine.freq(x)' call, but also potentially causes a glitch on the SYS clock - and therefore glitch on the PIO clocks.
This patch allows the passing of previously used
sleep_en0andsleep_en1values, which are used to determine whether SYS_CLOCK should be reinitialized, or skipped:20240314_sdk_keep_pios_running.patch.txt
I see that your patch is modifying
src/rp2040/hardware_regs/include/hardware/regs/clocks.h- FYI everything insidesrc/rp2040/hardware_regsis autogenerated, so you'll have to move the changes you made there to some other file 😉And I also think we generally prefer Pull Requests, rather than patch files attached to Issues.
I presume you mean that they are generated from
pico-sdk/src/rp2040/hardware_regs/rp2040.svd.How is that done? Can someone point me at a script? What I had added was a 'collation' of the 'SYS_CLK' dependants, not sure how to auto-gen that....
No problem for a PR, if I can figure it out.
Not quite. Both
src/rp2040/hardware_regs/include/hardware/regs/andsrc/rp2040/hardware_regs/rp2040.svdare generated from the same internal data-files. (which are also used to generate the register tables in https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf )This is done with internal (private) tooling.
I am back working on my project for which this is for. I note that the init code has changed substantially in the Pico-SDK and the patch is no longer valid. But....
MicroPython has taken ownship of the clock init, and I have implement a patch in that domain.
https://github.com/micropython/micropython/pull/16183
Okay - if the issue is being handled over on the micropython side of things, can this pico-sdk issue be closed? Or is this still a nice-to-have in the pico-sdk world?
To be honest, it seems that nobody else is crazy enough to be doing stuff like this... ;-)
Since I can implement in MicroPython world, and there's enough of a 'bread crumb trail' to there, I am closing the issue. Thanks.
Sorry I'm turning up very late to this issue from the MicroPython side, but I have realised that it's much more sustainable to have this use case supported in pico-sdk than for us to play catch-up with a patched SDK clocks.c file. I should have followed up back in July, when we split it out - my bad. 😞
Is something like this request still viable, where a variant of
clocks_init()allows specifying which clocks to skip reinitialisation for?Our current use case in MicroPython is to keep the USB clock and PLL running during lightsleep and not re-initialise on wake to avoid glitches, but obviously @mungewell has a use case for the PIO clock, and there are probably many others too.
Your issue #1746 is still open, if you want to add more details to that 🙂
Oh, I did raise this back in the middle of the year 🤦 . I should give myself more credit for thinking ahead (albeit not for having a good memory.) Thanks, @lurch 😄
@projectgus It's not been forgotten about. We had a meeting about a new long overdue "sleep" API recently and the Micropython requirement to keep the USB (or whatever) clock running was discussed.
@peterharperuk Well that's even better that you folks remembered it while I forgot. 😆