]> mj.ucw.cz Git - home-hw.git/commitdiff
Programming using serial boot loader
authorMartin Mares <mj@ucw.cz>
Mon, 17 Feb 2020 20:48:46 +0000 (21:48 +0100)
committerMartin Mares <mj@ucw.cz>
Mon, 17 Feb 2020 20:48:46 +0000 (21:48 +0100)
bin/stm32flash [new file with mode: 0755]
mk/bluepill.mk
test-blink/Makefile
test-blink/test.c

diff --git a/bin/stm32flash b/bin/stm32flash
new file mode 100755 (executable)
index 0000000..d660f9c
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Flashing via serial boot loader
+exec ~/stm/stm32flash/stm32flash "$@"
index d6146abd72cfbeb495c1999dcfa7f4cf815d722b..e762525e6dbfbd79e562154677c595695292906d 100644 (file)
@@ -105,15 +105,30 @@ ifdef WITH_DFU_FLASH
 
 else
 
+ifdef WITH_SERIAL_FLASH
+
+BOOT_SERIAL ?= /dev/ttyUSB0
+
 %.flash: %.bin
        @printf "  FLASH  $<\n"
-       $(Q)$(ROOT)/bin/st-flash write $(*).bin 0x8000000
+       $(Q)$(ROOT)/bin/stm32flash $(BOOT_SERIAL) -i 'dtr,-dtr' -w $< -g 0
 
 .PHONY: reset
 reset: all
+       $(Q)$(ROOT)/bin/stm32flash $(BOOT_SERIAL) -i 'dtr,-dtr' -g 0
+
+else
+
+%.flash: %.bin
+       @printf "  FLASH  $<\n"
+       $(Q)$(ROOT)/bin/st-flash write $(*).bin 0x8000000
+
+.PHONY: reset
+reset:
        $(ROOT)/bin/st-flash reset
 
 endif
+endif
 
 .SECONDEXPANSION:
 .SECONDARY:
index 81ed48bde96d18b8970cd3d7eb0a96ab565c66eb..953160afa40c7fe8f44dccaedf41e84f14fefdfb 100644 (file)
@@ -3,7 +3,8 @@ BINARY=test
 OBJS=test.o
 LIB_OBJS=util-debug.o
 
-WITH_BOOT_LOADER=1
-WITH_DFU_FLASH=1
+# WITH_BOOT_LOADER=1
+# WITH_DFU_FLASH=1
+WITH_SERIAL_FLASH=1
 
 include $(ROOT)/mk/bluepill.mk
index 50ca8babe3ce09eba9a2f51911594e6228898ecb..e56426c3a324d1c6edafa1e1a40c289b198cbdc2 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <libopencm3/cm3/cortex.h>
 #include <libopencm3/cm3/nvic.h>
+#include <libopencm3/cm3/scb.h>
 #include <libopencm3/cm3/systick.h>
 #include <libopencm3/stm32/rcc.h>
 #include <libopencm3/stm32/gpio.h>
@@ -48,6 +49,8 @@ int main(void)
        clock_setup();
        gpio_setup();
        tick_setup();
+       // This is needed when programming via serial boot loader, harmless otherwise.
+       SCB_VTOR = 0x08000000;
        cm_enable_interrupts();
 
        for (;;) {