--- /dev/null
+#!/bin/sh
+# Flashing via serial boot loader
+exec ~/stm/stm32flash/stm32flash "$@"
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:
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
#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>
clock_setup();
gpio_setup();
tick_setup();
+ // This is needed when programming via serial boot loader, harmless otherwise.
+ SCB_VTOR = 0x08000000;
cm_enable_interrupts();
for (;;) {