summaryrefslogtreecommitdiff
path: root/fw/fe310/bsp/upload
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-08-05 03:39:22 +0200
committerUros Majstorovic <majstor@majstor.org>2020-08-05 03:39:22 +0200
commitcf7c06297d04bade9cd04c056f9ed510e64dd7bd (patch)
treea3b8cc23574b98e10874b51d33c9fe1bfc012663 /fw/fe310/bsp/upload
parent5cd610a07468137066ea4daa5176c3e7045113b0 (diff)
code -> fw
Diffstat (limited to 'fw/fe310/bsp/upload')
-rwxr-xr-xfw/fe310/bsp/upload47
1 files changed, 47 insertions, 0 deletions
diff --git a/fw/fe310/bsp/upload b/fw/fe310/bsp/upload
new file mode 100755
index 0000000..a52fc0a
--- /dev/null
+++ b/fw/fe310/bsp/upload
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+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" == "" -a "$hex" == "" ]
+then
+ 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