mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-20 21:27:53 -06:00
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>
This commit is contained in:
parent
b6cd77f6e3
commit
4af8786587
10 changed files with 84 additions and 164 deletions
|
@ -134,39 +134,12 @@ hsi14_setup(void)
|
|||
* Bootloader
|
||||
****************************************************************/
|
||||
|
||||
#define USB_BOOT_FLAG_ADDR (CONFIG_RAM_START + CONFIG_RAM_SIZE - 1024)
|
||||
#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 || !CONFIG_MACH_STM32F0x2
|
||||
|| *(uint64_t*)USB_BOOT_FLAG_ADDR != USB_BOOT_FLAG)
|
||||
return;
|
||||
*(uint64_t*)USB_BOOT_FLAG_ADDR = 0;
|
||||
uint32_t *sysbase = (uint32_t*)0x1fffc400;
|
||||
if (CONFIG_MACH_STM32F072)
|
||||
sysbase = (uint32_t*)0x1fffc800;
|
||||
asm volatile("mov sp, %0\n bx %1"
|
||||
: : "r"(sysbase[0]), "r"(sysbase[1]));
|
||||
}
|
||||
|
||||
// Handle reboot requests
|
||||
void
|
||||
bootloader_request(void)
|
||||
{
|
||||
try_request_canboot();
|
||||
usb_reboot_for_dfu_bootloader();
|
||||
dfu_reboot();
|
||||
}
|
||||
|
||||
|
||||
|
@ -193,7 +166,7 @@ enable_ram_vectortable(void)
|
|||
void
|
||||
armcm_main(void)
|
||||
{
|
||||
check_usb_dfu_bootloader();
|
||||
dfu_reboot_check();
|
||||
SystemInit();
|
||||
|
||||
enable_pclock(SYSCFG_BASE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue