adding openocd-gdb command to makefile

This commit is contained in:
fishpepper 2017-07-25 23:24:16 +02:00
parent b13f96d29b
commit b57c3ea5d8
2 changed files with 27 additions and 0 deletions

View File

@ -131,6 +131,9 @@ VPATH := $(VPATH):$(ROOT)/make
# start specific includes
include $(ROOT)/make/mcu/$(TARGET_MCU).mk
# openocd specific includes
include $(ROOT)/make/openocd.mk
# Configure default flash sizes for the targets (largest size specified gets hit first) if flash not specified already.
ifeq ($(FLASH_SIZE),)
ifneq ($(TARGET_FLASH),)
@ -180,6 +183,7 @@ endif
# Tool names
CROSS_CC := $(CCACHE) $(ARM_SDK_PREFIX)gcc
CROSS_CXX := $(CCACHE) $(ARM_SDK_PREFIX)g++
CROSS_GDB := $(ARM_SDK_PREFIX)gdb
OBJCOPY := $(ARM_SDK_PREFIX)objcopy
OBJDUMP := $(ARM_SDK_PREFIX)objdump
SIZE := $(ARM_SDK_PREFIX)size
@ -383,6 +387,11 @@ st-flash_$(TARGET): $(TARGET_BIN)
## st-flash : flash firmware (.bin) onto flight controller
st-flash: st-flash_$(TARGET)
ifneq ($(OPENOCD_COMMAND),)
openocd-gdb: $(TARGET_ELF)
$(V0) $(OPENOCD_COMMAND) & $(CROSS_GDB) $(TARGET_ELF) -ex "target remote localhost:3333" -ex "load"
endif
binary:
$(V0) $(MAKE) -j $(TARGET_BIN)

18
make/openocd.mk Normal file
View File

@ -0,0 +1,18 @@
OPENOCD ?= openocd
OPENOCD_IF ?= interface/stlink-v2.cfg
ifeq ($(TARGET_MCU),STM32F3)
OPENOCD_CFG := target/stm32f3x.cfg
else ifeq ($(TARGET_MCU),STM32F4)
OPENOCD_CFG := target/stm32f34.cfg
else ifeq ($(TARGET_MCU),STM32F7)
OPENOCD_CFG := target/stm32f7x.cfg
else
endif
ifneq ($(OPENOCD_CFG),)
OPENOCD_COMMAND = $(OPENOCD) -f $(OPENOCD_IF) -f $(OPENOCD_CFG)
endif