diff --git a/boards/pca10000/Makefile.include b/boards/pca10000/Makefile.include index f0928bfd622fc82ea1c7013d59768dcf23cc0975..ee20cc6263da9fba6c23d910e0cfde8f05cae500 100644 --- a/boards/pca10000/Makefile.include +++ b/boards/pca10000/Makefile.include @@ -23,8 +23,10 @@ export LINK = $(PREFIX)gcc export SIZE = $(PREFIX)size export OBJCOPY = $(PREFIX)objcopy export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm -export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh $(BINDIR) $(RIOTBASE) $(APPLICATION) $(BOARD) -export HEXFILE = $(ELFFILE:.elf=.bin) +export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh +export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh +export DEBUGSERVER = JLinkGDBServer -device nrf51822 -if SWD +export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh # define build specific options CPU_USAGE = -mcpu=cortex-m0 @@ -36,7 +38,11 @@ export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endi # $(LINKERSCRIPT) is specified in cpu/Makefile.include export LINKFLAGS += -T$(LINKERSCRIPT) export OFLAGS = -O binary +export HEXFILE = $(ELFFILE:.elf=.bin) export TERMFLAGS = -p +export FFLAGS = $(BINDIR) $(HEXFILE) +export DEBUGGER_FLAGS = $(BINDIR) $(ELFFILE) +export RESET_FLAGS = $(BINDIR) # use the nano-specs of the NewLib when available ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) diff --git a/boards/pca10000/dist/debug.sh b/boards/pca10000/dist/debug.sh new file mode 100755 index 0000000000000000000000000000000000000000..f77b5d2e630a0410f703d39c59a0fc364e59ada9 --- /dev/null +++ b/boards/pca10000/dist/debug.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Start in-circuit debugging on this board: this script starts up the GDB +# client and connects to a GDB server. +# +# Start the GDB server first using the 'make debugserver' target + +BINDIR=$1 +ELFFILE=$2 + +# write GDB config file +echo "target extended-remote 127.0.0.1:2331" > $BINDIR/gdb.cfg + +# run GDB +arm-none-eabi-gdb -tui -command=$BINDIR/gdb.cfg $ELFFILE diff --git a/boards/pca10000/dist/flash.sh b/boards/pca10000/dist/flash.sh index 07b98759e28edae81fe23bf8ecb61403072ce0bd..0f4bbb33c7d77f6e738c07b3e817b2f7c37e3177 100755 --- a/boards/pca10000/dist/flash.sh +++ b/boards/pca10000/dist/flash.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # This flash script dynamically generates a file with a set of commands which # have to be handed to the flashing script of SEGGER (JLinkExe >4.84). @@ -6,34 +6,20 @@ # latest .bin file to the board. # @author Timo Ziegler <timo.ziegler@fu-berlin.de> +# @author Hauke Petersen <hauke.petersen@fu-berlin.de> BINDIR=$1 -RIOTBASE=$2 -APPLICATION=$3 -BOARD=$4 +HEXFILE=$2 -if [[ $APPLICATION == test_* ]] -then - TYPE=tests -else - TYPE=examples -fi - -echo "log /dev/null" > $BINDIR/burn.seg -echo "device nrf51822" >> $BINDIR/burn.seg +# setup JLink command file +echo "device nrf51822" > $BINDIR/burn.seg echo "speed 1000" >> $BINDIR/burn.seg echo "w4 4001e504 1" >> $BINDIR/burn.seg -echo "loadbin $RIOTBASE/$TYPE/$APPLICATION/bin/$BOARD/$APPLICATION.bin 0" >> $BINDIR/burn.seg +echo "loadbin $HEXFILE 0" >> $BINDIR/burn.seg echo "r" >> $BINDIR/burn.seg echo "g" >> $BINDIR/burn.seg echo "exit" >> $BINDIR/burn.seg echo "" >> $BINDIR/burn.seg + +# flash new binary to the board JLinkExe < $BINDIR/burn.seg -if [ -f JLink.log ] -then - rm JLink.log -fi -if [ -f ~/JLink.log ] -then - rm ~/JLink.log -fi diff --git a/boards/pca10000/dist/reset.sh b/boards/pca10000/dist/reset.sh new file mode 100755 index 0000000000000000000000000000000000000000..509f127ea42beeaaf2e4316ab5e76e7be5e408a7 --- /dev/null +++ b/boards/pca10000/dist/reset.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# This script resets a nrf51822 target using JLink called +# with a pre-defined reset sequence. + +# @author Hauke Petersen <hauke.petersen@fu-berlin.de> + +BINDIR=$1 + +# create JLink command file for resetting the board +echo "device nrf51822" > $BINDIR/reset.seg +echo "r" >> $BINDIR/reset.seg +echo "g" >> $BINDIR/reset.seg +echo "exit" >> $BINDIR/reset.seg +echo " " >> $BINDIR/reset.seg + +# reset the board +JLinkExe < $BINDIR/reset.seg