diff --git a/src/platforms/common/blackpill-f4/blackpill-f4.c b/src/platforms/common/blackpill-f4/blackpill-f4.c index 3c7aa0ce8ca..d05ba5b0e45 100644 --- a/src/platforms/common/blackpill-f4/blackpill-f4.c +++ b/src/platforms/common/blackpill-f4/blackpill-f4.c @@ -72,6 +72,12 @@ void platform_init(void) scb_reset_core(); } #endif + + /* Unmap ST MaskROM and map back Internal Flash */ + rcc_periph_clock_enable(RCC_SYSCFG); + if ((SYSCFG_MEMRM & 3U) == 1U) + SYSCFG_MEMRM &= ~3U; + rcc_clock_setup_pll(&rcc_hse_25mhz_3v3[PLATFORM_CLOCK_FREQ]); /* Set up DM/DP pins. PA9/PA10 are not routed to USB-C. */ diff --git a/src/platforms/common/blackpill-f4/usbdfu.c b/src/platforms/common/blackpill-f4/usbdfu.c index d5d205ea968..66ef0649a15 100644 --- a/src/platforms/common/blackpill-f4/usbdfu.c +++ b/src/platforms/common/blackpill-f4/usbdfu.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "usbdfu.h" @@ -54,6 +55,11 @@ int main(void) } else dfu_jump_app_if_valid(); + /* Unmap ST MaskROM and map back Internal Flash */ + rcc_periph_clock_enable(RCC_SYSCFG); + if ((SYSCFG_MEMRM & 3U) == 1U) + SYSCFG_MEMRM &= ~3U; + rcc_clock_setup_pll(&rcc_hse_25mhz_3v3[PLATFORM_CLOCK_FREQ]); /* Assert blue LED as indicator we are in the bootloader */