This commit is contained in:
kr rt 2023-10-27 23:49:00 +03:00
parent c119ec0f82
commit a0df138a71
4 changed files with 12 additions and 4 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.bin
*.elf

View File

@ -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

View File

@ -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

View File

@ -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