aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/stm32f1/Kconfig4
-rw-r--r--src/stm32f1/Makefile4
-rw-r--r--src/stm32f1/usbserial.c11
3 files changed, 17 insertions, 2 deletions
diff --git a/src/stm32f1/Kconfig b/src/stm32f1/Kconfig
index 78fb1bfd..49cd6919 100644
--- a/src/stm32f1/Kconfig
+++ b/src/stm32f1/Kconfig
@@ -20,10 +20,10 @@ config CLOCK_FREQ
choice
prompt "Bootloader offset"
- config STM_FLASH_START_0000
- bool "No bootloader"
config STM_FLASH_START_2000
bool "8KiB bootloader (stm32duino)"
+ config STM_FLASH_START_0000
+ bool "No bootloader"
endchoice
config FLASH_START
diff --git a/src/stm32f1/Makefile b/src/stm32f1/Makefile
index 8d813d4d..28662a01 100644
--- a/src/stm32f1/Makefile
+++ b/src/stm32f1/Makefile
@@ -47,5 +47,9 @@ $(OUT)klipper.bin: $(OUT)klipper.elf
$(Q)$(OBJCOPY) -O binary $< $@
flash: $(OUT)klipper.bin
+ @echo " Flashing $< to $(FLASH_DEVICE)"
+ $(Q)$(PYTHON) ./scripts/flash_usb.py -t stm32f1 -d "$(FLASH_DEVICE)" $(OUT)klipper.bin
+
+serialflash: $(OUT)klipper.bin
@echo " Flashing $< to $(FLASH_DEVICE) via stm32flash"
$(Q)stm32flash -w $< -v -g 0 $(FLASH_DEVICE)
diff --git a/src/stm32f1/usbserial.c b/src/stm32f1/usbserial.c
index 641aacc0..7eeb3421 100644
--- a/src/stm32f1/usbserial.c
+++ b/src/stm32f1/usbserial.c
@@ -5,8 +5,10 @@
// This file may be distributed under the terms of the GNU GPLv3 license.
#include <string.h> // NULL
+#include "autoconf.h" // CONFIG_STM_FLASH_START_2000
#include "board/gpio.h" // gpio_out_setup
#include "board/io.h" // writeb
+#include "board/irq.h" // irq_disable
#include "board/usb_cdc.h" // usb_notify_ep0
#include "board/usb_cdc_ep.h" // USB_CDC_EP_BULK_IN
#include "internal.h" // GPIO
@@ -214,6 +216,15 @@ usb_set_configure(void)
void
usb_request_bootloader(void)
{
+ if (!CONFIG_STM_FLASH_START_2000)
+ return;
+ // Enter "stm32duino" bootloader
+ irq_disable();
+ RCC->APB1ENR |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN;
+ PWR->CR |= PWR_CR_DBP;
+ BKP->DR10 = 0x01;
+ PWR->CR &=~ PWR_CR_DBP;
+ NVIC_SystemReset();
}