Skip to content

Commit

Permalink
Invalidate after cleaning the cache line
Browse files Browse the repository at this point in the history
gmx from the RPI forums came up with this hack and it seems to work!
https://forums.raspberrypi.com/viewtopic.php?p=2262371#p2262371
  • Loading branch information
earlephilhower committed Oct 22, 2024
1 parent 88868a5 commit 4ce9d14
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions cores/rp2040/flash_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
#endif

#if defined(PICO_RP2350) && defined(RP2350_PSRAM_CS)
static volatile uint32_t __wastedsum = 0;
static void __no_inline_not_in_flash_func(flushcache)() {
//for (volatile uint8_t* cache = (volatile uint8_t*)0x18000001; cache < (volatile uint8_t*)(0x18000001 + 2048 * 8); cache += 8) {
// *cache = 0;
//}
uint32_t sum = 0; // Ignored, just to ensure not optimized out
for (volatile uint32_t *flash = (volatile uint32_t *)0x11000000; flash < (volatile uint32_t *)(0x11000000 + 48 * 1024 * 4); flash++) {
sum += *flash;
for (volatile uint8_t* cache = (volatile uint8_t*)0x18000001; cache < (volatile uint8_t*)(0x18000001 + 2048 * 8); cache += 8) {
*cache = 0;
__compiler_memory_barrier();
*(cache - 1) = 0;
__compiler_memory_barrier();
}
__wastedsum += sum;
}
#elif defined(PICO_RP2350)
static void __no_inline_not_in_flash_func(flushcache)() {
Expand Down

0 comments on commit 4ce9d14

Please sign in to comment.