From d56e7fd9131a5c1a1c2035f846f0afeaf844412d Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 16 Mar 2019 01:34:26 +0700 Subject: [PATCH] adding flash (jlink) --- examples/device/cdc_msc_hid/Makefile | 18 ++++++++++++++++++ hw/bsp/stm32f407g_disc1/board.mk | 5 ++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/examples/device/cdc_msc_hid/Makefile b/examples/device/cdc_msc_hid/Makefile index a8430b4af..21dd059c7 100644 --- a/examples/device/cdc_msc_hid/Makefile +++ b/examples/device/cdc_msc_hid/Makefile @@ -111,6 +111,10 @@ $(BUILD)/$(BOARD)-firmware.elf: $(OBJ) $(BUILD)/$(BOARD)-firmware.bin: $(BUILD)/$(BOARD)-firmware.elf @echo CREATE $@ @$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@ + +$(BUILD)/$(BOARD)-firmware.hex: $(BUILD)/$(BOARD)-firmware.elf + @echo CREATE $@ + @$(OBJCOPY) -O ihex $^ $@ # We set vpath to point to the top of the tree so that the source files # can be located. By following this scheme, it allows a single build rule @@ -139,6 +143,20 @@ $(BUILD)/obj/%.o: %.S @echo AS $(notdir $@) @$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< +# Flash binary using Jlink +ifeq ($(OS),Windows_NT) + JLINKEXE = JLink.exe +else + JLINKEXE = JLinkExe +endif + +flash: $(BUILD)/$(BOARD)-firmware.hex + @echo halt > $(BUILD)/$(BOARD).jlink + @echo loadfile $^ >> $(BUILD)/$(BOARD).jlink + @echo go >> $(BUILD)/$(BOARD).jlink + @echo exit >> $(BUILD)/$(BOARD).jlink + #$(JLINKEXE) -device stm32f407vg -if swd -speed auto -CommandFile $(BUILD)/$(BOARD).jlink + size: $(BUILD)/$(BOARD)-firmware.elf -@echo '' @$(SIZE) $< diff --git a/hw/bsp/stm32f407g_disc1/board.mk b/hw/bsp/stm32f407g_disc1/board.mk index cbd6005dc..d7fdd9e1f 100644 --- a/hw/bsp/stm32f407g_disc1/board.mk +++ b/hw/bsp/stm32f407g_disc1/board.mk @@ -41,7 +41,6 @@ else endif endif -# flash target using on-board stlink or jlink -flash: $(BUILD)/$(BOARD)-firmware.elf +# flash target using on-board stlink +flash-stlink: $(BUILD)/$(BOARD)-firmware.elf $(STM32Prog) --connect port=swd --write $< --go - #JLinkExe \ No newline at end of file