-
Notifications
You must be signed in to change notification settings - Fork 7
/
k210-run
executable file
·55 lines (40 loc) · 980 Bytes
/
k210-run
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
set -e
OPTS="--sram"
if [ "$1" == "--ram" ]; then
OPTS="--sram"
shift
fi
if [ "$1" == "--flash" ]; then
OPTS=""
shift
fi
ELF="$1"
if [ ! -e "$ELF" ]; then
echo "Can't find input ELF file"
echo "Usage: $0 [--ram|--flash] path/to/elf"
exit 1
fi
FW="$(dirname "$ELF")/firmware.bin"
riscv64-unknown-elf-objcopy -O binary "$ELF" "$FW"
dir=$(dirname $(readlink -f $0))
declare -a known_serial_ids
# Sipeed MAIX Dock board
known_serial_ids[0]=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
# Sipeed MAIX bit, CH340 based, board
known_serial_ids[1]=/dev/serial/by-id/usb-Kongou_Hikari_Sipeed-Debug_A1525D0091-if00-port0
SERIAL_DEV=""
for serial_dev in "${known_serial_ids[@]}"
do
if [ -e "$serial_dev" ]
then
SERIAL_DEV="$serial_dev"
break
fi
done
if [[ -z "$SERIAL_DEV" ]]
then
echo "Can't find matching serial device"
exit 1
fi
"$dir/kflash.py" --port "$SERIAL_DEV" $OPTS --terminal --verbose "$FW"