Difficult to customise the initialization of clocks and peripherals #748
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#748
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?
The default
runtime_initcallsclocks_init, which sets up the external crystal and PLLs, and configures all the clocks, and then takes all peripherals out of reset, blocking until they come up.This is a sensible default for standard use cases, but for low power use cases you might not want to bring up, or might not even have, an external crystal. This configuration is discussed in a reasonable amount of detail in the RP2040 datasheet. Alternatively you might want to bring up the crystal but not the PLLs, or only configure the clocks and systems that you are actually going to use.
It would be good to have a fully supported way of bringing the system up just off the ring oscillator, and only configuring a minimal set of clocks - REF, SYS and maybe PERI. The user could then bring up any other clocks and peripherals they need. This could be controlled by a simple define.
Alternatively (or in addition), it might be nice to allow the user to specify their own custom
clocks_initfunction, and have that function return a mask of peripherals to take out of reset.Note that it is possible to workaround this by setting
SKIP_PICO_RUNTIMEand/orSKIP_HARDWARE_CLOCKSin cmake, and then making a modified copy of these files in your own project - that's obviously not a great solution as you probably only want to customize a small amount of the functionality, and your copy would miss any later fixes applied to the rest of the code that you had to copy.Sounds like this touches (slightly) on #712 too?
In addition to the full-blown customisation suggested above, may I also suggest a simple mechanism for the board file to specify a different crystal frequency? At the moment it's all totally hard-wired in clocks_init().
A simple PICO_XOSC_HZ or somesuch, preferably supporting the full range (50MHz) that the XOSC can accept from an external oscillator rather than just permitted crystals.
Yup; that seems like a reasonable request - fancy submitting a separate PR?
Can you not already set that by defining
XOSC_MHZ? It appears to accept a range 1-50.Unfortunately not:
I will raise a separate issue as suggested, noting these points. (#1024)
Ooops - point 1) above is wrong - I was accidentally looking at the "host" version of platform_defs.h. The rp2040 version does have the #ifndef wrapper around the definition of XOSC_MHZ. However point 2) is the key issue here.
Just ran into this problem for a custom board with no need for an external clock.
I believe this was actually fixed in 1.5.1