-
Notifications
You must be signed in to change notification settings - Fork 83
/
upload_fw_pi
executable file
·41 lines (28 loc) · 916 Bytes
/
upload_fw_pi
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
#!/bin/bash
# Exit on error
set -e
if [[ $1 == @(vcc|tero|rise_ubx|drangen|rise_f9) ]]; then
FW=fw_$1.bin
else
echo No valid firmware specified. Please use
echo ./upload_fw [fw]
echo where [fw] can be vcc, tero, rise_ubx, rise_f9 or drangen
exit 1
fi
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
FWPATH="Embedded/RC_Controller/precompiled"
CFG=$DIR/oo_rpi3.cfg
PI_VERSION=""
while IFS= read -r -d '' substring || [[ $substring ]]; do
PI_VERSION+="$substring"
done </proc/device-tree/model
if [[ $PI_VERSION == 'Raspberry Pi 4'* ]]; then
CFG=$DIR/oo_rpi4.cfg
fi
#echo $CFG
#echo $PI_VERSION
#exit
cd $DIR
#git pull
cd $FWPATH
sudo openocd -f $CFG -c "transport select swd" -c "set CHIPNAME stm32f4x" -f "target/stm32f4x.cfg" -c "reset_config srst_nogate" -c "adapter_nsrst_delay 100" -c "adapter_nsrst_assert_width 100" -c "program $FW verify reset exit 0x08000000"