diff options
Diffstat (limited to 'src/stm32')
-rw-r--r-- | src/stm32/Kconfig | 5 | ||||
-rw-r--r-- | src/stm32/stm32f4.c | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig index 3651aa2f..53853ace 100644 --- a/src/stm32/Kconfig +++ b/src/stm32/Kconfig @@ -93,11 +93,13 @@ config STACK_SIZE default 512 choice - prompt "Bootloader offset" if MACH_STM32F407 || MACH_STM32F103 || MACH_STM32F070 + prompt "Bootloader offset" if MACH_STM32F407 || MACH_STM32F405 || MACH_STM32F103 || MACH_STM32F070 config STM32_FLASH_START_800 bool "2KiB bootloader (HID Bootloader)" if MACH_STM32F103 config STM32_FLASH_START_2000 bool "8KiB bootloader (stm32duino)" if MACH_STM32F103 || MACH_STM32F070 + config STM32_FLASH_START_4000 + bool "16KiB bootloader (HID Bootloader)" if MACH_STM32F405 || MACH_STM32F407 config STM32_FLASH_START_7000 bool "28KiB bootloader" if MACH_STM32F103 config STM32_FLASH_START_8000 @@ -111,6 +113,7 @@ config FLASH_START hex default 0x8000800 if STM32_FLASH_START_800 default 0x8002000 if STM32_FLASH_START_2000 + default 0x8004000 if STM32_FLASH_START_4000 default 0x8007000 if STM32_FLASH_START_7000 default 0x8008000 if STM32_FLASH_START_8000 default 0x8010000 if STM32_FLASH_START_10000 diff --git a/src/stm32/stm32f4.c b/src/stm32/stm32f4.c index f8b5ab2d..9b5433af 100644 --- a/src/stm32/stm32f4.c +++ b/src/stm32/stm32f4.c @@ -98,7 +98,18 @@ void usb_request_bootloader(void) { irq_disable(); - *(uint64_t*)USB_BOOT_FLAG_ADDR = USB_BOOT_FLAG; + if (CONFIG_STM32_FLASH_START_4000) { + // HID Bootloader + RCC->APB1ENR |= RCC_APB1ENR_PWREN; + RCC->APB1ENR; + PWR->CR |= PWR_CR_DBP; + // HID Bootloader magic key + RTC->BKP4R = 0x424C; + PWR->CR &= ~PWR_CR_DBP; + } else { + // System DFU Bootloader + *(uint64_t*)USB_BOOT_FLAG_ADDR = USB_BOOT_FLAG; + } NVIC_SystemReset(); } |