summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xload-u-boot.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/load-u-boot.sh b/load-u-boot.sh
new file mode 100755
index 0000000..6284e8b
--- /dev/null
+++ b/load-u-boot.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+# load-u-boot.sh - a simple script that wraps GDB in order to download a U-Boot
+# image from a host computer into a target's RAM over JTAG
+# using an OpenOCD GDB server.
+
+# Parameters/syntax:
+# ./load-u-boot.sh [binary [location]]
+# * binary: file to download
+# * location: memory address on the target to start loading binary to
+# * GDB env var controls which GDB to use
+
+[ -z "$GDB" ] && GDB=armv8l-linux-gnueabihf-gdb
+binary=${1:-/tmp/u-boot.bin}
+location=${2:-0x8000}
+
+trap clean EXIT
+script=$(mktemp)
+
+clean(){
+ rm -f "$script"
+}
+
+cat > "$script" <<EOF
+set confirm off
+target remote :3333
+mon halt
+mon load_image "$binary" "$location" bin
+mon verify_image "$binary" "$location"
+mon resume $location
+quit
+EOF
+
+"$GDB" -x "$script"