WIP: Bug 1668 v2 - Provide method to prevent init of SYS_CLK, when left on during 'lightsleep' #1672
No reviewers
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!1672
Loading…
Reference in a new issue
No description provided.
Delete branch "mungewell/bug_1668_v2"
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?
During 'lightsleep' user may want to keep some clocks running (for example PIOs), but at present microPython calls 'clock-init()' causing the SYS_CLK to be reinitialized.
This patch allows microPython to provide the previously used 'sleep_en0 & sleep_en1' signifying which clocks stayed on. As most are dependant of SYS_CLK it can be inferred that this does NOT need to (/should NOT) be re-initialized.
Is the
&at the end of this line supposed to be&&?@ -168,0 +171,4 @@* During a 'lightsleep' some clocks may have been deliberately left running.* By specifying 'sleep_en0' and 'sleep_en1', it can be automatically determined* that SYS_CLK (and/or it's dependants) is running and thus it is not re-initialised.*/Some Doxygen function-documentation here would be great 🙂
Yes, should be a logical "&&".
I'll update PR and add some documentation. Thanks.
@ -165,6 +165,15 @@ extern "C" {*/Looks like
lightsleep()is only a MicroPython function, not a Pico C-SDK function, so perhaps'lightsleep()'here should be changed to"light sleep"?Should the
voidbe left in the parentheses, as it was originally? (IIRC some compilers get grumpy without this)Hmmm, rather than doing this same logic-test 3 separate times, perhaps it makes sense to do:
just once? 🤔
Can you replace tabs with spaces please, and fix up the indentation? 🙂
I removed the tabs.
Do you want the whole series resubmitted (_v3?) as a single patch/pull request?
That's not my decision to make, so leave it as-is for now unless asked otherwise 🙂
fixes #1668
This "tag" is used to auto-include this code snippet into page 191 of https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf

So in order not to clutter that example, it might make sense to move your new
ifcheck to outside of the tag? i.e.If this patch was extended to also check and selectively init PLL_USB then it would also meet the use case in #1746. Looks like a good approach to reuse the sleep bits this way.
cc @will-v-pi to see if handled by new lower power code
The new low power code doesn't have this issue as it doesn't disable any clocks while sleeping, so doesn't need to reinitialise the clocks when it wakes up.
Currently, Micropython disables the unused clocks during sleep, and therefore needs to reinitialise them afterwards, causing these issues. If they switch to the new low power code, this issue will go away, but there may be a slight increase in power consumption during sleep as the unused clocks are just gated during sleep, rather than being disabled.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.