lib: os: disable caches before reboot

This ensures that all pending writes are committed. This is relevant for
flags in .noinit SRAM that are read back after reset.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
This commit is contained in:
Armin Brauns 2023-01-18 08:38:21 +01:00 committed by Carles Cufí
parent a5f9fc2382
commit b94ab6e9f1

View file

@ -14,6 +14,18 @@ extern void sys_arch_reboot(int type);
FUNC_NORETURN void sys_reboot(int type) FUNC_NORETURN void sys_reboot(int type)
{ {
(void)irq_lock(); (void)irq_lock();
/* Disable caches to ensure all data is flushed */
#if defined(CONFIG_ARCH_CACHE)
#if defined(CONFIG_DCACHE)
sys_cache_data_disable();
#endif /* CONFIG_DCACHE */
#if defined(CONFIG_ICACHE)
sys_cache_instr_disable();
#endif /* CONFIG_ICACHE */
#endif /* CONFIG_ARCH_CACHE */
sys_clock_disable(); sys_clock_disable();
sys_arch_reboot(type); sys_arch_reboot(type);