2019-11-12 15:51:32 +01:00
|
|
|
PROGRAMMER ?= openocd
|
|
|
|
|
2020-05-04 16:31:27 +02:00
|
|
|
PROGRAMMERS_SUPPORTED := bmp dfu-util openocd stm32flash jlink
|
2019-11-12 15:51:32 +01:00
|
|
|
|
|
|
|
ifeq (,$(filter $(PROGRAMMER), $(PROGRAMMERS_SUPPORTED)))
|
|
|
|
$(error Programmer $(PROGRAMMER) not supported)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq (bmp,$(PROGRAMMER))
|
|
|
|
# On Blackmagic Probe, the first ACM is used to connect to the gdb server,
|
|
|
|
# the second is the BMP's UART interface
|
|
|
|
PORT_LINUX ?= /dev/ttyACM1
|
|
|
|
PORT_DARWIN ?= $(wordlist 2, 2, $(sort $(wildcard /dev/tty.usbmodem*)))
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq (openocd,$(PROGRAMMER))
|
|
|
|
# STM32 boards can become un-flashable after a hardfault,
|
|
|
|
# use connect_assert_srst to always be able to flash or reset the boards.
|
2020-02-24 10:26:14 +01:00
|
|
|
OPENOCD_RESET_USE_CONNECT_ASSERT_SRST ?= 1
|
2019-11-12 15:51:32 +01:00
|
|
|
|
|
|
|
# For STM32 boards the ST-link adapter is the default adapter, e.g. all
|
|
|
|
# Nucleo boards have an on-board ST-link adapter
|
2021-02-18 17:15:55 +01:00
|
|
|
OPENOCD_DEBUG_ADAPTER ?= stlink
|
2019-11-12 15:51:32 +01:00
|
|
|
endif
|
|
|
|
|
2020-05-04 16:31:27 +02:00
|
|
|
ifeq (jlink,$(PROGRAMMER))
|
|
|
|
JLINK_DEVICE ?= $(CPU_MODEL)
|
|
|
|
endif
|
|
|
|
|
2019-11-12 15:51:32 +01:00
|
|
|
ifeq (dfu-util,$(PROGRAMMER))
|
|
|
|
# optionally, use dfu-util to flash via usb
|
|
|
|
# note: needs a bootloader flashed before, config below is compatible
|
|
|
|
# with blackmagic_dfu, see https://github.com/blacksphere/blackmagic/
|
|
|
|
# To stop bootloader from loading an existing firmware, pull down
|
|
|
|
# (ground) GPIO B1.
|
|
|
|
ifeq (,$(DFU_USB_ID))
|
|
|
|
$(error DFU_USB_ID is not set)
|
|
|
|
endif
|
|
|
|
endif
|
2020-03-09 15:46:51 +01:00
|
|
|
|
|
|
|
ifeq (stm32flash,$(PROGRAMMER))
|
2020-03-12 12:48:38 +01:00
|
|
|
ROM_OFFSET ?= 0x0
|
2020-03-09 15:46:51 +01:00
|
|
|
FLASHER = stm32flash
|
|
|
|
DEBUGGER =
|
|
|
|
FLASHFILE ?= $(BINFILE)
|
|
|
|
PROG_BAUD ?= 57600
|
2020-03-12 12:48:38 +01:00
|
|
|
BIN_ADDR ?= $(shell echo $$(($(ROM_START_ADDR) + $(ROM_OFFSET))))
|
|
|
|
FFLAGS = -v -b $(PROG_BAUD) -w $(FLASHFILE) -S $(BIN_ADDR) -g $(BIN_ADDR) $(PORT)
|
2020-03-09 15:46:51 +01:00
|
|
|
endif
|