Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PSRAM cache invalidation #9759

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ports/raspberrypi/supervisor/internal_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ static uint32_t m1_timing;
static void save_psram_settings(void) {
#ifdef PICO_RP2350
// We're about to invalidate the XIP cache, clean it first to commit any dirty writes to PSRAM
uint8_t *maintenance_ptr = (uint8_t *)XIP_MAINTENANCE_BASE;
volatile uint8_t *maintenance_ptr = (uint8_t *)XIP_MAINTENANCE_BASE;
for (int i = 1; i < 16 * 1024; i += 8) {
// Background info: https://forums.raspberrypi.com/viewtopic.php?t=378249
maintenance_ptr[i] = 0; // Clean
__compiler_memory_barrier();
maintenance_ptr[i - 1] = 0; // Explicitly invalidate
__compiler_memory_barrier();
}

m1_timing = qmi_hw->m[1].timing;
Expand Down
2 changes: 1 addition & 1 deletion ports/raspberrypi/supervisor/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void port_heap_init(void) {
_heap = tlsf_create_with_pool(heap_bottom, size, 64 * 1024 * 1024);
_ram_pool = tlsf_get_pool(_heap);
if (_psram_size > 0) {
_psram_pool = tlsf_add_pool(_heap, (void *)0x11000004, _psram_size - 4);
_psram_pool = tlsf_add_pool(_heap, (void *)0x11000000, _psram_size);
}
}

Expand Down