stm32/modmachine: In bootloader() disable caches before reset of periphs
Otherwise flushing and disabling the D-cache will give a hard-fault when SDRAM is used. Fixes #4818.
This commit is contained in:
parent
019dd84af1
commit
66bcb5596a
@ -265,6 +265,12 @@ STATIC NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args)
|
||||
storage_flush();
|
||||
#endif
|
||||
|
||||
#if __DCACHE_PRESENT == 1
|
||||
// Flush and disable caches before turning off peripherals (eg SDRAM)
|
||||
SCB_DisableICache();
|
||||
SCB_DisableDCache();
|
||||
#endif
|
||||
|
||||
HAL_RCC_DeInit();
|
||||
HAL_DeInit();
|
||||
|
||||
@ -276,10 +282,6 @@ STATIC NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args)
|
||||
#if MICROPY_HW_USES_BOOTLOADER
|
||||
if (n_args == 0 || !mp_obj_is_true(args[0])) {
|
||||
// By default, with no args given, we enter the custom bootloader (mboot)
|
||||
#if __DCACHE_PRESENT == 1
|
||||
SCB_DisableICache();
|
||||
SCB_DisableDCache();
|
||||
#endif
|
||||
branch_to_bootloader(0x70ad0000, 0x08000000);
|
||||
}
|
||||
|
||||
@ -289,10 +291,6 @@ STATIC NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args)
|
||||
const char *data = mp_obj_str_get_data(args[0], &len);
|
||||
void *mboot_region = (void*)*((volatile uint32_t*)0x08000000);
|
||||
memmove(mboot_region, data, len);
|
||||
#if __DCACHE_PRESENT == 1
|
||||
SCB_DisableICache();
|
||||
SCB_DisableDCache();
|
||||
#endif
|
||||
branch_to_bootloader(0x70ad0080, 0x08000000);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user