-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstm32
executable file
·73 lines (62 loc) · 941 Bytes
/
stm32
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
check_port() {
nc -z localhost 4444
R=$?
if [[ $R -eq 1 ]];then
echo "ERROR: OpenOCD is not running"
exit 1
fi
}
burn() {
check_port
if [[ "$1" == "" ]];then
echo "Usage: stm32 burn file_name"
exit
fi
file=$PWD/$1
if [[ ! -r "$file" ]];then
echo "Binary file $1 cannot be opened."
exit 1
fi
nc localhost 4444 <<EOF
halt
poll
flash probe 0
stm32f1x mass_erase 0
flash write_bank 0 "$file" 0
reset halt
exit
EOF
}
reset() {
check_port
nc localhost 4444 <<EOF
reset
exit
EOF
}
gdb() {
check_port
if [[ "$1" == "" ]];then
echo "Usage: stm32 gdb file_name"
exit
fi
if [[ ! -r "$1" ]];then
echo "Cannot find ELF $1"
exit 1
fi
arm-none-eabi-gdbtui --eval-command="target remote localhost:3333" "$1"
}
case "$1" in
gdb)
gdb "$2"
;;
burn)
burn "$2"
;;
reset)
reset
;;
*)
echo $"Usage: $0 jlink|gdb|burn|reset"
esac