summaryrefslogtreecommitdiff
path: root/load-u-boot.sh
blob: 6284e8b12f7c130da2c2fc0ea53444673fe78c47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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"