diff --git a/.gitignore b/.gitignore index a8a0dce..29a82f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.bin +*.elf \ No newline at end of file diff --git a/Makefile b/Makefile index ffaa8fc..ba34c52 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ SHELL=/bin/bash BIN = $(wildcard ./*.bin) +ELF = $(wildcard ./*.elf) OFFSET = 0x08000000 OPEN_OCD_PROGRAMMER_CFG = /usr/local/share/openocd/scripts/interface/stlink.cfg OPEN_OCD_MK_CFG = /usr/local/share/openocd/scripts/target/stm32g0x.cfg diff --git a/README.md b/README.md index c5539b4..8694272 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,8 @@ Target: make flash-st : upload flash use st-flash make erase-st : erase flash use st-flash make gdb : open GNU debugger + +Example use: + + make flash BIN=./dodopiza.bin OPEN_OCD_MK_CFG=./stm32f10x.cfg + diff --git a/flash_uploader.mk b/flash_uploader.mk index 8f31474..8c7de80 100644 --- a/flash_uploader.mk +++ b/flash_uploader.mk @@ -6,6 +6,7 @@ SHELL=/bin/bash # OFFSET = 0x08000000 # OPEN_OCD_PROGRAMMER_CFG = /usr/local/share/openocd/scripts/interface/stlink.cfg # OPEN_OCD_MK_CFG = /usr/local/share/openocd/scripts/target/stm32g0x.cfg +# ELF = ./Project.elf # to use GDB HELP_FLASH_UPLOADER = \ " make flash : upload flash use OpenOCD\n"\ @@ -17,7 +18,7 @@ HELP_FLASH_UPLOADER = \ .PHONY: flash erase flash-st erase-st gdb-server gdb -flash: +flash: $(BIN) openocd -f $(OPEN_OCD_PROGRAMMER_CFG) \ -f $(OPEN_OCD_MK_CFG) \ -c init \ @@ -30,17 +31,17 @@ erase: -c "flash init; init; reset halt; flash erase_sector 0 1 last " \ -c shutdown \ -flash-st: +flash-st: $(BIN) st-flash write $(BIN) $(OFFSET) erase-st: st-flash erase OPENOCD_PORT=3333 -gdb: $(PROJECT) +gdb: $(ELF) openocd -f $(OPEN_OCD_PROGRAMMER_CFG) \ -f $(OPEN_OCD_MK_CFG) \ -c 'transport select hla_swd; reset_config none' & - arm-none-eabi-gdb $(PROJECT) \ + arm-none-eabi-gdb $(ELF) \ -ex 'target remote localhost:$(OPENOCD_PORT); monitor reset halt' \ && killall openocd