1#!/usr/bin/env bash
2
3DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4
5set -x
6set -e
7
8export PROJECT=sifive-e-test
9TARGET=`pwd`/build-${PROJECT}/lk.elf
10
11$DIR/make-parallel
12
13SDK_DIR=${HOME}/src/freedom-e-sdk
14OPENOCD_DIR=${SDK_DIR}/riscv-openocd-0.10.0-2020.04.6-x86_64-linux-ubuntu14/bin
15
16${OPENOCD_DIR}/openocd -f ${SDK_DIR}/bsp/sifive-hifive1/openocd.cfg &
17
18${SDK_DIR}/riscv64-unknown-elf-gcc-8.3.0-2020.04.1-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gdb \
19    ${TARGET} \
20    --batch -ex "set remotetimeout 240" \
21    -ex "target extended-remote localhost:3333" \
22    -ex "monitor reset halt" \
23    -ex "monitor flash protect 0 64 last off" \
24    -ex "load" \
25    -ex "monitor resume" \
26    -ex "monitor shutdown" \
27    -ex "quit"
28
29kill %1
30
31