Add support for using XIP cache as SRAM#2932
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
Allows overriding what to exclude from .text/.rodata and put in .data
These were being placed in Flash due to a missing space, and also are under libc on some compilers
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
Required changes to the way bazel views these files
…d 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
…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
Use spinlock IDs that are unaffected by E2
|
With memory_psram.incl and memory_xip_ram.incl providing integrated region support out-of-the-box, the comment/example text provided in memory_extra.incl file seems less relevant, and should probably be updated. |
PSRAM and xip_ram are now supported by default
There was a problem hiding this comment.
PICO_XIP_RAM should probably be integrated for PICO_DEFAULT_BINARY_TYPE and PICO_XIP_RAM resolution and exclusion, like all the other built-in binary types being supported above.
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
|
ok, i'm reasonably cool with all this, but
A bit confusing as there is data in XIP_SRAM describe just above that I think i'm still a bit weirded out about the cmake function to put time_critical elsewhere I wonder if we should
|
…er 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
Also re-add note to pico_place_time_critical_functions not to use xip_ram for flash binaries
|
Following those suggestions, I've refactored this to no longer use linker script generation, and just use compile definitions instead. I've also added the new macros in This means the new function is I've also added a I've left in the |
now identical to memory_aliases_no_flash
kilograham
left a comment
There was a problem hiding this comment.
So I think it is worth being clear about thigns; if i understand correctly
-
section .time_critical is now in RAM always (we should probably point out clearly that this is the case - maybe you already did - we don't want to change the name for histortical reasons in the linker script, but worth being verbose wherever we see it that it isn't striclty tied to the time_criitical macro any more
-
__not_in_flash() should probably default to in_ram() but possibly be overridable like time_critical
-
__time_critical (and __not_in_flash) can then i think default to in_ram (which would be defined as section ,time_critical)
it is probably worth adding doxygen to each of the new macros (and linking to the other ones where synojyms)
Perhaps renaming Or maybe implementing the Relatedly, there is precedent for the For the Or alternatively pushing the flag evaluation down into the It looks like the With this alternate approach, the sdk could cleanly focus on its three base binary layouts: E.g: E.g: the E.g: meanwhile for a larger performance oriented application running from ram, I might want to set the following options to selectively place whole sections (E.g: time_critical, not_in_flash, or .text*) of functions/instructions into XIP_RAM to take advantage of the dedicated AHB ports for their instruction bandwidth: Note: I'm trying out the following parameter prefix notation here to differentiate their effects, what do you think? |
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
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
|
@kilograham I have re-arranged
@steffenyount Thanks, I have changed Regarding the ability to place all functions somewhere else, I think that definitely belongs in a different PR, and I think I'd want to see a use case which can't be solved by just annotating the functions with the |
Note that the xip_ram binary type still doesn't work in bazel, as the bazel build doesn't fit in xip_ram
This adds a new
xip_rambinary type (RP2350 only) which puts everything (code, data, and stack) in XIP SRAM, and apico_place_time_critical_functionsCMake function to put functions marked as time_critical in specified memory (eg XIP SRAM or scratch) instead of regular SRAM. Thepico_place_time_critical_functions(TARGET xip_ram)is only useful forcopy_to_ramandno_flashbinary types - it will still work fordefaultbinary types, but makes everything slower instead of faster.Adds tests of both - currently the
pico_xip_sram_testdoesn't fit on Clang or Bazel so is skipped on both, andpico_place_time_critical_functionsis not implemented in Bazel, sopico_critical_xip_sram_testsets the compile definitions directly, for the same effect.Supercedes #2660, and fixes #2653