Add pico_low_power library#2852
Conversation
Allows for much simpler custom linker scripts
…ript_var variables Means that CMake doesn't need to know the default memory addresses for different platforms
…l files easier Restructured so that it includes the platform-specific files before common ones, so common ones can be overridden
Use new include_linker_script_dir and use_linker_script_file functions to add the linker arguments
Breaking change for Bazel builds using different binary types, instead of setting PICO_DEFAULT_LINKER_SCRIPT to eg `//src/rp2_common/pico_crt0:no_flash_linker_script` it is now `//src/rp2_common/pico_standard_link:no_flash_linker_script`
Treat rp2040 layout (boot2 instead of embedded blocks) as the outlier
|
|
||
| static inline generic_bitset_t *bitset_write_word(generic_bitset_t *bitset, uint word_num, uint32_t value) { | ||
| check_bitset(bitset); | ||
| if (word_num < bitset_word_size(bitset)) { |
There was a problem hiding this comment.
Should this raise an error if word_num >= bitset_word_size(bitset) ?
There was a problem hiding this comment.
This is a question for @kilograham, but given that the other functions don't throw any errors when you attempt to pass a value that is outside the range and just return 0/do nothing, I think this one should also not throw an error?
…n in the future by CMake/bazel functions
…ink_libraries, as it uses generator expressions Also add more checks to kitchen_sink
Intended for platform specific overrides, whereas post_end is for cross-platform overrides, similar to section_end vs section_platform_end
Existing method of just setting the linker script didn't work, because the PICO_NO_FLASH/PICO_COPY_TO_RAM define was only available in pico_platform, but needed to be propogated to things that only use pico_base_headers
…e for individual binaries Can remove full no_flash etc test builds, as there can now be kitchen_sink_no_flash etc builds like in CMake
Now uses single linker_scripts function to allow both including and linking scripts Returns DefaultInfo with all necessary files Prepends ctx.label.workspace_root to link_include_dir Gets link_include_dir directly from the include_scripts passed in
… bazel Also adds pico_set_linker_script transition to set linker script for individual binaries
Remove whitespace, and rename memory_aliases_default to memory_aliases_flash, as it applies to copy_to_ram too
Commits on this branch are very messy due to being on top of changing linker scripts, so definitely need squashing before final merge
| * | ||
| * \param range 0x01 Low, 0x02 Medium, 0x03 High, 0x04 Too High. | ||
| */ | ||
| void rosc_set_range(uint range); |
There was a problem hiding this comment.
also not sure about the function name - note the impl says it takes constants with PASSWORDS (which would probably be weird for the API) but the docs here say otherwise
There was a problem hiding this comment.
Yes, that is incorrect - happy to remove the API, or fix it if you want to keep it, it's from the original sleep2
| * | ||
| * \return The frequency of the Ring Oscillator in kHz. | ||
| */ | ||
| uint rosc_measure_freq_khz(void); |
There was a problem hiding this comment.
there must be caveats as to how/when this works - for example presumably not when running from the ROSC
There was a problem hiding this comment.
It works whenever clk_ref is running at an accurate frequency - I'll add a note to both this and the rosc_find_freq_mhz function, as they both use frequency_count_khz
| } | ||
|
|
||
| bool rtc_run_from_external_source(uint32_t src_hz, uint gpio_pin) { | ||
| return clock_configure_gpin(clk_rtc, gpio_pin, src_hz, 46875); |
There was a problem hiding this comment.
That number appears in sections 2.15.3.1 and 4.8.4 in the RP2040 datasheet - appears to be the default clk_rtc frequency?
There was a problem hiding this comment.
It doesn't seem to have an SDK-wide define, it's only defined in runtime_init_clocks.c. Maybe the RTC_CLOCK_FREQ_HZ define should be moved into RP2040 platform_defs.h, so it can be used here?
Also update note about DORMANT_CLOCK_SOURCE_LPOSC for pin state, to clarify that you should use DORMANT_CLOCK_SOURCE_ROSC instead
Now include persistent data section
Also add __unused to check_fixed_bitset to fix release builds
Also allow setting PICO_ALLOW_EXAMPLE_KEYS as a property, and allow it for test/ directory
Use a key, rather than a key share, to prevent warnings about hamming weights when building hello_sleep_encrypted Keep old file too, for picotool_check_default_keys
This adds a pico_low_power library, which allows going to sleep, dormant, and powman pstates.
Also adds bitsets and hardware_rosc, to support the low power stuff.
Includes a possible fix for #2420 to get the bazel rp2040 clang build working
Requires the include linker scripts in #2841, so will need rebasing once those are merged
Also requires raspberrypi/picotool#298 when putting persistent data in XIP SRAM
See low_power.h for documentation