Merge pull request #32 from sdalu/flash

Ease dev with flash/debug target helper
This commit is contained in:
Fabio Utzig 2016-02-14 20:59:54 -02:00
commit 97bf343a8b
3 changed files with 52 additions and 0 deletions

View File

@ -3,3 +3,9 @@ BOARDSRC = ${CHIBIOS_CONTRIB}/os/hal/boards/NRF51-DK/board.c
# Required include directories
BOARDINC = ${CHIBIOS_CONTRIB}/os/hal/boards/NRF51-DK
# Flash
JLINK_DEVICE = nrf51422
JLINK_PRE_FLASH = w4 4001e504 1
JLINK_ERASE_ALL = w4 4001e504 2\nw4 4001e50c 1\nsleep 100

13
os/various/gdb.mk Normal file
View File

@ -0,0 +1,13 @@
GDB ?= arm-none-eabi-gdb
GDB_PROGRAM ?= $(BUILDDIR)/$(PROJECT).elf
GDB_PORT ?= 2331
GDB_START_ADDRESS ?= 0
GDB_BREAK ?= main
gdb-debug:
printf "target remote localhost:$(GDB_PORT)\nmem $(GDB_START_ADDRESS) 0\nbreak $(GDB_BREAK)\nload\nmon reset\ncontinue" > .gdbinit
$(GDB) --command=.gdbinit $(GDB_PROGRAM)
.PHONY: gdb-debug

33
os/various/jlink.mk Normal file
View File

@ -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