-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetbuildsuffix
executable file
·282 lines (250 loc) · 9.06 KB
/
setbuildsuffix
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#!/bin/csh -f
if("$1" == "") then
echo "Specify suffix"
exit 1
endif
setenv BUILDSUFFIX "$1"
shift
setenv SDKCONFIG "sdkconfig"
if("$1" != "") setenv SDKCONFIG "$1"
if(! -e "$SDKCONFIG") then
echo "Missing $SDKCONFIG"
exit 0
endif
# The variants are per silicon, e.g. 8266, ESP32, ESP32S1, ESP32S2, ESP32S3, ESP32C3, ESP32H2 can all have different options
set add=()
set rem=()
set part=""
set sign=""
if(-e settings.def) then
set rem=($rem CONFIG_REVK_OLD_SETTINGS);
endif
if(-e betarelease) then
set add=($rem CONFIG_REVK_WEB_BETA);
else
set rem=($rem CONFIG_REVK_WEB_BETA);
endif
if(-e managed_components/espressif__led_strip) then
set add=($add CONFIG_REVK_LED_STRIP);
else
set rem=($rem CONFIG_REVK_LED_STRIP);
endif
if("$BUILDSUFFIX" =~ *-8266*) then
grep -q CONFIG_IDF_TARGET_ESP8266=y "$SDKCONFIG"
if($status) then
echo You need to manually set ESP8266 build environment
exit 1
endif
else
grep -q CONFIG_IDF_TARGET_ESP8266=y "$SDKCONFIG"
if(! $status) then
echo This build environment is for ESP8266, change to ESP32 based
exit 1
endif
endif
if("$BUILDSUFFIX" =~ *-8266*) then
if("$BUILDSUFFIX" =~ *-4M*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_PARTITION_TABLE_CUSTOM)
set rem=($rem CONFIG_ESPTOOLPY_FLASHSIZE_8MB)
set part="components/ESP32-RevK/partitions_4m-8266.csv"
else
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_PARTITION_TABLE_CUSTOM)
set rem=($rem CONFIG_ESPTOOLPY_FLASHSIZE_4MB)
set part="components/ESP32-RevK/partitions_8m-8266.csv"
endif
endif
if("$BUILDSUFFIX" =~ *-S1*) then
grep -q CONFIG_IDF_TARGET_ESP32=y "$SDKCONFIG"
if($status) then
idf.py set-target esp32
setenv CHANGED 1
endif
set add=($add CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME)
set rem=($rem CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME);
set sign="secure_boot_signing_key_ecdsa.pem"
# The settings PICO/D4/SOLO impact flash and PSRAM
if("$BUILDSUFFIX" =~ *-PICO*) then
set add=($add CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_SPIRAM CONFIG_REVK_PICO CONFIG_PARTITION_TABLE_CUSTOM)
set rem=($rem CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE CONFIG_REVK_D4)
set part="components/ESP32-RevK/partitions_8m.csv"
else if("$BUILDSUFFIX" =~ *-D4*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE CONFIG_REVK_D4 CONFIG_PARTITION_TABLE_CUSTOM)
set rem=($rem CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_SPIRAM CONFIG_REVK_PICO)
set part="components/ESP32-RevK/partitions_4m.csv"
else if("$BUILDSUFFIX" =~ *-SOLO*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE CONFIG_PARTITION_TABLE_CUSTOM)
set rem=($rem CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_SPIRAM CONFIG_REVK_PICO CONFIG_REVK_D4)
set part="components/ESP32-RevK/partitions_4m.csv"
else
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_PARTITION_TABLE_CUSTOM)
set rem=($rem CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_FREERTOS_UNICORE CONFIG_SPIRAM CONFIG_REVK_PICO CONFIG_REVK_D4)
set part="components/ESP32-RevK/partitions_4m.csv"
endif
if("$BUILDSUFFIX" =~ *-V3*) then
set add=($add CONFIG_ESP32_REV_MIN_3)
set rem=($rem CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V2*) then
set add=($add CONFIG_ESP32_REV_MIN_2)
set rem=($rem CONFIG_ESP32_REV_MIN_3 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V1*) then
set add=($add CONFIG_ESP32_REV_MIN_1)
set rem=($rem CONFIG_ESP32_REV_MIN_3 CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V0*) then
set add=($add CONFIG_ESP32_REV_MIN_0)
set rem=($rem CONFIG_ESP32_REV_MIN_3 CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else # Default is V3
set add=($add CONFIG_ESP32_REV_MIN_3)
set rem=($rem CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
endif
endif
if("$BUILDSUFFIX" =~ *-S2*) then
grep -q CONFIG_IDF_TARGET_ESP32S2=y "$SDKCONFIG"
if($status) then
idf.py set-target esp32s2
setenv CHANGED 1
endif
endif
if("$BUILDSUFFIX" =~ *-S3*) then
grep -q CONFIG_IDF_TARGET_ESP32S3=y "$SDKCONFIG"
if($status) then
idf.py set-target esp32s3
setenv CHANGED 1
endif
set add=($add CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT)
set sign="secure_boot_signing_key_rsa.pem"
if("$BUILDSUFFIX" =~ *-V2*) then
set add=($add CONFIG_ESP32S3_REV_MIN_2)
set rem=($rem CONFIG_ESP32S3_REV_MIN_3 CONFIG_ESP32S3_REV_MIN_1 CONFIG_ESP32S3_REV_MIN_0 CONFIG_ESP32S3_REV_MIN_1_1 CONFIG_ESP32S3_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V1*) then
set add=($add CONFIG_ESP32S3_REV_MIN_1)
set rem=($rem CONFIG_ESP32S3_REV_MIN_3 CONFIG_ESP32S3_REV_MIN_2 CONFIG_ESP32S3_REV_MIN_0 CONFIG_ESP32S3_REV_MIN_1_1 CONFIG_ESP32S3_REV_MIN_3_1)
else # Default is V0
set add=($add CONFIG_ESP32S3_REV_MIN_0)
set rem=($rem CONFIG_ESP32S3_REV_MIN_3 CONFIG_ESP32S3_REV_MIN_2 CONFIG_ESP32S3_REV_MIN_1 CONFIG_ESP32S3_REV_MIN_1_1 CONFIG_ESP32S3_REV_MIN_3_1)
endif
if("$BUILDSUFFIX" =~ *-MINI*) then
set add=($add CONFIG_REVK_MINI)
else
set rem=($rem CONFIG_REVK_MINI)
endif
if("$BUILDSUFFIX" =~ *-N4*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_PARTITION_TABLE_CUSTOM)
set rem=($rem CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_FREERTOS_UNICORE)
set part="components/ESP32-RevK/partitions_4m.csv"
else if("$BUILDSUFFIX" =~ *-N8*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_PARTITION_TABLE_CUSTOM)
set rem=($rem CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE)
set part="components/ESP32-RevK/partitions_8m.csv"
endif
if("$BUILDSUFFIX" =~ *-R2*) then
set add=($add CONFIG_ESP32S3_SPIRAM_SUPPORT CONFIG_SPIRAM)
else
set rem=($rem CONFIG_ESP32S3_SPIRAM_SUPPORT CONFIG_SPIRAM)
endif
endif
if("$BUILDSUFFIX" =~ *-C3*) then
grep -q CONFIG_IDF_TARGET_ESP32C3=y "$SDKCONFIG"
if($status) then
idf.py set-target esp32c3
setenv CHANGED 1
endif
endif
if("$BUILDSUFFIX" =~ *-H2*) then
grep -q CONFIG_IDF_TARGET_ESP32H2=y "$SDKCONFIG"
if($status) then
idf.py set-target esp32h2
setenv CHANGED 1
endif
endif
if("$BUILDSUFFIX" =~ *-MT*) then
grep -q CONFIG_REVK_MATTER=y "$SDKCONFIG"
if($status) then
set add=($add CONFIG_REVK_MATTER)
setenv CHANGED 1
endif
else
grep -q CONFIG_REVK_MATTER=y "$SDKCONFIG"
if(! $status) then
set rem=($rem CONFIG_REVK_MATTER)
setenv CHANGED 1
endif
endif
set bs=(`grep _BUILD_SUFFIX_ sdkconfig | sed 's/.*\(CONFIG_[A-Z0-9_]*_BUILD_SUFFIX_[A-Z0-9]*\).*/\1/'`)
foreach c ($bs)
echo -n "$BUILDSUFFIX" | grep -q -- "-"`echo -n "$c" | sed 's/CONFIG_.*_BUILD_SUFFIX_\(.*\)/\1/'`
if(! $status) then
set add=($add $c)
setenv CHANGED 1
else
set rem=($rem $c)
setenv CHANGED 1
endif
end
echo "$add" | grep -q CONFIG_SPIRAM
if(! $status) then
set add=($add CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL)
set rem=($rem CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT)
else
set add=($add CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT)
set rem=($rem CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL)
endif
rm -f "$SDKCONFIG".new
foreach c ($add)
grep -q "^# $c is not set" "$SDKCONFIG"
if(! $status) then
sed "s/^# $c is not set/$c=y/" "$SDKCONFIG" > "$SDKCONFIG.new"
mv -f "$SDKCONFIG".new "$SDKCONFIG"
setenv CHANGED 1
endif
end
foreach c ($rem)
grep -q "^$c=y" "$SDKCONFIG"
if(! $status) then
sed "s/^$c=y/# $c is not set/" "$SDKCONFIG" > "$SDKCONFIG.new"
mv -f "$SDKCONFIG".new "$SDKCONFIG"
setenv CHANGED 1
endif
end
if($part != "") then
foreach t (CONFIG_PARTITION_TABLE_CUSTOM_FILENAME CONFIG_PARTITION_TABLE_FILENAME)
grep -q "^$t="'"'"$part"'"' "$SDKCONFIG"
if($status) then
sed "s:^$t.*:$t="'"'"$part"'"'":" "$SDKCONFIG" > "$SDKCONFIG.new"
mv -f "$SDKCONFIG".new "$SDKCONFIG"
setenv CHANGED 1
endif
end
endif
if($?CHANGED) then
idf.py reconfigure
foreach c ($add)
grep -q "^# $c is not set" "$SDKCONFIG"
if(! $status) then
sed "s/^# $c is not set/$c=y/" "$SDKCONFIG" > "$SDKCONFIG.new"
mv -f "$SDKCONFIG".new "$SDKCONFIG"
endif
end
foreach c ($rem)
grep -q "^$c=y" "$SDKCONFIG"
if(! $status) then
sed "s/^$c=y/# $c is not set/" "$SDKCONFIG" > "$SDKCONFIG.new"
mv -f "$SDKCONFIG".new "$SDKCONFIG"
endif
end
if($part != "") then
foreach t (CONFIG_PARTITION_TABLE_CUSTOM_FILENAME CONFIG_PARTITION_TABLE_FILENAME)
grep -q "^$t="'"'"$part"'"' "$SDKCONFIG"
if($status) then
sed "s:^$t.*:$t="'"'"$part"'"'":" "$SDKCONFIG" > "$SDKCONFIG.new"
mv -f "$SDKCONFIG".new "$SDKCONFIG"
endif
end
endif
endif
if($sign != "") then
grep -q "^CONFIG_SECURE_BOOT_SIGNING_KEY="'"'"$sign"'"' "$SDKCONFIG"
if($status) then
sed "s:^CONFIG_SECURE_BOOT_SIGNING_KEY.*:CONFIG_SECURE_BOOT_SIGNING_KEY="'"'"$sign"'"'":" "$SDKCONFIG" > "$SDKCONFIG.new"
mv -f "$SDKCONFIG".new "$SDKCONFIG"
endif
endif