forked from kike-canaries/canairio_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·184 lines (158 loc) · 4.27 KB
/
build
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
SRC_REV=`cat platformio.ini | grep revision | awk '{print $3}'`
SRC_VER=`cat platformio.ini | grep version | awk '{print $3}'`
TARGET=`cat platformio.ini | grep target | awk '{print $3}'`
DATE=`date +%Y%m%d`
OUTDIR=".pio/build"
RELDIR="releases"
BINDIR="binaries"
MANIFEST="manifest"
DEFAULT="TTGO_T7"
INSDIR=$RELDIR/installer/canairio_installer
showHelp () {
echo ""
echo "************************************************"
echo "** Build release flavor or installer package **"
echo "************************************************"
echo ""
echo "Usage: ./build [board|all|installer|publish|help|print]"
echo ""
echo "example: ./build all"
echo "example: ./build TTGO_T7"
echo "example: ./build installer"
echo ""
echo "Supported boards: "
echo "TTGO_T7, WEMOSOLED, HELTEC, TTGO_TQ, ESP32DEVKIT, ESP32PICOD4, M5PICOD4"
echo ""
echo "Build installer option will make a installer package for Linux"
echo "with OTA support and USB support"
echo ""
}
updateInstallerBinaries () {
echo ""
echo "***********************************************"
echo "** Update installer binaries.."
echo "***********************************************"
echo ""
cp $OUTDIR/$DEFAULT/partitions.bin $INSDIR/system/
cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin $INSDIR/system/
cp ~/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader_dio_40m.bin $INSDIR/system/
cp ~/.platformio/packages/tool-esptoolpy/esptool.py $INSDIR/system/
cp ~/.platformio/packages/framework-arduinoespressif32/tools/espota.py $INSDIR/system/
chmod 755 $INSDIR/install.sh
}
updateFlavorBinaries() {
rm -f $INSDIR/*.bin
rm -f $INSDIR/*.py # old installer
cp $RELDIR/$BINDIR/*/*${SRC_REV}.bin $INSDIR/
}
clean () {
rm -rf $RELDIR/$BINDIR
rm -rf $RELDIR/$MANIFEST
rm -f $INSDIR/*.bin
rm -f $INSDIR/*.py # old installer
}
build () {
pio run -s -e $1 -t clean
echo ""
echo "***********************************************"
echo "** Building $1"
echo "***********************************************"
echo ""
pio run -s -e $1
echo ""
echo "***********************************************"
echo "** Firmware $1 output:"
echo -n "** MD5:"
FIRMDIR=$RELDIR/$BINDIR/$1
mkdir -p $FIRMDIR
cp $OUTDIR/$1/firmware.bin $FIRMDIR/canairio_${1}_rev${SRC_REV}.bin
md5sum $FIRMDIR/canairio_${1}_rev${SRC_REV}.bin
echo "***********************************************"
echo ""
}
buildInstaller () {
echo ""
mkdir -p $INSDIR/system
updateInstallerBinaries
updateFlavorBinaries
printOutput
cd $INSDIR/..
rm -f canairio_${TARGET}_rev${SRC_REV}_${DATE}.zip
zip -r canairio_${TARGET}_rev${SRC_REV}_${DATE}.zip canairio_installer
echo ""
du -hs canairio_${TARGET}_rev${SRC_REV}_${DATE}.zip
echo ""
}
publish_release () {
cd $INSDIR/..
COMMIT_LOG=`git log -1 --format='%ci %H %s'`
github-release upload --owner kike-canaries --repo canairio_firmware --tag "rev${SRC_REV}" --release-name "rev${SRC_REV} v${SRC_VER}" --body "${COMMIT_LOG}" canairio_${TARGET}_rev${SRC_REV}_${DATE}.zip
}
publish_release_ota () {
cd $INSDIR
scp -P $canairio_port *.bin $canairio_host:$canairio_target/$TARGET
scp -P $canairio_port ../../$MANIFEST/$TARGET/*.json $canairio_host:$canairio_target/$TARGET
}
printOutput () {
echo ""
mkdir -p $INSDIR
FIRMDIR=$RELDIR/$BINDIR
rm -f $INSDIR/md5output.txt
touch $INSDIR/md5output.txt
cd $FIRMDIR
for flavor in *; do
MD5FLAVOR=`md5sum $flavor/canairio_${flavor}_rev${SRC_REV}.bin`
echo $MD5FLAVOR >> ../../$INSDIR/md5output.txt
done
cat ../../$INSDIR/md5output.txt
cd ../..
echo ""
}
if [ "$1" = "" ]; then
showHelp
else
case "$1" in
clean)
clean
;;
installer)
buildInstaller
;;
help)
showHelp
;;
--help)
showHelp
;;
-help)
showHelp
;;
print)
printOutput
;;
all)
build TTGO_T7
build WEMOSOLED
build HELTEC
build TTGO_TQ
build ESP32DEVKIT
build TTGO_TDISPLAY
build ESP32PICOD4
build M5STICKCPLUS
build M5ATOM
build M5PICOD4
printOutput
;;
publish)
publish_release
;;
otatrigger)
publish_release_ota
;;
*)
build $1
;;
esac
fi
exit 0