From 5d8fe5dcfd65031242f2af5d412643fed0f46e12 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 24 Mar 2025 07:09:57 +0800 Subject: [PATCH] platform/nuttx: Flush icache/dcache properly (#4147) Enhance the os_dcache_flush and os_icache_flush functions to ensure proper cache invalidation, improving memory management efficiency. * Added cache invalidation for data cache * Implemented cache invalidation for instruction cache Signed-off-by: Huang Qi --- core/shared/platform/nuttx/nuttx_platform.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/shared/platform/nuttx/nuttx_platform.c b/core/shared/platform/nuttx/nuttx_platform.c index dcefb7e84..171adb344 100644 --- a/core/shared/platform/nuttx/nuttx_platform.c +++ b/core/shared/platform/nuttx/nuttx_platform.c @@ -10,6 +10,8 @@ #include #endif +#include + int bh_platform_init() { @@ -115,11 +117,14 @@ os_dcache_flush() && defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS) up_textheap_data_sync(); #endif + up_invalidate_dcache_all(); } void os_icache_flush(void *start, size_t len) -{} +{ + up_invalidate_icache((uintptr_t)start, (uintptr_t)start + len); +} #if (WASM_MEM_DUAL_BUS_MIRROR != 0) void *