diff options
| author | Andrew Leech | 2019-05-29 11:11:20 +1000 |
|---|---|---|
| committer | Damien George | 2019-05-29 15:50:17 +1000 |
| commit | 66bcb5596aae3e2f7748ae6b2379e5c542647052 (patch) | |
| tree | 30153343d076d05fba966dc20c36e374a698c1a8 | |
| parent | 019dd84af1e8e9bbdbbb6377c28950d31f05a77c (diff) | |
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.
| -rw-r--r-- | ports/stm32/modmachine.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/ports/stm32/modmachine.c b/ports/stm32/modmachine.c index 7031dea91..eca8322ea 100644 --- a/ports/stm32/modmachine.c +++ b/ports/stm32/modmachine.c @@ -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 |
