Skip to content

Conversation

DavidMenting
Copy link

The RP2350 boot rom restricts access to flash addresses outside of the current partition when partitions are used. This change uses XIP_NOCACHE_NOALLOC_NOTRANSLATE_BASE on RP2350 to enable access to flash regions beyond the currently booted partition. On RP2040, continue using XIP_BASE for optimal cached performance.

On RP2350's without partitions this might result in slightly lower performance, although I suspect the XIP cache is not really useful when working with virtual filesystems anyway.

Fixes #65: RP2350 partitioned flash access restriction

Use XIP_NOCACHE_NOALLOC_NOTRANSLATE_BASE on RP2350 to enable access
to flash regions beyond the currently booted partition. On RP2040,
continue using XIP_BASE for optimal cached performance.

Fixes oyama#65: RP2350 partitioned flash access restriction
@DavidMenting
Copy link
Author

A discussion about this issue is here: https://forums.raspberrypi.com/viewtopic.php?p=2335484#p2335484

A possible improvement for futureproofing is changing the #define to check whether XIP_NOCACHE_NOALLOC_NOTRANSLATE_BASE is defined like so:

#ifdef XIP_NOCACHE_NOALLOC_NOTRANSLATE_BASE
    const uint8_t *flash_contents = (const uint8_t *)(XIP_NOCACHE_NOALLOC_NOTRANSLATE_BASE + flash_target_offset(device) + (size_t)addr);
#else
    const uint8_t *flash_contents = (const uint8_t *)(XIP_BASE + flash_target_offset(device) + (size_t)addr);
#endif

or, if we want to never read through the cache:

#ifdef XIP_NOCACHE_NOALLOC_NOTRANSLATE_BASE
    #define FLASH_BASE XIP_NOCACHE_NOALLOC_NOTRANSLATE_BASE
#else
    #define FLASH_BASE XIP_NOCACHE_NOALLOC_BASE
#endif

const uint8_t *flash_contents = (const uint8_t *)(FLASH_BASE + flash_target_offset(device) + (size_t)addr);

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.

RP2350 Partition Support
1 participant