Make clocks_init weak so a user can provide their own version #745
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 milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk!745
Loading…
Reference in a new issue
No description provided.
Delete branch "allow-clocks-init-override"
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
clocks_initfunction in the SDK unconditionally sets up the external crystal and PLLs. This function is called as part of runtime_init before the user's main function.It would be nice to be able to override this behaviour so that the system could be started from ROSC only, or simply to avoid bringing up the PLLs. This would make it straightforward to create a project that did not use an external crystal using the standard SDK.
I propose to fix this by making the
clocks_initfunction weak. The user project can then provide their own version that configures ROSC and the clocks they need appropriately, and their version will be preferred by the linker.I agree that the current rather monolithic and fixed runtime startup is not super flexible, and plan to reorganize it in a more customizable fashion.
Thus far we have shied away from overriding of
__weaksymbols (as opposed to having them be present or NULL) because I believe the various compiler/linkers do not support this correctly. I will take another look when we deal withclangsupport.In any case, I'm not going to accept this for now. Feel free to open an issue to track the requirement.
You should be able to workaround it for now by setting
at the top of your
CMakeLists.txtand providing your own replacement implementation ofhardware_clocks. not ideal, but is should work@kilograham Should that be mentioned in https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf somewhere, or is it too much of a "hack" to document?
Thanks for the info on the
SKIPsettings. I've been able to acheive what I wanted usingSKIP_PICO_RUNTIMEand copying that directory out into my own project and making a couple of tweaks. This was nicer than just overridingclocks_init, as I no longer have to bring the USB clock up just to take the USB device out of reset, as I can tweakrutime_initnot to take it out of reset.Overall I agree that the init code just needs to be more configurable - I've raised an issue with some discussion and ideas. Closing this request.
note i thought it was documented, but perhaps not very well !?
hmm; i don't obviously see it... perhaps I have just mentioned it on the forums a bunch
Pull request closed