Skip to content

Commit

Permalink
Use volatile pointerwhen invalidating PSRAM cache
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalbert committed Oct 25, 2024
1 parent b4a45d2 commit b9fa0c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit b9fa0c8

Please sign in to comment.