Commit 8189c2de authored by Kongou Hikari's avatar Kongou Hikari

Template: Update Makefile

parent 2c9d4295
*.o
*/build
*~
*.tmp
*/.deps
......@@ -11,7 +11,7 @@ TARGET = gd32vf103
# building variables
######################################
# debug build?
DEBUG = 0
DEBUG = 1
# optimization
OPT = -O2
......@@ -92,7 +92,7 @@ CFLAGS += -g -gdwarf-2
endif
# Generate dependency information
CFLAGS += -std=gnu11 -MMD -MP # -MF$(@:%.o=%.d) -MT$(@:%.o=%.d)
CFLAGS += -std=gnu11 -MMD -MP #.deps/$(notdir $(<:.c=.d)) -MF$(@:%.o=%.d) -MT$(@:%.o=%.d)
#######################################
# LDFLAGS
......@@ -118,13 +118,16 @@ vpath %.c $(sort $(dir $(C_SOURCES)))
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) .deps
@echo "CC $<"
@$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
@$(CC) -c $(CFLAGS) -MMD -MP \
-MF .deps/$(notdir $(<:.c=.d)) \
-Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) .deps
@echo "AS $<"
@$(AS) -c $(CFLAGS) $< -o $@
@$(AS) -c $(CFLAGS) -MMD -MP \
-MF .deps/$(notdir $(<:.s=.d)) $< -o $@
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
@echo "LD $@"
......@@ -145,12 +148,15 @@ $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BUILD_DIR):
mkdir $@
.deps:
mkdir $@
#######################################
# clean up
#######################################
clean:
-rm -fR .dep $(BUILD_DIR)
-rm -fR .deps $(BUILD_DIR)
flash: all
-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;"
......@@ -166,6 +172,6 @@ uart: all
#######################################
# dependencies
#######################################
#-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-include $(shell mkdir .deps 2>/dev/null) $(wildcard .deps/*)
# *** EOF ***
adapter_khz 4000
interface ftdi
ftdi_device_desc "Dual RS232"
ftdi_vid_pid 0x0403 0x6010
#autoexit true
#interface cmsis-dap
transport select jtag
ftdi_layout_init 0x0008 0x001b
ftdi_layout_signal nSRST -oe 0x0020 -data 0x0020
#Reset Stretcher logic on FE310 is ~1 second long
#This doesn't apply if you use
# ftdi_set_signal, but still good to document
#adapter_nsrst_delay 1500
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1e200a6d
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 10000 -work-area-backup 1
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME gd32vf103 0x08000000 0 0 0 $_TARGETNAME
#riscv expose_csrs 3040-3071
init
#reset
#if {[ info exists pulse_srst]} {
# ftdi_set_signal nSRST 0
# ftdi_set_signal nSRST z
#}
halt
# We must turn on this because otherwise the IDE version debug cannot download the program into flash
#flash protect 0 0 last off
adapter_khz 1000
interface ftdi
ftdi_device_desc "Sipeed-Debug"
ftdi_vid_pid 0x0403 0x6010
#autoexit true
#interface cmsis-dap
transport select jtag
ftdi_layout_init 0x0008 0x001b
ftdi_layout_signal nSRST -oe 0x0020 -data 0x0020
#Reset Stretcher logic on FE310 is ~1 second long
#This doesn't apply if you use
# ftdi_set_signal, but still good to document
#adapter_nsrst_delay 1500
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1e200a6d
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 10000 -work-area-backup 1
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME gd32vf103 0x08000000 0 0 0 $_TARGETNAME
#riscv expose_csrs 3040-3071
init
#reset
#if {[ info exists pulse_srst]} {
# ftdi_set_signal nSRST 0
# ftdi_set_signal nSRST z
#}
halt
# We must turn on this because otherwise the IDE version debug cannot download the program into flash
#flash protect 0 0 last off
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment