From 548744bef495bb3ed50ca6fcd41dc170b6864451 Mon Sep 17 00:00:00 2001 From: Kongou Hikari Date: Wed, 4 Sep 2019 16:01:24 +0800 Subject: [PATCH] Template: Update Programming rule --- Template/Makefile | 14 +++++++++++--- Template/openocd_ft2232.cfg | 3 +-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Template/Makefile b/Template/Makefile index d17c6ab..4b2b0fb 100644 --- a/Template/Makefile +++ b/Template/Makefile @@ -103,7 +103,7 @@ LDSCRIPT = $(FIRMWARE_DIR)/RISCV/env_Eclipse/GD32VF103x8.lds # libraries #LIBS = -lc_nano -lm LIBDIR = -LDFLAGS = -flto $(ARCH) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) $(PERIFLIB_SOURCES) -Wl,--no-relax -Wl,--gc-sections -Wl,-M=$(BUILD_DIR)/$(TARGET).map -nostartfiles #-ffreestanding -nostdlib +LDFLAGS = -flto $(ARCH) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) $(PERIFLIB_SOURCES) -Wl,--cref -Wl,--no-relax -Wl,--gc-sections -Wl,-M=$(BUILD_DIR)/$(TARGET).map -nostartfiles #-ffreestanding -nostdlib # default action: build all all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin @@ -152,8 +152,16 @@ $(BUILD_DIR): clean: -rm -fR .dep $(BUILD_DIR) flash: all - $()openocd -f ./openocd_ft2232.cfg -c init -c "halt; flash protect 0 0 last off; \ - program {build\gd32vf103.elf} verify ; mww 0xe004200c 0x4b5a6978; mww 0xe0042008 0x01; resume; exit;" + -openocd -f ./openocd_ft2232.cfg -c init -c " flash protect 0 0 last off; \ + program {$(BUILD_DIR)/$(TARGET).elf} verify; mww 0xe004200c 0x4b5a6978; mww 0xe0042008 0x01; resume; exit 0;" + +dfu: all + dfu-util -d 28e9:0189 -a 0 --dfuse-address 0x08000000:leave -D $(BUILD_DIR)/$(TARGET).bin + +#Remove ':leave', the microcontroller will not boot to application when finished programming. + +uart: all + stm32flash -w $(BUILD_DIR)/$(TARGET).bin /dev/ttyUSB0 ####################################### # dependencies diff --git a/Template/openocd_ft2232.cfg b/Template/openocd_ft2232.cfg index 0f55ef9..8606d0e 100644 --- a/Template/openocd_ft2232.cfg +++ b/Template/openocd_ft2232.cfg @@ -26,8 +26,7 @@ $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 10000 -work-ar set _FLASHNAME $_CHIPNAME.flash flash bank $_FLASHNAME gd32vf103 0x08000000 0 0 0 $_TARGETNAME -riscv expose_csrs 3040-3071 -bindto 0.0.0.0 +#riscv expose_csrs 3040-3071 init #reset #if {[ info exists pulse_srst]} {