Repository navigation
Expand file tree
/
Copy pathplatformio.ini
More file actions
399 lines (364 loc) · 14.5 KB
/
Copy pathplatformio.ini
File metadata and controls
399 lines (364 loc) · 14.5 KB
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
; PlatformIO Project Configuration File for EMS-ESP
;
; override any settings with your own local ones in pio_local.ini (see example pio_local.ini_example)
; The firmware is renamed following this convention, and placed in the build/firmware folder:
; EMS-ESP32-<version>-<chip_type>-<flash_mem>[+ if PSRAM onboard].bin
; For example: EMS-ESP-3_7_0-dev_31-esp32-16MB+.bin
;
; boards can be found in https://github.com/pioarduino/platform-espressif32/tree/main/boards
[platformio]
; build all supported targets. Use pio_local.ini to override and build specific targets.
default_envs = s_4M, s_16M, s_16M_P, s3_16M_P, recovery_s_16M_P, recovery_s3_16M_P
description = EMS-ESP Firmware for the ESP32
src_dir = src
lib_dir = lib
boards_dir = boards
extra_configs =
factory_settings.ini
pio_local.ini
[common]
core_build_flags = -Wall -Wextra -Wno-type-limits -Wno-unused-parameter -Wno-unused-variable -Wno-format -Wno-missing-field-initializers
core_unbuild_flags = -O2 -O3 -Og -fno-lto
my_build_flags =
build_flags =
${common.core_build_flags}
${factory_settings.build_flags}
${common.my_build_flags}
-I./src/core
; core 3.3.12 uses spi_host_device_t in ETH.h without including it. A framework
; refresh restores that header, so force the declaration on every compile.
-include hal/spi_types.h
-D ARDUINO_ARCH_ESP32
-D ONEWIRE_CRC16=0
-D CONFIG_UART_ISR_IN_IRAM
-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000 ; default
-D CONFIG_ASYNC_TCP_PRIORITY=10 ; default
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=64 ; default
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1 ; force async_tcp task to be on same core as Arduino app (default is any core)
-D CONFIG_ASYNC_TCP_STACK_SIZE=8192 ; default is 16KB/8192*2
-D ENABLE_PSRAM ; incase BOARD_HAS_PSRAM is not set, so boards without PSRAM keep using the internal heap
; -D SSE_MAX_QUEUED_MESSAGES=1 ; for log messages, default 32
; -D EMSESP_UART_STACKSIZE=2560 ; 5120 is default
; -D EMSESP_OWN_IDENTITY ; answer version/name reads to our bus ID with a real identity instead of empty, see issue #3094
unbuild_flags =
${common.core_unbuild_flags}
; 4MB Flash variants
[espressif32_base_4M]
framework = arduino
board_build.partitions = partitions/esp32_partition_4M.csv
build_flags =
${common.build_flags}
-D EMSESP_EN_DE_ONLY
-D NO_EMSESP_FEATURE_PRICE
; 16MB Flash variants
[espressif32_base_16M]
framework = arduino
board_build.partitions = partitions/esp32_partition_16M.csv
build_flags =
${common.build_flags}
-D EMSESP_HAS_RECOVERY ; installs and falls back to the recovery firmware in the factory partition
-D OTA_UPDATER_ANY_PARTITION ; so the recovery firmware can be uploaded into the factory partition
; 32MB Flash variants
[espressif32_base_32M]
framework = arduino
board_build.partitions = partitions/esp32_partition_32M.csv
[env]
; use own Ardunio libs packages from https://github.com/emsesp/esp32-arduino-lib-builder
; and with Tasmota's tool chain (platform)
; Arduino Core 3.3.12 and IDF 5.5.5
platform = https://github.com/tasmota/platform-espressif32/releases/download/2026.11.51/platform-espressif32.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/emsesp/esp32-arduino-lib-builder/releases/download/1411-1037-5.5_gcc153/framework-arduinoespressif32-release_v5.5_gcc153-e9beae0f.tar.xz
build_flags =
${common.build_flags}
build_unflags =
${common.unbuild_flags}
extra_scripts =
post:scripts/rename_fw.py ; renames the firmware .bin file
monitor_speed = 115200
monitor_filters = direct, esp32_exception_decoder
build_type = release
board_build.filesystem = littlefs
board_build.littlefs_version = 2.0
lib_deps =
bblanchon/ArduinoJson @ 7.4.3
ESP32Async/AsyncTCP @ 3.6.1
ESP32Async/ESPAsyncWebServer @ 3.12.1
https://github.com/mobizt/ReadyMail.git @ 0.4.2
https://github.com/mobizt/ESP_SSLClient.git @ 3.1.4
; https://github.com/emsesp/EMS-ESP-Modules.git @ 1.0.8
; builds the web interface only, not the firmware
[env:build-webUI]
platform = native
targets = build
extra_scripts = pre:scripts/build_interface.py
; Exclude all source files so the C code doesn't build
build_src_filter = -<*>
; builds the recovery web interface only (recovery/WWWData.h), not the recovery firmware
[env:build-recovery]
platform = native
targets = build
extra_scripts = pre:scripts/build_recovery_interface.py
; Exclude all source files so the C code doesn't build
build_src_filter = -<*>
;
; Builds for different board types
; If you're building for a single target environment, we recommend creating a pio_local.ini (see example file)
;
[env:s_4M]
; 4MB ESP32 - no SSL, no PSRAM - like a BBQKees older S32 and E32 models
; only entity translations for German (English is default)
extends = espressif32_base_4M
board = s_4M
[env:s_16M]
; 16MB ESP32 - no PSRAM - like a BBQKees later S32 V2 models
extends = espressif32_base_16M
board = s_16M
[env:s_16M_P]
; 16MB ESP32 - with PSRAM - like a BBQKees E32V2
extends = espressif32_base_16M
board = s_16M_P
[env:s3_16M_P]
; 16MB ESP32-S3 - with PSRAM - like a BBQKees S3
extends = espressif32_base_16M
board = s3_16M_P
[env:s3_32M_P]
; 16MB ESP32-S3 - with PSRAM and 32MB flash
extends = espressif32_base_32M
board = s3_32M_P
[env:s2_4M_P]
; based on lolin_s2_mini 4MB with 2MB PSRAM
extends = espressif32_base_4M
board = s2_4M_P
build_flags =
${common.build_flags}
-D EMSESP_EN_DE_ONLY
[env:c3_mini_4M]
; based on lolin_c3_mini 4MB, no PSRAM
extends = espressif32_base_4M
board = c3_mini_4M
; lolin C3 mini v1 needs special wifi initialization
; https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi
[env:c3_miniv1_4M]
extends = espressif32_base_4M
board = c3_mini_4M
build_flags =
${espressif32_base_4M.build_flags}
-D BOARD_C3_MINI_V1
; XIAO ESP32C - 512KB SRAM & 4MB Flash - https://wiki.seeedstudio.com/xiao_esp32c6_getting_started/
[env:c6_xiao_4M]
extends = espressif32_base_4M
board = seeed_xiao_esp32c6
; Crash test builds for the bootloader rollback and the recovery fallback. Install with the web upload, not over
; serial, since a serial flash boots the recovery. Change EMSESP_CRASH_TEST to pick the test:
; 1 crashes on every start, so the bootloader rolls back to the previous firmware
; 2 runs normally until it's confirmed after 2 minutes, then crashes from the next restart. After 5 crashes in a row
; it switches to the recovery firmware. Without one it keeps crashing until reflashed over serial
[env:crashtest_s_16M_P]
extends = env:s_16M_P
build_flags =
${espressif32_base_16M.build_flags}
-D EMSESP_CRASH_TEST=1
custom_fw_name = EMS-ESP-CrashTest
; EMS-ESP Recovery - a small app for the factory (boot) partition with an access point and a firmware upload page.
; Only for boards with a factory partition (16MB). Sources are in ./recovery, the WebUI is built from ./interface.
; build: pio run -e recovery_s3_16M_P
; flash into the boot partition: pio run -e recovery_s3_16M_P -t upload
; or over the network while EMS-ESP is running: add an [env:recovery_s3_16M_P] section to pio_local.ini with
; upload_protocol = custom (custom_emsesp_ip, custom_username and custom_password as for upload.py)
; run it from app0 like a normal app instead, add an [env:recovery_s3_16M_P] section to pio_local.ini with custom_app_offset =
; develop the WebUI with a mock: cd interface && pnpm recovery
[recovery_base]
extends = espressif32_base_16M
board_build.app_partition_name = boot
build_src_filter = -<*> +<../recovery/>
build_flags =
${factory_settings.build_flags}
-std=gnu++20 -Os
-D OTA_UPDATER_ANY_PARTITION
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1
-D CONFIG_ASYNC_TCP_STACK_SIZE=8192
build_unflags =
${common.core_unbuild_flags}
lib_ldf_mode = chain
lib_deps =
bblanchon/ArduinoJson @ 7.4.3
ESP32Async/AsyncTCP @ 3.6.1
ESP32Async/ESPAsyncWebServer @ 3.12.1
extra_scripts =
pre:scripts/build_recovery_interface.py
post:scripts/set_app_desc.py
post:scripts/rename_fw.py
post:scripts/upload_factory.py
upload_protocol = esptool
custom_app_offset = 0x10000
custom_fw_name = EMS-ESP-Recovery
custom_version_file = recovery/recovery_version.h
custom_version_define = RECOVERY_VERSION
[env:recovery_s_16M]
extends = recovery_base
board = s_16M
[env:recovery_s_16M_P]
extends = recovery_base
board = s_16M_P
[env:recovery_s3_16M_P]
extends = recovery_base
board = s3_16M_P
; foundation for building and testing natively, standalone without an ESP32
; use the `standalone` environment instead of `native` for testing
[env:native]
platform = native
build_type = debug
build_flags =
build_src_flags =
-DEMSESP_STANDALONE -DEMSESP_TEST
-DARDUINOJSON_ENABLE_ARDUINO_STRING=1
-std=gnu++20 -Og -ggdb
-Wall -Wextra
-Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces
;-Wno-vla-cxx-extension -Wno-tautological-constant-out-of-range-compare
-I./src/core
-I./lib_standalone
-I./lib/uuid-common/src
-I./lib/uuid-console/src
-I./lib/uuid-log/src
-I./lib/PButton
-I./lib/espMqttClient/src
-I./lib/espMqttClient/src/Transport
-I./lib/FirmwareSignature
build_src_filter =
+<../src>
+<../lib>
+<../lib_standalone>
-<../src/ESP32React>
-<../lib/uuid-telnet>
-<../lib/uuid-syslog>
-<../lib/eModbus>
-<../lib/OneWire>
-<../lib/OtaUpdater>
-<../lib/CoreDump>
-<../lib/FirmwareSignature/micro-ecc>
-<../src/core/ModuleLibrary.cpp>
lib_ldf_mode = off
lib_deps =
; unit tests
; The test code is in ./test/test_api.cpp and the test_api.h file is generated by the native-test-create environment.
; to run use `platformio run -e native-test -t exec`. All tests should PASS.
; tip: use https://jsondiff.com/ to compare the expected and actual responses.
; to update the test output run `python3 scripts/generate_test_api.py`
[env:native-test]
platform = native
test_build_src = true
build_flags =
build_type = debug
build_src_flags =
-D EMSESP_STANDALONE -DEMSESP_TEST
-D EMSESP_UNITY
-D ARDUINOJSON_ENABLE_ARDUINO_STRING=1
-D EMSESP_DEFAULT_LOCALE=\"en\" -D EMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
-std=gnu++20 -Og -ggdb
-Wall -Wextra
-Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces
-Wno-vla-cxx-extension -Wno-tautological-constant-out-of-range-compare
-I./src/core
-I./lib_standalone
-I./lib/uuid-common/src
-I./lib/uuid-console/src
-I./lib/uuid-log/src
-I./lib/PButton
-I./lib/espMqttClient/src
-I./lib/espMqttClient/src/Transport
-I./lib/FirmwareSignature
-I./test/api
-I./test
build_src_filter =
+<../src>
+<../test>
+<../lib>
+<../lib_standalone>
-<../src/ESP32React>
-<../lib/uuid-telnet>
-<../lib/uuid-syslog>
-<../lib/eModbus>
-<../lib/OneWire>
-<../lib/OtaUpdater>
-<../lib/CoreDump>
-<../lib/FirmwareSignature/micro-ecc>
-<../src/core/ModuleLibrary.cpp>
lib_ldf_mode = off
lib_deps = Unity
test_testing_command =
${platformio.build_dir}/${this.__env__}/program
; builds the test cases and creates the test_api.h file
; run with `pio run -e native-test-create -t exec` and capture the output between "START - CUT HERE" and "END - CUT HERE" and paste it into the test_api.h file
[env:native-test-create]
extends = env:native-test
build_flags =
-D EMSESP_UNITY_CREATE
; fuzzes Command::process and compute() with random input, built with AddressSanitizer and UBSan
; run with `pio run -e native-fuzz -t exec`. FUZZ_ITERATIONS (default 20000) and FUZZ_SEED override the defaults
[env:native-fuzz]
extends = env:native-test
build_flags =
-D EMSESP_FUZZ
-fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer
;
; Building and testing locally on OS, which we call "standalone" without an ESP32.
; See https://docs.platformio.org/en/latest/platforms/native.html
;
; It will generate an executable which when run will show the EMS-ESP Console where you can run tests using the `test` command.
;
; See https://docs.platformio.org/en/latest/core/installation/shell-commands.html#piocore-install-shell-commands
;
; to build and run directly on linux: pio run -e standalone -t exec
;
; to build and run on Windows, it needs winsock for the console input so:
; - For the first time, install Msys2 (https://www.msys2.org/) and the GCC compiler with `run pacman -S mingw-w64-ucrt-x86_64-gcc`
; - Then, build with `pio run -e standalone` to create the program.exe file
; - run by calling the executable from the Mysys shell e.g. `C:/msys64/msys2_shell.cmd -defterm -here -no-start -ucrt64 -c <location>/.pio/build/native/program.exe`
; - or use with Windows Terminal https://www.msys2.org/docs/terminals/
;
[env:standalone]
extends = env:native
build_flags =
-D EMSESP_DEFAULT_LOCALE=\"en\" -D EMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
; Modbus
; Creates the file modbus_entity_parameters.hpp
; Creating the modbus registers is a multi-step process. Before it was in a shell script called generate_csv_and_headers.sh
; but now moved to pio so everything is in python and cross-platform. The logic is as follows:
; 1. save the current modbus_entity_parameters.hpp to .pio/modbus_entity_parameters.prev.hpp and
; create a dummy modbus_entity_parameters.hpp file so the first pass compiles
; 2. compile the EMS-ESPcode with the EMSESP_MODBUS flag set
; 3. run the entity_dump test command and generate the dump_entities.csv file
; 4. use the dump_entities.csv file with update_modbus_registers.py script to generate the modbus_entity_parameters.hpp file.
; Existing register offsets are kept from the saved map, new entities are added at the end of their block.
; Use scripts/modbus_register_diff.py to list register changes since the last release for the changelog.
; 5. clean up everything and start again with the EMSESP_STANDALONE flag set
; 6. run the entity_dump test command again to create the real dump_entities.csv file
;
; To use, run:
; pio run -e build_modbus -t clean -t build
[env:build_modbus]
extends = env:native
targets = build
extra_scripts =
pre:scripts/build_modbus_entity_parameters_pre.py
post:scripts/build_run_test.py
build_flags = -D EMSESP_MODBUS
custom_test_command = entity_dump
custom_output_file = dump_entities.csv
custom_post_script = scripts/build_modbus_entity_parameters_post.py
; builds the real dump_entities.csv and dump_telegrams.csv files
; and also the Modbus*.md files used in the emsesp.org documentation
; (Modbus-Entity-Registers.md, Modbus-Server-IDs.md, Modbus-Register-Blocks.md, Modbus-System-Server.md)
;
; To use, run after build_modbus environment, with:
; pio run -e build_standalone -t clean -t build
[env:build_standalone]
extends = env:native
targets = build
extra_scripts =
post:scripts/build_run_test.py
build_flags = -D EMSESP_STANDALONE
custom_test_command = entity_dump
custom_output_file = dump_entities.csv
custom_post_script = scripts/build_standalone_post.py