aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArksine <arksine.code@gmail.com>2020-04-24 14:29:56 -0400
committerKevinOConnor <kevin@koconnor.net>2020-05-28 14:44:51 -0400
commit05efccc874f34bf16dbc925946c5bbd06cd2d968 (patch)
tree05587f828c5a87f3cf801ccce740ee4dccf4b585 /src
parent4b9b705b992dd7f919b397b48fa4fcded2a89a3c (diff)
downloadkutter-05efccc874f34bf16dbc925946c5bbd06cd2d968.tar.gz
kutter-05efccc874f34bf16dbc925946c5bbd06cd2d968.tar.xz
kutter-05efccc874f34bf16dbc925946c5bbd06cd2d968.zip
stm32f1: Add support for HID Bootloader
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/stm32/Kconfig3
-rw-r--r--src/stm32/Makefile6
-rw-r--r--src/stm32/stm32f1.c11
3 files changed, 16 insertions, 4 deletions
diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig
index 201322b5..3651aa2f 100644
--- a/src/stm32/Kconfig
+++ b/src/stm32/Kconfig
@@ -94,6 +94,8 @@ config STACK_SIZE
choice
prompt "Bootloader offset" if MACH_STM32F407 || 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_7000
@@ -107,6 +109,7 @@ choice
endchoice
config FLASH_START
hex
+ default 0x8000800 if STM32_FLASH_START_800
default 0x8002000 if STM32_FLASH_START_2000
default 0x8007000 if STM32_FLASH_START_7000
default 0x8008000 if STM32_FLASH_START_8000
diff --git a/src/stm32/Makefile b/src/stm32/Makefile
index e5627ec4..dc8768a2 100644
--- a/src/stm32/Makefile
+++ b/src/stm32/Makefile
@@ -52,7 +52,11 @@ $(OUT)klipper.bin: $(OUT)klipper.elf
$(Q)$(OBJCOPY) -O binary $< $@
# Flash rules
-flash: $(OUT)klipper.bin
+lib/hidflash/hid-flash:
+ @echo " Building hid-flash"
+ $(Q)make -C lib/hidflash
+
+flash: $(OUT)klipper.bin lib/hidflash/hid-flash
@echo " Flashing $< to $(FLASH_DEVICE)"
$(Q)$(PYTHON) ./scripts/flash_usb.py -t $(CONFIG_MCU) -d "$(FLASH_DEVICE)" -s "$(CONFIG_FLASH_START)" $(if $(NOSUDO),--no-sudo) $(OUT)klipper.bin
diff --git a/src/stm32/stm32f1.c b/src/stm32/stm32f1.c
index 97a6ade4..cad28f31 100644
--- a/src/stm32/stm32f1.c
+++ b/src/stm32/stm32f1.c
@@ -112,13 +112,18 @@ gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup)
void
usb_request_bootloader(void)
{
- if (!CONFIG_STM32_FLASH_START_2000)
+ if (!(CONFIG_STM32_FLASH_START_2000 || CONFIG_STM32_FLASH_START_800))
return;
- // Enter "stm32duino" bootloader
+ // Enter "stm32duino" or HID bootloader
irq_disable();
RCC->APB1ENR |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN;
PWR->CR |= PWR_CR_DBP;
- BKP->DR10 = 0x01;
+ if (CONFIG_STM32_FLASH_START_800)
+ // HID Bootloader magic key
+ BKP->DR4 = 0x424C;
+ else
+ // stm32duino bootloader magic key
+ BKP->DR10 = 0x01;
PWR->CR &=~ PWR_CR_DBP;
NVIC_SystemReset();
}