From 9bda80b906ece9f401212ef46757b057b37d140c Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 23 Oct 2024 10:17:49 -0700 Subject: [PATCH] Explicitly invalidate cache lines on RP2350 Clean alone can lead to crashes. Fixes #9746 --- ports/raspberrypi/supervisor/internal_flash.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ports/raspberrypi/supervisor/internal_flash.c b/ports/raspberrypi/supervisor/internal_flash.c index 6502aa08b055a..b667112b58802 100644 --- a/ports/raspberrypi/supervisor/internal_flash.c +++ b/ports/raspberrypi/supervisor/internal_flash.c @@ -51,7 +51,9 @@ static void save_psram_settings(void) { // 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; for (int i = 1; i < 16 * 1024; i += 8) { - maintenance_ptr[i] = 0; + // Background info: https://forums.raspberrypi.com/viewtopic.php?t=378249 + maintenance_ptr[i] = 0; // Clean + maintenance_ptr[i - 1] = 0; // Explicitly invalidate } m1_timing = qmi_hw->m[1].timing;