-
Notifications
You must be signed in to change notification settings - Fork 20
/
fw_build.sh
219 lines (195 loc) · 9.88 KB
/
fw_build.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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/bin/bash
# This is a script to build the firmware for the ESP32 PrusaConnectCam project.
# Thi script is created by Miroslav Pivovarsky ([email protected])
# The script is provided as-is without any warranty.
# The script is free to use and modify.
# Version: 1.0
#
# The script builds the firmware for the following boards:
# 1. Ai Thinker ESP32-CAM
# 2. ESP32 Wrover Dev
# 3. ESP32-S3-EYE 2.2
#
# The script compiles the firmware for each board and creates a zip file with the compiled firmware.
# The zip file contains the firmware binary and other files generated during the compilation.
#
# The script uses the arduino-cli tool to compile the firmware.
# The arduino-cli tool must be installed before running this script.
#
# The script assumes the following directory structure:
# ESP32_PrusaConnectCam/
# ├── arduino-cli
# ├── ESP32_PrusaConnectCam.ino
# ├── mcu_cfg.h
# ├── ...
# ├── libraries/
# │ ├── zip/
# │ │ ├── AsyncTCP-3.1.4.zip
# │ │ └── ESPAsyncWebServer-2.10.8.zip
# ├── build/
# │ ├── output/
# │ ├── esp32-cam/
# │ ├── esp32-wrover-dev/
# │ └── esp32-s3-eye-22/
#
# The script creates the following files:
# build/
# ├── output/
# │ ├── ESP32_PrusaConnectCam.ino.bin
# │ ├── ESP32_WROVERDEV_PrusaConnectCam.ino.bin
# │ ├── ESP32S3_EYE22_PrusaConnectCam.ino.bin
# | ├── esp32-cam.zip
# | ├── esp32-wrover-dev.zip
# | ├── esp32-s3-eye-22.zip
#
# The script assumes the following libraries are installed:
# 1. ArduinoJson
# 2. ArduinoUniqueID
# 3. AsyncTCP-3.1.4
# 4. ESPAsyncWebServer-2.10.8
#
# The script assumes the ESP32 core is installed:
# 1. esp32:esp32
# ---------------------------------------------
# Setup Instructions:
# Before running this script, ensure the following steps have been completed:
# 1. Download arduino-cli:
# wget https://github.com/arduino/arduino-cli/releases/download/v1.0.1/arduino-cli_1.0.1_Linux_64bit.tar.gz
# 2. Extract the downloaded archive:
# tar -zxvf arduino-cli_1.0.1_Linux_64bit.tar.gz
# 3. Install pip3:
# sudo apt-get install pip3
# 4. Install pyserial using pip3:
# pip3 install pyserial
#
# 5. Initialize arduino-cli configuration:
# ./arduino-cli config init
# 6. Edit the arduino-cli.yaml configuration file (e.g., using nano):
# nano /home/miro/.arduino15/arduino-cli.yaml
# Add the following lines:
# board_manager:
# additional_urls:
# - https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
# library:
# enable_unsafe_install: true
#
# 7. Check installed libraries:
# ./arduino-cli lib list
# 8. Install necessary libraries:
# ./arduino-cli lib install ArduinoJson
# ./arduino-cli lib install ArduinoUniqueID
# ./arduino-cli lib install DHTNEW
# ./arduino-cli lib install --zip-path ../libraries/zip/AsyncTCP-3.1.4.zip
# ./arduino-cli lib install --zip-path ../libraries/zip/ESPAsyncWebServer-2.10.8.zip
# Check installed libraries again:
# ./arduino-cli lib list
#
# 9. Install the ESP32 core:
# ./arduino-cli core install esp32:esp32
# ---------------------------------------------
set -e
if [ -d "build" ]; then
rm -rf build
fi
cd ESP32_PrusaConnectCam
if [ ! -f arduino-cli ]; then
echo "arduino-cli not found. Please download arduino-cli and place it in the same folder as this script."
exit 1
fi
mkdir -p ../build/output
build_start=`date`
# ----------------- ESP32-CAM -----------------
# enable and build Ai Thinker board
echo "----------------------------------------------"
echo "Building Ai Thinker board"
mkdir -p ../build/esp32-cam
sed -i 's/#define \(AI_THINKER_ESP32_CAM\|ESP32_WROVER_DEV\|CAMERA_MODEL_ESP32_S3_DEV_CAM\|CAMERA_MODEL_ESP32_S3_EYE_2_2\|CAMERA_MODEL_XIAO_ESP32_S3_CAM\|CAMERA_MODEL_ESP32_S3_CAM\) .*/#define \1 false/' mcu_cfg.h && sed -i 's/#define AI_THINKER_ESP32_CAM false/#define AI_THINKER_ESP32_CAM true/' mcu_cfg.h
./arduino-cli compile -v -b esp32:esp32:esp32cam:CPUFreq=240,FlashFreq=80,FlashMode=dio,PartitionScheme=min_spiffs,DebugLevel=none,EraseFlash=none --output-dir ../build/esp32-cam
if [ $? -ne 0 ]; then
echo "Build failed, exiting."
exit 1
fi
rm -f ../build/esp32-cam/ESP32_PrusaConnectCam.ino.elf
rm -f ../build/esp32-cam/ESP32_PrusaConnectCam.ino.map
rm -f ../build/esp32-cam/ESP32_PrusaConnectCam.ino.merged.bin
cp ../build/esp32-cam/ESP32_PrusaConnectCam.ino.bin ../build/output/ESP32_PrusaConnectCam.ino.bin
cd ../build/esp32-cam && zip -r ../esp32-cam.zip . && cd -
mv ../build/esp32-cam.zip ../build/output/
# ----------------- ESP32-WROVER-DEV -----------------
# enable and build ESP32 Wrover Dev board
echo "----------------------------------------------"
echo "Building ESP32 Wrover Dev board"
mkdir ../build/esp32-wrover-dev
sed -i 's/#define \(AI_THINKER_ESP32_CAM\|ESP32_WROVER_DEV\|CAMERA_MODEL_ESP32_S3_DEV_CAM\|CAMERA_MODEL_ESP32_S3_EYE_2_2\|CAMERA_MODEL_XIAO_ESP32_S3_CAM\|CAMERA_MODEL_ESP32_S3_CAM\) .*/#define \1 false/' mcu_cfg.h && sed -i 's/#define ESP32_WROVER_DEV false/#define ESP32_WROVER_DEV true/' mcu_cfg.h
./arduino-cli compile -v -b esp32:esp32:esp32wrover:FlashFreq=80,FlashMode=dio,PartitionScheme=min_spiffs,DebugLevel=none,EraseFlash=none --output-dir ../build/esp32-wrover-dev
if [ $? -ne 0 ]; then
echo "Build failed, exiting."
exit 1
fi
rm -f ../build/esp32-wrover-dev/ESP32_PrusaConnectCam.ino.elf
rm -f ../build/esp32-wrover-dev/ESP32_PrusaConnectCam.ino.map
rm -f ../build/esp32-wrover-dev/ESP32_PrusaConnectCam.ino.merged.bin
cp ../build/esp32-wrover-dev/ESP32_PrusaConnectCam.ino.bin ../build/output/ESP32_WROVERDEV.bin
cd ../build/esp32-wrover-dev && zip -r ../esp32-wrover-dev.zip . && cd -
mv ../build/esp32-wrover-dev.zip ../build/output/
# ----------------- ESP32-S3-CAM EYE 2.2 -----------------
# build ESP32-S3-EYE 2.2 board
echo "----------------------------------------------"
echo "Building ESP32-S3-EYE 2.2 board"
mkdir ../build/esp32-s3-eye-22
sed -i 's/#define \(AI_THINKER_ESP32_CAM\|ESP32_WROVER_DEV\|CAMERA_MODEL_ESP32_S3_DEV_CAM\|CAMERA_MODEL_ESP32_S3_EYE_2_2\|CAMERA_MODEL_XIAO_ESP32_S3_CAM\|CAMERA_MODEL_ESP32_S3_CAM\) .*/#define \1 false/' mcu_cfg.h && sed -i 's/#define CAMERA_MODEL_ESP32_S3_EYE_2_2 false/#define CAMERA_MODEL_ESP32_S3_EYE_2_2 true/' mcu_cfg.h
./arduino-cli compile -v -b esp32:esp32:esp32s3:USBMode=hwcdc,CDCOnBoot=cdc,MSCOnBoot=default,DFUOnBoot=default,UploadMode=cdc,CPUFreq=240,FlashMode=dio,FlashSize=8M,PartitionScheme=min_spiffs,DebugLevel=none,PSRAM=opi,LoopCore=0,EventsCore=0,EraseFlash=none,JTAGAdapter=default,ZigbeeMode=default --output-dir ../build/esp32-s3-eye-22
if [ $? -ne 0 ]; then
echo "Build failed, exiting."
exit 1
fi
rm -f ../build/esp32-s3-eye-22/ESP32_PrusaConnectCam.ino.elf
rm -f ../build/esp32-s3-eye-22/ESP32_PrusaConnectCam.ino.map
rm -f ../build/esp32-s3-eye-22/ESP32_PrusaConnectCam.ino.merged.bin
cp ../build/esp32-s3-eye-22/ESP32_PrusaConnectCam.ino.bin ../build/output/ESP32S3_EYE22.bin
cd ../build/esp32-s3-eye-22 && zip -r ../esp32-s3-eye-22.zip . && cd -
mv ../build/esp32-s3-eye-22.zip ../build/output/
# ----------------- XIAO ESP32-S3 Sense -----------------
# build XIAO ESP32-S3 Sense
echo "----------------------------------------------"
echo "Building XIAO ESP32-S3 Sense"
mkdir ../build/xiao-esp32-s3
sed -i 's/#define \(AI_THINKER_ESP32_CAM\|ESP32_WROVER_DEV\|CAMERA_MODEL_ESP32_S3_DEV_CAM\|CAMERA_MODEL_ESP32_S3_EYE_2_2\|CAMERA_MODEL_XIAO_ESP32_S3_CAM\|CAMERA_MODEL_ESP32_S3_CAM\) .*/#define \1 false/' mcu_cfg.h && sed -i 's/#define CAMERA_MODEL_XIAO_ESP32_S3_CAM false/#define CAMERA_MODEL_XIAO_ESP32_S3_CAM true/' mcu_cfg.h
./arduino-cli compile -v -b esp32:esp32:XIAO_ESP32S3:USBMode=hwcdc,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,CPUFreq=160,FlashMode=qio,FlashSize=8M,PartitionScheme=default_8MB,DebugLevel=none,PSRAM=opi,LoopCore=1,EventsCore=1,EraseFlash=none,JTAGAdapter=default --output-dir ../build/xiao-esp32-s3
if [ $? -ne 0 ]; then
echo "Build failed, exiting."
exit 1
fi
rm -f ../build/xiao-esp32-s3/ESP32_PrusaConnectCam.ino.elf
rm -f ../build/xiao-esp32-s3/ESP32_PrusaConnectCam.ino.map
rm -f ../build/xiao-esp32-s3/ESP32_PrusaConnectCam.ino.merged.bin
cp ../build/xiao-esp32-s3/ESP32_PrusaConnectCam.ino.bin ../build/output/XIAO_ESP32S3.bin
cd ../build/xiao-esp32-s3 && zip -r ../xiao-esp32-s3.zip . && cd -
mv ../build/xiao-esp32-s3.zip ../build/output/
# ----------------- ESP32-S3-CAM -----------------
# build ESP32-S3-CAM
echo "----------------------------------------------"
echo "Building ESP32-S3-CAM"
mkdir ../build/esp32-s3-cam
sed -i 's/#define \(AI_THINKER_ESP32_CAM\|ESP32_WROVER_DEV\|CAMERA_MODEL_ESP32_S3_DEV_CAM\|CAMERA_MODEL_ESP32_S3_EYE_2_2\|CAMERA_MODEL_XIAO_ESP32_S3_CAM\|CAMERA_MODEL_ESP32_S3_CAM\) .*/#define \1 false/' mcu_cfg.h && sed -i 's/#define CAMERA_MODEL_ESP32_S3_CAM false/#define CAMERA_MODEL_ESP32_S3_CAM true/' mcu_cfg.h
./arduino-cli compile -v -b esp32:esp32:esp32s3:USBMode=hwcdc,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,CPUFreq=240,FlashMode=dio,FlashSize=16M,PartitionScheme=min_spiffs,DebugLevel=none,PSRAM=opi,LoopCore=0,EventsCore=0,EraseFlash=none,JTAGAdapter=default,ZigbeeMode=default --output-dir ../build/esp32-s3-cam
if [ $? -ne 0 ]; then
echo "Build failed, exiting."
exit 1
fi
rm -f ../build/esp32-s3-cam/ESP32_PrusaConnectCam.ino.elf
rm -f ../build/esp32-s3-cam/ESP32_PrusaConnectCam.ino.map
rm -f ../build/esp32-s3-cam/ESP32_PrusaConnectCam.ino.merged.bin
cp ../build/esp32-s3-cam/ESP32_PrusaConnectCam.ino.bin ../build/output/esp32-s3-cam.bin
cd ../build/esp32-s3-cam && zip -r ../esp32-s3-cam.zip . && cd -
mv ../build/esp32-s3-cam.zip ../build/output/
# --------------------------------------------------------
# Print build completion message
echo "----------------------------------------------"
echo "Build completed. Output files are in the output folder."
echo "Start build: $build_start"
echo "End build: `date`"
echo ""
ls -lah ../build/output/
exit 0
# EOF