summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@yeah.nah.nz>2019-12-28 17:32:05 +1300
committerDavid Phillips <david@yeah.nah.nz>2019-12-28 17:32:05 +1300
commit13ec28b4bd88099c051f87a5ef59a46aa41a740b (patch)
tree4da140fa5f769746c0d742aad465f1ea1f6e5fb6
parent05f9aaab9f6f20a32eb12a2abc89efe1893dec16 (diff)
downloadpi-zero-jtag-13ec28b4bd88099c051f87a5ef59a46aa41a740b.tar.xz
Add script for downloading U-Boot binaries to RAM
-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"