From ff7f7449d2c40a3aa1e16abf7fc337d1ee43d712 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 1 Dec 2025 10:44:51 +1100 Subject: [PATCH] py/emitglue: Add hook for RV32 arch to flush D-cache for native emitter. Eventually this cache flushing mechanism should be generalised to work the same way for all architectures. But for now, this allows ESP32 RV32 SoCs to flush the D-cache whenn needed. Signed-off-by: Damien George --- py/emitglue.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/py/emitglue.c b/py/emitglue.c index 27cbb349ef..8a32b227ff 100644 --- a/py/emitglue.c +++ b/py/emitglue.c @@ -32,6 +32,7 @@ #include #include "py/emitglue.h" +#include "py/mphal.h" #include "py/runtime0.h" #include "py/bc.h" #include "py/objfun.h" @@ -126,6 +127,9 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, cons "mcr p15, 0, r0, c7, c7, 0\n" // invalidate I-cache and D-cache : : : "r0", "cc"); #endif + #elif (MICROPY_EMIT_RV32 || MICROPY_EMIT_INLINE_RV32) && defined(MP_HAL_CLEAN_DCACHE) + // Flush the D-cache. + MP_HAL_CLEAN_DCACHE(fun_data, fun_len); #endif rc->kind = kind;