forked from emmebrusa/TSDZ2-Smart-EBike-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
compile_and_flash_20.sh
62 lines (51 loc) · 1.31 KB
/
compile_and_flash_20.sh
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
#!/bin/bash
set -e
version="20.1C.6-0"
settings_date=$1
release_folder=$(pwd)/releases
backup_folder=$(pwd)/releases/backup
cd src
# Clean existing
rm -rf main.hex || true
make clean || true
# Build firmware
echo Build started...
make
# Save new firmware
echo Copying firmware to release folder.
echo $release_folder/TSDZ2-$version-$settings_date.hex
mkdir -p "$release_folder"
yes | cp -rf ../bin/main.hex "$release_folder/TSDZ2-$version-$settings_date.hex"
backup=no
while true; do
read -p "Do you want to backup the firmware ? [y/N]" yn
case $yn in
y ) backup=yes; break;;
n ) break;;
* ) break;;
esac
done
# Backup firmware
if [ "$backup" = "yes" ]; then
echo Backup current firmware to $backup_folder/TSDZ_orig_opt-$version-$settings_date.bin
mkdir -p $backup_folder
make backup
yes | cp -rf ../bin/TSDZ_orig_opt.bin $backup_folder/TSDZ_orig_opt-$version-$settings_date.bin
yes | cp -rf ../bin/TSDZ_orig.bin $backup_folder/TSDZ_orig-$version-$settings_date.bin
yes | cp -rf ../bin/TSDZ_orig_eeprom.bin $backup_folder/TSDZ_orig_eeprom-$version-$settings_date.bin
fi
flash=yes
while true; do
read -p "Do you want to flash the motor ? [Y/n]" yn
case $yn in
y ) break;;
n ) flash=no; break;;
* ) break;;
esac
done
# Flash new firmware
if [ "$flash" = "yes" ]; then
make clear_eeprom
make flash
fi
echo All done !