make flash: overhaul openocd configuration

Instead of OOCD_SERIAL triggering an attempt to use a specific ftdi based
adapter, introduce common target/interface pairs, OOCD_INTERFACE and
OOCD_TARGET, and an override via OOCD_FILE allowing full control.

Further, attempt to connect to a running openocd instance to flash if possible.
This _will not_ work well if you have multiple openocd instances open at once,
but that's a rare use case.

Examples:
OOCD_INTERFACE=stlink-v2
OOCD_TARGET=stm32f0x
 --> openocd ... -f interface/stlink-v2.cfg -f target/stm32f0x.cfg)

OOCD_FILE=board/ek-lm4f120xl.cfg
 --> openocd ... -f $(OOCD_FILE)  (ie, the variable is passed untouched)

As part of implementing this, correct variables that were always wrong, and
update the openocd flashing commands to use current commands.
This commit is contained in:
Karl Palsson
2016-04-18 01:14:19 +00:00
parent b227e1609c
commit bcd7d57c11
20 changed files with 33 additions and 38 deletions

View File

@@ -29,7 +29,7 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m3 $(FP_FLAGS) -mfix-cortex-m3-ldrd
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= flossjtag OOCD_INTERFACE ?= flossjtag
OOCD_BOARD ?= olimex_stm32_h103 OOCD_TARGET ?= lpc13xx
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -30,7 +30,7 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m3 $(FP_FLAGS) -mfix-cortex-m3-ldrd
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= flossjtag OOCD_INTERFACE ?= flossjtag
OOCD_BOARD ?= olimex_stm32_h103 OOCD_TARGET ?= lpc17xx
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -32,7 +32,7 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m4 $(FP_FLAGS)
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= flossjtag OOCD_INTERFACE ?= flossjtag
OOCD_BOARD ?= olimex_stm32_h103 OOCD_TARGET ?= lpc4357
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -225,27 +225,21 @@ styleclean: $(STYLECHECKFILES:=.styleclean)
ifeq ($(STLINK_PORT),) ifeq ($(STLINK_PORT),)
ifeq ($(BMP_PORT),) ifeq ($(BMP_PORT),)
ifeq ($(OOCD_SERIAL),) ifeq ($(OOCD_FILE),)
%.flash: %.hex %.flash: %.elf
@printf " FLASH $<\n" @printf " FLASH $<\n"
@# IMPORTANT: Don't use "resume", only "reset" will work correctly! $(Q)(echo "halt; program $(*).elf verify reset" | nc -4 localhost 4444 2>/dev/null) || \
$(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \ $(OOCD) -f interface/$(OOCD_INTERFACE).cfg \
-f board/$(OOCD_BOARD).cfg \ -f target/$(OOCD_TARGET).cfg \
-c "init" -c "reset init" \ -c "program $(*).elf verify reset exit" \
-c "flash write_image erase $(*).hex" \ $(NULL)
-c "reset" \
-c "shutdown" $(NULL)
else else
%.flash: %.hex %.flash: %.elf
@printf " FLASH $<\n" @printf " FLASH $<\n"
@# IMPORTANT: Don't use "resume", only "reset" will work correctly! $(Q)(echo "halt; program $(*).elf verify reset" | nc -4 localhost 4444 2>/dev/null) || \
$(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \ $(OOCD) -f $(OOCD_FILE) \
-f board/$(OOCD_BOARD).cfg \ -c "program $(*).elf verify reset exit" \
-c "ft2232_serial $(OOCD_SERIAL)" \ $(NULL)
-c "init" -c "reset init" \
-c "flash write_image erase $(*).hex" \
-c "reset" \
-c "shutdown" $(NULL)
endif endif
else else
%.flash: %.elf %.flash: %.elf

View File

@@ -28,6 +28,6 @@ endif
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= cmsis-dap OOCD_INTERFACE ?= cmsis-dap
OOCD_BOARD ?= OOCD_TARGET ?= at91samdXX
include ../../../../rules.mk include ../../../../rules.mk

View File

@@ -28,8 +28,8 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m0 $(FP_FLAGS)
# OpenOCD specific variables # OpenOCD specific variables
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= flossjtag OOCD_INTERFACE ?= stlink-v2-1
OOCD_BOARD ?= olimex_stm32_h103 OOCD_TARGET ?= stm32f0x
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -29,7 +29,7 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m3 $(FP_FLAGS) -mfix-cortex-m3-ldrd
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= flossjtag OOCD_INTERFACE ?= flossjtag
OOCD_BOARD ?= olimex_stm32_h103 OOCD_TARGET ?= stm32f1x
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -19,7 +19,7 @@
BINARY = usart_irq BINARY = usart_irq
OOCD_BOARD = open-bldc OOCD_FILE = board/open-bldc.cfg
LDSCRIPT = ../obldc.ld LDSCRIPT = ../obldc.ld

View File

@@ -31,7 +31,7 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m3 $(FP_FLAGS) -mfix-cortex-m3-ldrd
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= flossjtag OOCD_INTERFACE ?= flossjtag
OOCD_BOARD ?= olimex_stm32_h103 OOCD_TARGET ?= stm32f2x
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -30,7 +30,7 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m4 $(FP_FLAGS)
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= stlink-v2 OOCD_INTERFACE ?= stlink-v2
OOCD_BOARD ?= stm32f3discovery OOCD_TARGET ?= stm32f3x
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -33,7 +33,7 @@ endif
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= stlink-v2 OOCD_INTERFACE ?= stlink-v2
OOCD_BOARD ?= stm32f4discovery OOCD_TARGET ?= stm32f4x
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -29,7 +29,7 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m0plus $(FP_FLAGS)
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= stlink-v2-1 OOCD_INTERFACE ?= stlink-v2-1
OOCD_BOARD ?= stm32l0discovery OOCD_TARGET ?= stm32l0
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -29,7 +29,7 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m3 $(FP_FLAGS) -mfix-cortex-m3-ldrd
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= stlink-v2 OOCD_INTERFACE ?= stlink-v2
OOCD_BOARD ?= stm32ldiscovery OOCD_TARGET ?= stm32l1
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -29,7 +29,7 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m3 $(FP_FLAGS)
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= flossjtag OOCD_INTERFACE ?= flossjtag
OOCD_BOARD ?= olimex_stm32_h103 OOCD_TARGET ?= stellaris
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -29,10 +29,11 @@ ARCH_FLAGS = -mthumb -mcpu=cortex-m4 $(FP_FLAGS)
# OpenOCD specific variables # OpenOCD specific variables
# Support for ICDI is available starting with openocd 0.7.0 # Support for ICDI is available starting with openocd 0.7.0
# but a board file maybe required to select jtag/swd transport
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= ti-icdi OOCD_INTERFACE ?= ti-icdi
OOCD_BOARD ?= ek-lm4f120xl OOCD_TARGET ?= stellaris
################################################################################ ################################################################################
# Black Magic Probe specific variables # Black Magic Probe specific variables

View File

@@ -18,7 +18,7 @@
## ##
BINARY = miniblink BINARY = miniblink
OOCD_FILE = board/ek-lm4f120xl.cfg
LDSCRIPT = ../ek-lm4f120xl.ld LDSCRIPT = ../ek-lm4f120xl.ld
include ../../Makefile.include include ../../Makefile.include

View File

@@ -18,7 +18,7 @@
## ##
BINARY = uart_echo_interrupt BINARY = uart_echo_interrupt
OOCD_FILE = board/ek-lm4f120xl.cfg
LDSCRIPT = ../ek-lm4f120xl.ld LDSCRIPT = ../ek-lm4f120xl.ld
include ../../Makefile.include include ../../Makefile.include

View File

@@ -18,7 +18,7 @@
## ##
BINARY = uart_echo_simple BINARY = uart_echo_simple
OOCD_FILE = board/ek-lm4f120xl.cfg
LDSCRIPT = ../ek-lm4f120xl.ld LDSCRIPT = ../ek-lm4f120xl.ld
include ../../Makefile.include include ../../Makefile.include

View File

@@ -18,7 +18,7 @@
## ##
BINARY = usb_bulk_dev BINARY = usb_bulk_dev
OOCD_FILE = board/ek-lm4f120xl.cfg
LDSCRIPT = ../ek-lm4f120xl.ld LDSCRIPT = ../ek-lm4f120xl.ld
include ../../Makefile.include include ../../Makefile.include

View File

@@ -18,7 +18,7 @@
## ##
BINARY = usb_to_serial_cdcacm BINARY = usb_to_serial_cdcacm
OOCD_FILE = board/ek-lm4f120xl.cfg
LDSCRIPT = ../ek-lm4f120xl.ld LDSCRIPT = ../ek-lm4f120xl.ld