From 0071f68cb698da5e2f9d56b01bde912d3e5e5761 Mon Sep 17 00:00:00 2001 From: kuwoyuki Date: Thu, 5 Dec 2024 19:12:06 +0600 Subject: [PATCH] fix: separate makefile for openocd cmds --- Makefile | 30 ++---------------------------- rtl8710-openocd.mk | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 28 deletions(-) create mode 100644 rtl8710-openocd.mk diff --git a/Makefile b/Makefile index ecf857b..b279fc4 100644 --- a/Makefile +++ b/Makefile @@ -22,10 +22,6 @@ CFLAGS = -mcpu=cortex-m4 -mthumb -Os -flto \ SRC = rtl8710_flasher.c TARGET = rtl8710_flasher -INTERFACE = stlink - -OPENOCD_BASE=openocd -f interface/$(INTERFACE).cfg -f script/rtl8710.ocd -c "init" -c "reset" -c "halt" - # generate OpenOCD script with embedded flasher bin script/rtl8710.ocd: $(TARGET).bin rtl8710_cpu.tcl rtl8710_flasher.tcl cat rtl8710_cpu.tcl > $@ @@ -45,28 +41,6 @@ $(TARGET).elf: $(SRC) clean: rm -f $(TARGET).elf $(TARGET).bin script/rtl8710.ocd -test: - $(OPENOCD_BASE) -c "rtl8710_flash_read_id" -c "shutdown" +include rtl8710-openocd.mk -mac: - $(OPENOCD_BASE) -c "rtl8710_flash_read_mac" -c "shutdown" - -dump: - $(OPENOCD_BASE) -c "rtl8710_flash_read_id" -c "rtl8710_flash_read dump.bin 0 1048576" -c "shutdown" - -full_erase: - $(OPENOCD_BASE) -c "rtl8710_flash_mass_erase" -c shutdown - -restore: - $(OPENOCD_BASE) -c "rtl8710_flash_auto_erase 1" -c "rtl8710_flash_auto_verify 1" -c "rtl8710_flash_write dump.bin 0" -c shutdown - -restore_nae: - $(OPENOCD_BASE) -c "rtl8710_flash_auto_erase 0" -c "rtl8710_flash_auto_verify 1" -c "rtl8710_flash_write dump.bin 0" -c shutdown - -verify: - $(OPENOCD_BASE) -c "rtl8710_flash_verify dump.bin 0" -c shutdown - -reset: - $(OPENOCD_BASE) -c "rtl8710_reboot" -c shutdown - -.PHONY: clean +.PHONY: rtl-test rtl-mac rtl-dump rtl-full-erase rtl-restore rtl-restore-nae rtl-verify rtl-reset clean diff --git a/rtl8710-openocd.mk b/rtl8710-openocd.mk new file mode 100644 index 0000000..99c9707 --- /dev/null +++ b/rtl8710-openocd.mk @@ -0,0 +1,31 @@ +# override if importing as submodule +RTL8710_PATH ?= . +RTL8710_SCRIPT_PATH ?= $(RTL8710_PATH)/script + +INTERFACE ?= stlink + +OPENOCD_BASE = openocd -f interface/$(INTERFACE).cfg -f $(RTL8710_SCRIPT_PATH)/rtl8710.ocd -c "init" -c "reset" -c "halt" + +rtl-test: + $(OPENOCD_BASE) -c "rtl8710_flash_read_id" -c "shutdown" + +rtl-mac: + $(OPENOCD_BASE) -c "rtl8710_flash_read_mac" -c "shutdown" + +rtl-dump: + $(OPENOCD_BASE) -c "rtl8710_flash_read_id" -c "rtl8710_flash_read dump.bin 0 1048576" -c "shutdown" + +rtl-full-erase: + $(OPENOCD_BASE) -c "rtl8710_flash_mass_erase" -c shutdown + +rtl-restore: + $(OPENOCD_BASE) -c "rtl8710_flash_auto_erase 1" -c "rtl8710_flash_auto_verify 1" -c "rtl8710_flash_write dump.bin 0" -c shutdown + +rtl-restore-nae: + $(OPENOCD_BASE) -c "rtl8710_flash_auto_erase 0" -c "rtl8710_flash_auto_verify 1" -c "rtl8710_flash_write dump.bin 0" -c shutdown + +rtl-verify: + $(OPENOCD_BASE) -c "rtl8710_flash_verify dump.bin 0" -c shutdown + +rtl-reset: + $(OPENOCD_BASE) -c "rtl8710_reboot" -c shutdown