Skip to content

Conversation

will-v-pi
Copy link
Contributor

@will-v-pi will-v-pi commented Sep 11, 2025

Draft for now, as it includes changes from #2645 and #2137, requires the xip-sram branch of picotool (otherwise UF2 creation and signing fails), and is still WIP - just raising so it can be viewed early, and maybe some of these bits can be added to #2137

This should fix #2653 for both RP2040 and RP2350

This adds new binary types xip_sram (whole binary in XIP SRAM), and copy_to_ram_using_xip_ram/no_flash_using_xip_ram (time critical functions placed in XIP SRAM)

Also adds parsing of addressmap.h so variables in it can be accessed by using pico_get_addressmap_value, to remove hardcoded SRAM addresses from the CMake

Allows creating binaries using an existing binary type & linker script, but with modified RAM/SCRATCH addresses

For example, to only use SRAM1 so you can power down SRAM0 in your binary you could use `pico_set_modified_binary_type(<my_exe> no_flash RAM "0x20040000" "256k"`
New template flash and sram linker scripts, to avoid need for parsing the file

Adds a test to kitchen_sink that these new linker scripts produce the same defaults, to ensure modifications to linker scripts are propogated
Use spinlock IDs that are unaffected by E2
…ash builds

Also modify linker scripts to add templating additional regions, and callback to pico_set_modified_binary_type to set additional variables
On RP2040 they are copy to xip sram, as the bootrom doesn't support direct entry into xip sram
Time critical functions are placed in xip sram for those types
Parse addressmap.h for sram locations, and set them as target properties on pico_standard_link for storage
More DMA, and check the cycles after - now works on RP2040 and RP2350
Add pico_read_addressmap_value function to do actual reading, called by pico_get_addressmap_value when not found
*(.time_critical.text*)
. = ALIGN(4);
__xip_ram_text_end__ = .;
} > XIP_RAM AT> FLASH

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this line ending the .xip_text block needs to be the following in the copy_to_ram_using_xip_ram case

} > XIP_RAM AT> FLASH

and needs to be the following in the no_flash_using_xip_ram case

} > XIP_RAM

__embedded_block_end = .;
. = ALIGN(256);
KEEP (*(.vectors))
*(.time_critical*)
Copy link

@steffenyount steffenyount Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line:

*(.time_critical*)

is preempting the

*(.time_critical.text*)

line of the @ADDITIONAL_PRE_DATA@ block below.

Should it be relocated into the .data block where it is housed for both the copy_to_ram and default linker scripts?


.data : {
__data_start__ = .;
*(vtable)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E.g. could add the following here in .data under vtable as is done for the copy_to_ram and default linker scripts:

        *(.time_critical*)
        . = ALIGN(4);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll ping @kilograham over this, as I'm not sure why time critical is placed in a different place for no_flash vs the other build types?

@steffenyount
Copy link

These changes are now working as expected for me and my test program running on an RP2040 using in following configurations:
pico_set_binary_type(main copy_to_ram_using_xip_ram)
pico_set_binary_type(main copy_to_ram)
pico_set_binary_type(main no_flash_using_xip_ram)
pico_set_binary_type(main no_flash)

KEEP (*(.embedded_block))
__embedded_block_end = .;
KEEP (*(.reset))
}
Copy link

@steffenyount steffenyount Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the RP2350 implementations of this and the copy_to_ram template this block is ended with

} > FLASH

should that be made the same here and in the RP2040's copy_to_ram template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants