Skip to content

Commit b9db23b

Browse files
authored
zephyr: Use zephyr sys_cache instead of CMSIS (#3162)
When running AOT code in Zephyr on STM32H743VIT6 without CONFIG_CACHE_MANAGEMENT=y, a hard fault occurs, which leads to SCB_CleanDCache(). It’s better to use the functions built into Zephyr.
1 parent 8b8c595 commit b9db23b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

core/shared/platform/zephyr/platform_internal.h

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
#include <zephyr/net/net_context.h>
5151
#endif /* end of KERNEL_VERSION_NUMBER < 0x030200 */
5252

53+
#if KERNEL_VERSION_NUMBER >= 0x030300 /* version 3.3.0 */
54+
#if defined(CONFIG_CPU_CORTEX_M7) && defined(CONFIG_ARM_MPU)
55+
#include <zephyr/cache.h>
56+
#endif
57+
#endif /* end of KERNEL_VERSION_NUMBER > 0x030300 */
58+
5359
#ifdef CONFIG_ARM_MPU
5460
#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */
5561
#include <arch/arm/aarch32/cortex_m/cmsis.h>

core/shared/platform/zephyr/zephyr_platform.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,14 @@ void
202202
os_dcache_flush()
203203
{
204204
#if defined(CONFIG_CPU_CORTEX_M7) && defined(CONFIG_ARM_MPU)
205+
#if KERNEL_VERSION_NUMBER < 0x030300 /* version 3.3.0 */
205206
uint32 key;
206207
key = irq_lock();
207208
SCB_CleanDCache();
208209
irq_unlock(key);
210+
#else
211+
sys_cache_data_flush_all();
212+
#endif
209213
#elif defined(CONFIG_SOC_CVF_EM7D) && defined(CONFIG_ARC_MPU) \
210214
&& defined(CONFIG_CACHE_FLUSHING)
211215
__asm__ __volatile__("sync");
@@ -216,7 +220,11 @@ os_dcache_flush()
216220

217221
void
218222
os_icache_flush(void *start, size_t len)
219-
{}
223+
{
224+
#if KERNEL_VERSION_NUMBER >= 0x030300 /* version 3.3.0 */
225+
sys_cache_instr_flush_range(start, len);
226+
#endif
227+
}
220228

221229
void
222230
set_exec_mem_alloc_func(exec_mem_alloc_func_t alloc_func,

0 commit comments

Comments
 (0)