From 3c0ed3b32e6ac40d55f42525a7e03fbbf30d4e3f Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Mon, 18 Oct 2021 22:35:16 +0100 Subject: [PATCH] Force F7 reset after flashing --- src/main/drivers/system_stm32f7xx.c | 2 +- src/main/startup/system_stm32f7xx.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/drivers/system_stm32f7xx.c b/src/main/drivers/system_stm32f7xx.c index 5fa897bde4..fd89b0c3ea 100644 --- a/src/main/drivers/system_stm32f7xx.c +++ b/src/main/drivers/system_stm32f7xx.c @@ -76,7 +76,7 @@ static void checkForBootLoaderRequest(void) if (bootloaderRequest != RESET_BOOTLOADER_REQUEST_ROM) { return; } - persistentObjectWrite(PERSISTENT_OBJECT_RESET_REASON, RESET_NONE); + persistentObjectWrite(PERSISTENT_OBJECT_RESET_REASON, RESET_BOOTLOADER_POST); __SYSCFG_CLK_ENABLE(); SYSCFG->MEMRMP |= SYSCFG_MEM_BOOT_ADD0 ; diff --git a/src/main/startup/system_stm32f7xx.c b/src/main/startup/system_stm32f7xx.c index 7fa0c1a0ac..33afba1d4f 100644 --- a/src/main/startup/system_stm32f7xx.c +++ b/src/main/startup/system_stm32f7xx.c @@ -313,6 +313,13 @@ void OverclockRebootIfNecessary(uint32_t overclockLevel) */ void SystemInit(void) { + uint32_t bootloaderRequest = persistentObjectRead(PERSISTENT_OBJECT_RESET_REASON); + + if (bootloaderRequest == RESET_BOOTLOADER_POST) { + persistentObjectWrite(PERSISTENT_OBJECT_RESET_REASON, RESET_NONE); + NVIC_SystemReset(); + } + initialiseMemorySections(); SystemInitOC();