aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32/stm32f4.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2022-12-15 11:23:28 -0500
committerKevin O'Connor <kevin@koconnor.net>2022-12-18 19:50:08 -0500
commit4af87865875755b421873e7e4e43ece958ab00ee (patch)
treefcef44139275082394abfc17257011a5da90566b /src/stm32/stm32f4.c
parentb6cd77f6e377060d2625126ffef9b2842e1cc25b (diff)
downloadkutter-4af87865875755b421873e7e4e43ece958ab00ee.tar.gz
kutter-4af87865875755b421873e7e4e43ece958ab00ee.tar.xz
kutter-4af87865875755b421873e7e4e43ece958ab00ee.zip
stm32: Move dfu reboot logic to new dfu_reboot.c file
Move the stm32 DFU reboot logic to a new dfu_reboot.c file. This simplifies the per-chip code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32/stm32f4.c')
-rw-r--r--src/stm32/stm32f4.c28
1 files changed, 2 insertions, 26 deletions
diff --git a/src/stm32/stm32f4.c b/src/stm32/stm32f4.c
index 4f1dc084..a2060d76 100644
--- a/src/stm32/stm32f4.c
+++ b/src/stm32/stm32f4.c
@@ -204,30 +204,6 @@ usb_hid_bootloader(void)
NVIC_SystemReset();
}
-#define USB_BOOT_FLAG_ADDR (CONFIG_RAM_START + CONFIG_RAM_SIZE - 4096)
-#define USB_BOOT_FLAG 0x55534220424f4f54 // "USB BOOT"
-
-// Flag that bootloader is desired and reboot
-static void
-usb_reboot_for_dfu_bootloader(void)
-{
- irq_disable();
- *(uint64_t*)USB_BOOT_FLAG_ADDR = USB_BOOT_FLAG;
- NVIC_SystemReset();
-}
-
-// Check if rebooting into system DFU Bootloader
-static void
-check_usb_dfu_bootloader(void)
-{
- if (!CONFIG_USB || *(uint64_t*)USB_BOOT_FLAG_ADDR != USB_BOOT_FLAG)
- return;
- *(uint64_t*)USB_BOOT_FLAG_ADDR = 0;
- uint32_t *sysbase = (uint32_t*)0x1fff0000;
- asm volatile("mov sp, %0\n bx %1"
- : : "r"(sysbase[0]), "r"(sysbase[1]));
-}
-
// Handle reboot requests
void
bootloader_request(void)
@@ -235,7 +211,7 @@ bootloader_request(void)
try_request_canboot();
if (CONFIG_STM32_FLASH_START_4000)
usb_hid_bootloader();
- usb_reboot_for_dfu_bootloader();
+ dfu_reboot();
}
@@ -247,7 +223,7 @@ bootloader_request(void)
void
armcm_main(void)
{
- check_usb_dfu_bootloader();
+ dfu_reboot_check();
// Run SystemInit() and then restore VTOR
SystemInit();