Commit 5aa4bd6
Add support for using XIP cache as SRAM (#2932)
* Separate linker scripts out into include files
Allows for much simpler custom linker scripts
* Add customisable heap location, with pico_set_linker_script_var function
* Add kitchen sink test of custom linker scripts
* Separate out rp2_common and platform-specific linker script sections
* More de-duplication
* Make overriding ram locations simpler
* Make it possible to reference default locations in pico_set_linker_script_var variables
Means that CMake doesn't need to know the default memory addresses for different platforms
* Add pico_add_linker_script_override_path to make overriding individual files easier
Restructured so that it includes the platform-specific files before common ones, so common ones can be overridden
* Add simple overlay demo
* Add scripts to bazel build
Use new include_linker_script_dir and use_linker_script_file functions to add the linker arguments
* Move linker scripts out of crt0
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`
* Make rp2350 text sections the default
Treat rp2040 layout (boot2 instead of embedded blocks) as the outlier
* Rename scripts include directories to standard_scripts and platform_scripts
* Move and add example to Bazel docs for changing linker scripts
* Add cc_library load to new bazel files
* Add excludes.ld files for default memmap
Allows overriding what to exclude from .text/.rodata and put in .data
* Put mem functions in SRAM
These were being placed in Flash due to a missing space, and also are under libc on some compilers
* Rename standard_scripts and platform_scripts to script_include
* Move pico_platform_link stuff into pico_plaftorm
* Remove rigidity from linker include paths
Add PICO_LINKER_SCRIPT_INCLUDE_DIRS and PICO_LINKER_DEFAULT_LOCATIONS_PATH, instead of hardcoded paths under PICO_LINKER_SCRIPT_PATH
Also improve pico_set_linker_script_var and pico_add_linker_script_override_path to better utilise generator expressions
* Rename all linker scripts intended to be included to .incl
Required changes to the way bazel views these files
* Separate into section_... files which do only contain one section, and sections_... which contain multiple
Only exceptions are section_..._data and section_bss, as these contain data/bss and tdata/tbss - these are kept together as they are treated as a single section
* Add section_extra files to make adding extra sections simpler
* Fix comments, and add some more extra files
* Add generated override files - currently unused, but can be overridden in the future by CMake/bazel functions
* pico_add_linker_script_override_path can now be called after target_link_libraries, as it uses generator expressions
Also add more checks to kitchen_sink
* Add extra post_platform_end sections
Intended for platform specific overrides, whereas post_end is for cross-platform overrides, similar to section_end vs section_platform_end
* review fixups
* Save/restore XIP cache state around flash functions
* Fix PICO_USE_SW_SPIN_LOCKS=0 on RP2350
Use spinlock IDs that are unaffected by E2
* Working XIP SRAM binaries
* Change implementation to use pico_use_xip_sram_for_time_critical instead of new binary types
Adds pico_include_in_generated_section to fill section_generated_... files with lists of include files,
and pico_set_compile_definition to allow setting the same definition multiple times on a target without getting warnings
* Add some CMake function docs
* Fix bazel and RP2350 build
Has missed setting PICO_CRT0_PIN_XIP_SRAM
* Fix bazel build
Ordering of transistions matters
* Improve new __time_critical_func description
Special treatment is no longer in the future
* Add pico_test, and improve SRAM thrashing
* fix bazel build
* fixup merge
* Move memory_xip_ram.incl to match location in other PRs
* Review fixups
Place RAM_SECTION_NAME in .time_critical.text
Typo in __time_critical_func description
* fixup merge
* review fixup
* add memmap_xip_ram.cmake
* some minor cleanup
* Doesn't require data copy for no_flash use_xip_cache_as_ram on RP2040
The code is still loaded before boot on rp2040, so doesn't need copying
* remove copy-paste typo
* Fixes for compatibility with low power
Skip low power unpinning when PICO_USE_XIP_CACHE_AS_RAM is set
Take xip_ram as argument to pico_set_persistent_data_loc, to allow placing normally instead of specifying address
Add pico_critical_xip_sram_test_low_power test to check usin xip_ram for both works
* Improve pico_set_persistent_data_loc description
* add () inside #define
* Update memory_extra.incl examples
PSRAM and xip_ram are now supported by default
* Improve binary type generator expressions
Use PICO_DEFAULT_BINARY_TYPE in the generator expressions, to remove need for PICO_NO_FLASH etc, and fixup the legacy variable handling to that effect
Now throws an error if both PICO_DEFAULT_BINARY_TYPE and one of PICO_NO_FLASH etc are specified - just use PICO_DEFAULT_BINARY_TYPE
* Refactor to place functions using compile definitions instead of linker script injections
This adds section_xip_ram.incl into every linker script, and provides the __in_xip_ram macro to put stuff there
__time_critical_func then uses the PICO_TIME_CRITICAL_PLACEMENT define to select where to place code, so that can be overriden to be __in_xip_ram to place time critical functions in xip_ram
Also works for placing time critical functions in scratch x/y
* pico_use_xip_cache_as_sram -> pico_use_xip_cache_as_ram for consistency
Also re-add note to pico_place_time_critical_functions not to use xip_ram for flash binaries
* fix bazel linting
* remove memory_aliases_xip_ram_only
now identical to memory_aliases_no_flash
* Re-arrange sections.h to be clearer what everything does
All `__in_xxx` macros place directly into linker sections, which are located in the relevant memory
`__scratch_x` and `__scratch_y` are kept as aliases to `__in_scratch_x` and `__in_scratch_y`
`__not_in_flash` is placed using `PICO_NOT_IN_FLASH_PLACEMENT` which defaults to `__in_ram`, and the same for `__time_critical_func`, so they can be placed separately
pico_place_time_critical_functions -> pico_set_time_critical_placement, and add pico_set_not_in_flash_placement
* Make memmap_xip_ram.incl include memmap_no_flash.incl
Removes the ability to override XIP_RAM_ORIGIN and XIP_RAM_LENGTH (to prevent duplicate includes, which Clang doesn't like), but that is fine
* Fixup bazel build
Note that the xip_ram binary type still doesn't work in bazel, as the bazel build doesn't fit in xip_ram
* fix bazel buildifier checks
---------
Co-authored-by: graham sanderson <graham.sanderson@raspberrypi.com>1 parent 3d63b1d commit 5aa4bd6
46 files changed
Lines changed: 926 additions & 78 deletions
File tree
- bazel
- config
- constraint
- src
- common/pico_base_headers
- rp2040/pico_platform
- rp2350/pico_platform
- include/pico
- rp2_common
- hardware_flash
- hardware_riscv_platform_timer
- hardware_sync_spin_lock/include/hardware/sync
- pico_crt0
- pico_low_power
- pico_platform_sections/include/pico/platform
- pico_runtime_init/include/pico
- pico_standard_link
- script_include
- test
- pico_xip_sram_test
- tools
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
0 commit comments