diff --git a/.gitignore b/.gitignore index 98ea1e3..c43db80 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,7 @@ GTAGS *.bin *.elf *.axf -*.map \ No newline at end of file +*.map + +# ignore local makefile settings +src/local.mk \ No newline at end of file diff --git a/libopencm3.rules.mk b/libopencm3.rules.mk index 7a16200..b1e0d26 100644 --- a/libopencm3.rules.mk +++ b/libopencm3.rules.mk @@ -198,46 +198,15 @@ styleclean: $(STYLECHECKFILES:=.styleclean) @printf " FLASH $<\n" $(Q)$(STFLASH) write $(*).bin 0x8000000 -ifeq ($(STLINK_PORT),) -ifeq ($(BMP_PORT),) -ifeq ($(OOCD_SERIAL),) %.flash: %.hex @printf " FLASH $<\n" @# IMPORTANT: Don't use "resume", only "reset" will work correctly! - $(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \ - -f board/$(OOCD_BOARD).cfg \ + $(Q)$(OOCD) -f $(OOCD_INTERFACE) \ + -f $(OOCD_BOARD) \ -c "init" -c "reset init" \ -c "flash write_image erase $(*).hex" \ -c "reset" \ -c "shutdown" $(NULL) -else -%.flash: %.hex - @printf " FLASH $<\n" - @# IMPORTANT: Don't use "resume", only "reset" will work correctly! - $(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \ - -f board/$(OOCD_BOARD).cfg \ - -c "ft2232_serial $(OOCD_SERIAL)" \ - -c "init" -c "reset init" \ - -c "flash write_image erase $(*).hex" \ - -c "reset" \ - -c "shutdown" $(NULL) -endif -else -%.flash: %.elf - @printf " GDB $(*).elf (flash)\n" - $(Q)$(GDB) --batch \ - -ex 'target extended-remote $(BMP_PORT)' \ - -x $(SCRIPT_DIR)/black_magic_probe_flash.scr \ - $(*).elf -endif -else -%.flash: %.elf - @printf " GDB $(*).elf (flash)\n" - $(Q)$(GDB) --batch \ - -ex 'target extended-remote $(STLINK_PORT)' \ - -x $(SCRIPT_DIR)/stlink_flash.scr \ - $(*).elf -endif .PHONY: images clean stylecheck styleclean elf bin hex srec list diff --git a/openocd/debug.cfg b/openocd/debug.cfg index 31e1e10..01bb119 100644 --- a/openocd/debug.cfg +++ b/openocd/debug.cfg @@ -1,5 +1,12 @@ +gdb_port pipe gdb_memory_map disable + $_TARGETNAME configure -event gdb-attach { echo "Halting target" halt +} + +$_TARGETNAME configure -event gdb-detach { + echo "Resetting target" + reset } \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index f1d4810..26df560 100644 --- a/src/Makefile +++ b/src/Makefile @@ -14,6 +14,8 @@ ## NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN ## CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +-include local.mk + BINARY = DAP42 OPENCM3_DIR = ../libopencm3 @@ -52,6 +54,11 @@ include libopencm3.target.mk size: $(OBJS) $(BINARY).elf @$(PREFIX)-size $(OBJS) $(BINARY).elf +debug: $(BINARY).elf + -$(GDB) --tui --eval "target remote | $(OOCD) -f $(OOCD_INTERFACE) -f $(OOCD_BOARD) -f ../openocd/debug.cfg" $(BINARY).elf + +.PHONY += debug size dfuse-flash + OBJS := $(sort $(OBJS)) # Add the base directory to the header search path diff --git a/src/libopencm3.target.mk b/src/libopencm3.target.mk index 8239806..0ecb838 100644 --- a/src/libopencm3.target.mk +++ b/src/libopencm3.target.mk @@ -23,12 +23,14 @@ ifeq ($(ARCH),STM32F0) DEFS += -DSTM32F0 FP_FLAGS ?= -msoft-float ARCH_FLAGS = -mthumb -mcpu=cortex-m0 $(FP_FLAGS) + OOCD_BOARD ?= target/stm32f0x.cfg endif ifeq ($(ARCH),STM32F1) LIBNAME = opencm3_stm32f1 DEFS += -DSTM32F1 FP_FLAGS ?= -msoft-float ARCH_FLAGS = -mthumb -mcpu=cortex-m3 $(FP_FLAGS) -mfix-cortex-m3-ldrd + OOCD_BOARD ?= target/stm32f1x.cfg endif LIBNAME ?= opencm3_stm32f0 @@ -40,17 +42,7 @@ ARCH_FLAGS ?= -mthumb -mcpu=cortex-m0 $(FP_FLAGS) # OpenOCD specific variables OOCD ?= openocd -OOCD_INTERFACE ?= flossjtag -OOCD_BOARD ?= olimex_stm32_h103 - -################################################################################ -# Black Magic Probe specific variables -# Set the BMP_PORT to a serial port and then BMP is used for flashing -BMP_PORT ?= - -################################################################################ -# texane/stlink specific variables -#STLINK_PORT ?= :4242 - +OOCD_INTERFACE ?= interface/cmsis-dap.cfg +OOCD_BOARD ?= target/stm32f1x.cfg include ../libopencm3.rules.mk