From 71fb3d2f3157a077cb6292024e4fe727470f7b33 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Wed, 28 Aug 2024 15:42:12 +0800 Subject: [PATCH] fix(esp_system): fix test rodata being prefetched into cache unexpectedly --- .../test_apps/cache_panic/main/test_cache_disabled.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/esp_system/test_apps/cache_panic/main/test_cache_disabled.c b/components/esp_system/test_apps/cache_panic/main/test_cache_disabled.c index 19fd6b9ef7..6dfc11af78 100644 --- a/components/esp_system/test_apps/cache_panic/main/test_cache_disabled.c +++ b/components/esp_system/test_apps/cache_panic/main/test_cache_disabled.c @@ -60,7 +60,9 @@ TEST_CASE("spi_flash_cache_enabled() works on both CPUs", "[spi_flash][esp_flash // This needs to sufficiently large array, otherwise it may end up in // DRAM (e.g. size <= 8 bytes && ARCH == RISCV) -static const uint32_t s_in_rodata[8] = { 0x12345678, 0xfedcba98 }; +// And it needs to be >= and aligned to the cacheline size, otherwise it may be prefetched +// to cache data memory before accessing it because of accessing other rodata in the same cacheline. +static const __attribute__((aligned(128))) uint32_t s_in_rodata[32] = { 0x12345678, 0xfedcba98 }; static void reset_after_invalid_cache(void) {