Skip to content

Commit 98cc153

Browse files
authored
Merge pull request #9759 from dhalbert/rp2350-volatile-cache-invalidate
Fix PSRAM cache invalidation
2 parents 099c43b + b9fa0c8 commit 98cc153

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ports/raspberrypi/supervisor/internal_flash.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ static uint32_t m1_timing;
4949
static void save_psram_settings(void) {
5050
#ifdef PICO_RP2350
5151
// We're about to invalidate the XIP cache, clean it first to commit any dirty writes to PSRAM
52-
uint8_t *maintenance_ptr = (uint8_t *)XIP_MAINTENANCE_BASE;
52+
volatile uint8_t *maintenance_ptr = (uint8_t *)XIP_MAINTENANCE_BASE;
5353
for (int i = 1; i < 16 * 1024; i += 8) {
5454
// Background info: https://forums.raspberrypi.com/viewtopic.php?t=378249
5555
maintenance_ptr[i] = 0; // Clean
56+
__compiler_memory_barrier();
5657
maintenance_ptr[i - 1] = 0; // Explicitly invalidate
58+
__compiler_memory_barrier();
5759
}
5860

5961
m1_timing = qmi_hw->m[1].timing;

ports/raspberrypi/supervisor/port.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void port_heap_init(void) {
244244
_heap = tlsf_create_with_pool(heap_bottom, size, 64 * 1024 * 1024);
245245
_ram_pool = tlsf_get_pool(_heap);
246246
if (_psram_size > 0) {
247-
_psram_pool = tlsf_add_pool(_heap, (void *)0x11000004, _psram_size - 4);
247+
_psram_pool = tlsf_add_pool(_heap, (void *)0x11000000, _psram_size);
248248
}
249249
}
250250

0 commit comments

Comments
 (0)