aboutsummaryrefslogtreecommitdiffstats
path: root/os/various/jlink.mk
diff options
context:
space:
mode:
Diffstat (limited to 'os/various/jlink.mk')
-rw-r--r--os/various/jlink.mk33
1 files changed, 33 insertions, 0 deletions
diff --git a/os/various/jlink.mk b/os/various/jlink.mk
new file mode 100644
index 0000000..1a13bd3
--- /dev/null
+++ b/os/various/jlink.mk
@@ -0,0 +1,33 @@
+JLINK ?= JLinkExe
+JLINK_GDB_SERVER ?= JLinkGDBServer
+JLINK_GDB_PORT ?= 2331
+JLINK_IF ?= swd
+JLINK_SPEED ?= 2000
+JLINK_START_ADDRESS ?= 0
+JLINK_BURN ?= $(BUILDDIR)/$(PROJECT).bin
+JLINK_COMMON_OPTS ?= -device $(JLINK_DEVICE) -if $(JLINK_IF) -speed $(JLINK_SPEED)
+
+jlink-flash:
+ printf "$(JLINK_PRE_FLASH)\nloadbin $(JLINK_BURN) $(JLINK_START_ADDRESS)\nverifybin $(JLINK_BURN) $(JLINK_START_ADDRESS)\nr\ng\nexit\n" > $(BUILDDIR)/flash.jlink
+ $(JLINK) $(JLINK_COMMON_OPTS) $(BUILDDIR)/flash.jlink
+
+ifneq ($(SOFTDEVICE),)
+jlink-flash-softdevice:
+ printf "w4 4001e504 1\nloadbin $(NRF51SDK)/components/softdevice/$(SOFTDEVICE)/hex/$(SOFTDEVICE)_nrf51_$(SOFTDEVICE_RELEASE)_softdevice.hex 0\nr\ng\nexit\n" > $(BUILDDIR)/flash.softdevice.jlink
+ $(JLINK) $(JLINK_COMMON_OPTS) $(BUILDDIR)/flash.softdevice.jlink
+endif
+
+ifneq ($(JLINK_ERASE_ALL),)
+jlink-erase-all:
+ printf "$(JLINK_ERASE_ALL)\nr\nexit\n" > $(BUILDDIR)/erase-all.jlink
+ $(JLINK) $(JLINK_COMMON_OPTS) $(BUILDDIR)/erase-all.jlink
+endif
+
+jlink-reset:
+ printf "r\nexit\n" > $(BUILDDIR)/reset.jlink
+ $(JLINK) $(JLINK_COMMON_OPTS) $(BUILDDIR)/reset.jlink
+
+jlink-debug-server:
+ $(JLINK_GDB_SERVER) $(JLINK_COMMON_OPTS) -port $(JLINK_GDB_PORT)
+
+.PHONY: jlink-flash jlink-flash-softdevice jlink-erase-all jlink-reset jlink-debug-server