summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNathaniel Graff <nathaniel.graff@sifive.com>2019-03-06 21:41:15 +0000
committerGitHub <noreply@github.com>2019-03-06 21:41:15 +0000
commit87f176dfbbbf1a64bd3e034713434393a0f3518b (patch)
tree83596e3e6ed4d1fa832f6771cdee2ee35c070b95 /scripts
parentc71689996d85011f3d493b8cbe75e1379bdbc932 (diff)
parent6aab6996dbd890c5788bf4e330454a3490268174 (diff)
Merge pull request #193 from sifive/hifive1-revb
Add support for Segger J-Link OB to HiFive1 Rev B
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/debug13
-rw-r--r--scripts/standalone.mk16
-rwxr-xr-xscripts/upload17
3 files changed, 43 insertions, 3 deletions
diff --git a/scripts/debug b/scripts/debug
index d02c42c..87068c5 100755
--- a/scripts/debug
+++ b/scripts/debug
@@ -5,6 +5,7 @@ set -o pipefail
unset elf
unset cfg
+unset jlink
unset openocd
unset gdb
while [[ "$1" != "" ]]
@@ -13,13 +14,14 @@ do
in
--elf) elf="$2"; shift 2;;
--openocd) openocd="$2"; shift 2;;
+ --jlink) jlink="$2"; shift 2;;
--openocd-config) cfg="$2"; shift 2;;
--gdb) gdb="$2"; shift 2;;
*) echo "$0: Unknown argument $1"; exit 1;;
esac
done
-if [[ "$elf" == "" ]]
+if [ "$elf" == "" ]
then
echo "$0: --elf is required" >&2
exit 1
@@ -27,8 +29,17 @@ fi
export GDB_PORT=3333
+if [ "$jlink" != "" ]
+then
+
+$jlink -device RISC-V -port $GDB_PORT &
+
+else
+
$openocd -f $cfg &
+fi
+
$gdb $elf -ex "set remotetimeout 240" -ex "target extended-remote localhost:${GDB_PORT}"
kill %1
diff --git a/scripts/standalone.mk b/scripts/standalone.mk
index e80e0c1..921d6a1 100644
--- a/scripts/standalone.mk
+++ b/scripts/standalone.mk
@@ -54,6 +54,7 @@ ifeq ($(RISCV_PATH),)
RISCV_GCC := $(CROSS_COMPILE)-gcc
RISCV_GXX := $(CROSS_COMPILE)-g++
RISCV_OBJDUMP := $(CROSS_COMPILE)-objdump
+RISCV_OBJCOPY := $(CROSS_COMPILE)-objcopy
RISCV_GDB := $(CROSS_COMPILE)-gdb
RISCV_AR := $(CROSS_COMPILE)-ar
RISCV_SIZE := $(CROSS_COMPILE)-size
@@ -61,12 +62,16 @@ else
RISCV_GCC := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-gcc)
RISCV_GXX := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-g++)
RISCV_OBJDUMP := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-objdump)
+RISCV_OBJCOPY := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-objcopy)
RISCV_GDB := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-gdb)
RISCV_AR := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-ar)
RISCV_SIZE := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-size)
PATH := $(abspath $(RISCV_PATH)/bin):$(PATH)
endif
+SEGGER_JLINK_EXE := JLinkExe
+SEGGER_JLINK_GDB_SERVER := JLinkGDBServer
+
#############################################################
# Software
#############################################################
@@ -84,6 +89,9 @@ software: $(PROGRAM_ELF)
ifneq ($(COREIP_MEM_WIDTH),)
software: $(PROGRAM_HEX)
endif
+ifneq ($(SEGGER_JLINK_OB),)
+software: $(PROGRAM_HEX)
+endif
PROGRAM_SRCS = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*.h) $(wildcard $(SRC_DIR)/*.S)
@@ -104,6 +112,14 @@ $(PROGRAM_ELF): \
$(RISCV_SIZE) $@
+ifneq ($(SEGGER_JLINK_OB),)
+# If we're using Segger J-Link OB, use objcopy to create an Intel hex file for programming
+$(PROGRAM_HEX): \
+ $(RISCV_OBJCOPY) \
+ $(PROGRAM_ELF)
+ $< -O ihex $(PROGRAM_ELF) $@
+endif
+
.PHONY: clean-software
clean-software:
$(MAKE) -C $(SRC_DIR) clean
diff --git a/scripts/upload b/scripts/upload
index 66e9ed8..a52fc0a 100755
--- a/scripts/upload
+++ b/scripts/upload
@@ -4,31 +4,44 @@ set -e
set -o pipefail
unset elf
+unset hex
unset cfg
unset openocd
+unset jlink
unset gdb
while [[ "$1" != "" ]]
do
case "$1"
in
--elf) elf="$2"; shift 2;;
+ --hex) hex="$2"; shift 2;;
--openocd) openocd="$2"; shift 2;;
--openocd-config) cfg="$2"; shift 2;;
+ --jlink) jlink="$2"; shift 2;;
--gdb) gdb="$2"; shift 2;;
*) echo "$0: Unknown argument $1"; exit 1;;
esac
done
-if [[ "$elf" == "" ]]
+if [ "$elf" == "" -a "$hex" == "" ]
then
- echo "$0: --elf is required" >&2
+ echo "$0: --elf or --hex is required" >&2
exit 1
fi
export GDB_PORT=3333
+if [ "$jlink" != "" ]
+then
+
+echo -e "loadfile $hex\nrnh\nexit" | $jlink -device FE310 -if JTAG -speed 4000 -jtagconf -1,-1 -autoconnect 1
+
+else
+
$openocd -f $cfg &
$gdb $elf --batch -ex "set remotetimeout 240" -ex "target extended-remote localhost:${GDB_PORT}" -ex "monitor reset halt" -ex "monitor flash protect 0 64 last off" -ex "load" -ex "monitor resume" -ex "monitor shutdown" -ex "quit"
kill %1
+
+fi