diff --git a/left/Makefile b/left/Makefile index 7941a9c..1255771 100644 --- a/left/Makefile +++ b/left/Makefile @@ -31,6 +31,9 @@ FPU = -mfloat-abi=soft # Command for flashing the left half of the keyboard. FLASH_CMD = node ../lib/agent/packages/usb/update-module-firmware.js leftHalf $(PROJECT_OBJ:.axf=.bin) +# Path to the JLink script used for the left half. +JLINK_SCRIPT = ../scripts/flash-left.jlink + # Source files. SOURCE = $(wildcard src/*.c) \ ../lib/KSDK_2.0_MKL03Z8xxx4/devices/MKL03Z4/system_MKL03Z4.c \ diff --git a/right/Makefile b/right/Makefile index ab882d3..0ae5f00 100644 --- a/right/Makefile +++ b/right/Makefile @@ -31,6 +31,9 @@ FPU = -mfpu=fpv4-sp-d16 -mfloat-abi=hard # Command for flashing the right half of the keyboard. FLASH_CMD = node ../lib/agent/packages/usb/update-device-firmware.js $(PROJECT_OBJ:.axf=.hex) +# Path to the JLink script used for the right half. +JLINK_SCRIPT = ../scripts/flash-right.jlink + # Preprocessor directives. BUILD_FLAGS = -DCPU_$(PART)_cm4 -DUSB_STACK_BM -DBL_HAS_BOOTLOADER_CONFIG=1 diff --git a/scripts/Makedefs.mk b/scripts/Makedefs.mk index a0f6fc1..c344580 100644 --- a/scripts/Makedefs.mk +++ b/scripts/Makedefs.mk @@ -29,10 +29,24 @@ PROJECT_OBJ = $(BUILD_DIR)/$(PROJECT_NAME).axf # Set the prefix for the tools to use. PREFIX ?= arm-none-eabi +# Set WIN=1 manually for Windows Subsystem for Linux. +WIN ?= 0 + # Determine if we are on a Windows machine and set the .exe suffix. -# We can not use the suffix command, as the PREFIX might contain spaces. UNAME_S := $(shell uname -s) ifeq ($(OS),Windows_NT) # Native Windows. + WIN = 1 +endif + +# Set J-Link executable. +ifeq ($(WIN),1) + JLINK := JLink.exe +else + JLINK := JLinkExe +endif + +# We can not use the suffix command, as the PREFIX might contain spaces. +ifeq ($(WIN),1) SUFFIX := .exe endif @@ -148,7 +162,7 @@ ifeq ($(INTERACTIVE),1) color_purple = \033[38;5;097m endif -.PHONY: all clean flash +.PHONY: all clean flash flash-jlink # The default rule, which causes the project to be built. all: $(PROJECT_OBJ) @@ -161,6 +175,9 @@ clean: flash: all @$(FLASH_CMD) || exit 1 +flash-jlink: all + $(JLINK) -if SWD -CommandFile $(JLINK_SCRIPT) || exit 1 + # Rebuild all objects when the Makefiles change. $(OBJS): $(MAKEFILE_LIST) diff --git a/scripts/flash-left.jlink b/scripts/flash-left.jlink new file mode 100644 index 0000000..a250d9d --- /dev/null +++ b/scripts/flash-left.jlink @@ -0,0 +1,7 @@ +speed 4000 +device MKL03Z32xxx4 +connect +loadfile build_make/uhk_left.hex +RSetType 2 +r +qc diff --git a/scripts/flash-right.jlink b/scripts/flash-right.jlink new file mode 100644 index 0000000..54b3810 --- /dev/null +++ b/scripts/flash-right.jlink @@ -0,0 +1,7 @@ +speed 4000 +device MK22FN512xxx12 +connect +loadfile build_make/uhk_right.hex +RSetType 2 +r +qc