From 443b7012d70f72486e14e8981a759e13305b68c0 Mon Sep 17 00:00:00 2001 From: Swift Tian Date: Wed, 7 May 2025 15:38:22 +0800 Subject: [PATCH] soc: ambiq: fix potential issues 1. fix compile issue when CONFIG_DCACHE=n 2. check null in buf_in_nocache Signed-off-by: Swift Tian --- soc/ambiq/apollo5x/soc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/soc/ambiq/apollo5x/soc.c b/soc/ambiq/apollo5x/soc.c index cc0affc7d40..8f168b19141 100644 --- a/soc/ambiq/apollo5x/soc.c +++ b/soc/ambiq/apollo5x/soc.c @@ -8,9 +8,9 @@ #include #include #include -#ifdef CONFIG_DCACHE +#ifdef CONFIG_CACHE_MANAGEMENT #include -#endif /* CONFIG_DCACHE */ +#endif /* CONFIG_CACHE_MANAGEMENT */ #ifdef CONFIG_NOCACHE_MEMORY #include @@ -48,8 +48,9 @@ void soc_early_init_hook(void) /* * Set default temperature for spotmgr to room temperature */ - am_hal_pwrctrl_temp_thresh_t dummy[32]; - am_hal_pwrctrl_temp_update(25.0f, dummy); + am_hal_pwrctrl_temp_thresh_t dummy; + + am_hal_pwrctrl_temp_update(25.0f, &dummy); /* Enable Icache*/ sys_cache_instr_enable(); @@ -63,6 +64,10 @@ bool buf_in_nocache(uintptr_t buf, size_t len_bytes) { bool buf_within_nocache = false; + if (buf == 0 || len_bytes == 0) { + return buf_within_nocache; + } + #if CONFIG_NOCACHE_MEMORY /* Check if buffer is in nocache region defined by the linker */ buf_within_nocache = (buf >= ((uintptr_t)_nocache_ram_start)) &&