Skip to content

Commit 34a10f7

Browse files
authored
Merge pull request #5492 from TD-er/build/reduce_binsize_disable_spi_i2c
[Build] Try to reduce build size for ESP8266 minimal, disable I2C/SPI
2 parents a388622 + f034922 commit 34a10f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+515
-126
lines changed

platformio_esp82xx_base.ini

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,13 @@ lib_ignore = ESP32_ping
246246
extends = ir
247247
build_flags = ${ir.build_flags}
248248
-DPLUGIN_BUILD_MINIMAL_IR
249+
-DFEATURE_I2C=1
249250

250251
[minimal_ir_extended]
251252
extends = ir
252253
build_flags = ${ir.build_flags}
253254
-DPLUGIN_BUILD_MINIMAL_IRext
255+
-DFEATURE_I2C=1
254256

255257
[normal_ir]
256258
extends = ir
@@ -305,6 +307,108 @@ build_flags = ${esp82xx_1M.build_flags}
305307
-DDISABLE_SC16IS752_Serial
306308
-DFEATURE_GPIO_USE_ESP8266_WAVEFORM=0
307309
extra_scripts = ${esp82xx_1M.extra_scripts}
310+
lib_ignore = ESP32_ping
311+
ESP32WebServer
312+
ESP32HTTPUpdateServer
313+
ServoESP32
314+
TinyWireM
315+
ESP8266SdFat
316+
SD(esp8266)
317+
SD
318+
SDFS
319+
LittleFS(esp8266)
320+
LittleFS
321+
ArduinoOTA
322+
ESP8266mDNS
323+
I2C AXP192 Power management
324+
EspSoftwareSerial
325+
AXP2101 Power management (I2C)
326+
AM2320
327+
AS3935MI
328+
AS5600
329+
AS_BH1750
330+
Adafruit BME680 Library
331+
Adafruit BMP3XX Library
332+
Adafruit GFX Library
333+
Adafruit HMC5883 Unified
334+
Adafruit ILI9341 ESPEasy
335+
Adafruit MPR121
336+
Adafruit Motor Shield V2 Library
337+
Adafruit NeoMatrix via NeoPixelBus
338+
Adafruit PCD8544 Nokia 5110 LCD library
339+
Adafruit SGP30 Sensor
340+
Adafruit SI1145 Library
341+
Adafruit TCS34725
342+
Adafruit TSL2591 Library
343+
Adafruit Unified Sensor
344+
Adafruit VEML7700 Library
345+
Adafruit seesaw Library
346+
Adafruit_ST77xx
347+
AnyRtttl
348+
; ArduinoJson
349+
Blynk
350+
CHT16K33 LED Matrix Library
351+
CircularBuffer
352+
ClimateGuard RadSens
353+
DFRobot_GP8403_ESPEasy
354+
DNSServer
355+
; ESP8266HTTPClient
356+
; ESP8266HTTPUpdateServer
357+
; ESP8266WebServer
358+
; ESP8266WiFi
359+
ESP8266_SSD1306
360+
; ESPeasySerial
361+
ESPping
362+
ESP8266 and ESP32 Oled Driver for SSD1306 display
363+
FrogmoreScd30
364+
; GPIO_DirectAccess
365+
HLW8012
366+
HeatpumpIR
367+
I2Cdevlib-Core
368+
ILI9488
369+
IRremoteESP8266
370+
ITG3205
371+
Improv WiFi Library
372+
IthoCC1101
373+
LOLIN_EPD
374+
LiquidCrystal_I2C
375+
MD_MAX72XX
376+
MD_Parola
377+
MFRC522
378+
MechInputs
379+
Multi Channel Relay Arduino Library
380+
NeoPixelBus
381+
NeoPixelBus_wrapper
382+
NewPing
383+
Noiasca NeopixelDisplay
384+
PZEM-004T-v30
385+
; PubSubClient3
386+
RAK12019_LTR390_UV_Light
387+
RN2xx3 Arduino Library
388+
RTClib
389+
Regexp
390+
SC16IS752
391+
SDM
392+
SPI
393+
Sensirion Gas Index Algorithm
394+
SerialSensors
395+
Servo
396+
ShiftRegister74HC595_NonTemplate
397+
SparkFun ADXL345 Arduino Library
398+
SparkFun APDS9960 RGB and Gesture Sensor
399+
SparkFun MAX1704x Fuel Gauge Arduino Library
400+
SparkFun SCD4x Arduino Library
401+
SparkFun VL53L1X 4m Laser Distance Sensor
402+
SparkFun_AS7265x
403+
TinyGPSPlus
404+
VL53L0X
405+
WakeOnLan
406+
Wire
407+
XPT2046_Touchscreen
408+
bb_captouch
409+
htcw_ip5306
410+
ld2410
411+
supertinycron
308412
;lib_ignore = ${esp82xx_1M.lib_ignore}
309413
; Adding the libs below to the lib_ignore will even increase build size
310414
; Adafruit TCS34725

platformio_esp82xx_envs.ini

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,42 +375,46 @@ build_flags = ${esp8266_1M_OTA.build_flags}
375375
extends = esp8266_1M_OTA, core274_platform
376376
build_flags = ${core274_platform.build_flags}
377377
${minimal_OTA_domoticz.build_flags}
378-
lib_ignore = ${core274_platform.lib_ignore}
378+
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
379379

380380

381381
[env:minimal_core_274_ESP8266_1M_OTA_Domoticz_MQTT]
382382
extends = esp8266_1M_OTA, core274_platform
383383
build_flags = ${core274_platform.build_flags}
384384
${minimal_OTA_domoticz_MQTT.build_flags}
385-
lib_ignore = ${core274_platform.lib_ignore}
385+
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
386386

387387

388388
[env:minimal_core_274_ESP8266_1M_OTA_FHEM_HA]
389389
extends = esp8266_1M_OTA, core274_platform
390390
build_flags = ${core274_platform.build_flags}
391391
${minimal_OTA_FHEM_HA.build_flags}
392-
lib_ignore = ${core274_platform.lib_ignore}
392+
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
393393

394394

395395
[env:minimal_core_312_ESP8266_1M_OTA_Domoticz]
396396
extends = esp8266_1M_OTA, core312_platform
397397
build_flags = ${core312_platform.build_flags}
398398
${minimal_OTA_domoticz.build_flags}
399399
build_unflags = ${core312_platform.build_unflags}
400+
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
401+
400402

401403

402404
[env:minimal_core_312_ESP8266_1M_OTA_Domoticz_MQTT]
403405
extends = esp8266_1M_OTA, core312_platform
404406
build_flags = ${core312_platform.build_flags}
405407
${minimal_OTA_domoticz_MQTT.build_flags}
406408
build_unflags = ${core312_platform.build_unflags}
409+
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
407410

408411

409412
[env:minimal_core_312_ESP8266_1M_OTA_FHEM_HA]
410413
extends = esp8266_1M_OTA, core312_platform
411414
build_flags = ${core312_platform.build_flags}
412415
${minimal_OTA_FHEM_HA.build_flags}
413416
build_unflags = ${core312_platform.build_unflags}
417+
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
414418

415419

416420

src/src/Commands/InternalCommands.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@ bool InternalCommands::executeInternalCommand()
326326
#if FEATURE_WIFI
327327
case ESPEasy_cmd_e::hiddenssid: COMMAND_CASE_R(Command_Wifi_HiddenSSID, 1); // wifi.h
328328
#endif
329+
#if FEATURE_I2C
329330
case ESPEasy_cmd_e::i2cscanner: COMMAND_CASE_R(Command_i2c_Scanner, -1); // i2c.h
331+
#endif
330332
case ESPEasy_cmd_e::inc: COMMAND_CASE_A(Command_Rules_Inc, -1); // Rules.h
331333
case ESPEasy_cmd_e::ip: COMMAND_CASE_R(Command_IP, 1); // Network Command
332334
#if FEATURE_USE_IPV6

src/src/Commands/i2c.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "../../ESPEasy_common.h"
1313

14+
#if FEATURE_I2C
1415
void i2c_scanI2Cbus(bool dbg, int8_t channel, uint8_t i2cBus) {
1516
uint8_t error, address;
1617

@@ -70,3 +71,4 @@ const __FlashStringHelper* Command_i2c_Scanner(struct EventStruct *event, const
7071
I2CSelectHighClockSpeed(0); // By default the bus is in standard speed
7172
return return_see_serial(event);
7273
}
74+
#endif

src/src/Commands/i2c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
#define COMMAND_I2C_H
33

44
#include "../../ESPEasy_common.h"
5-
5+
#if FEATURE_I2C
66
void i2c_scanI2Cbus(bool dbg,
77
int8_t channel,
88
uint8_t i2cBus);
99

1010
const __FlashStringHelper* Command_i2c_Scanner(struct EventStruct *event,
1111
const char *Line);
12-
12+
#endif
1313
#endif // COMMAND_I2C_H

src/src/CustomBuild/define_plugin_sets.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ To create/register a plugin, you have to :
5555
#define WEBSERVER_INCLUDE_JS
5656
#endif
5757
#ifndef WEBSERVER_LOG
58+
#ifndef PLUGIN_BUILD_MINIMAL_OTA
5859
#define WEBSERVER_LOG
5960
#endif
61+
#endif
6062
#ifndef WEBSERVER_JSON
6163
#define WEBSERVER_JSON
6264
#endif
@@ -4471,4 +4473,55 @@ To create/register a plugin, you have to :
44714473
#endif
44724474
#endif
44734475

4476+
#ifndef FEATURE_I2C
4477+
#ifdef ESP32
4478+
#define FEATURE_I2C 1
4479+
#else
4480+
// TODO TD-er: Add check for plugins requiring I2C
4481+
// Checks:
4482+
// FEATURE_I2CMULTIPLEXER
4483+
// FEATURE_PLUGIN_PRIORITY
4484+
// FEATURE_I2C_MULTIPLE
4485+
// FEATURE_CLEAR_I2C_STUCK
4486+
// FEATURE_I2C_GET_ADDRESS
4487+
// FEATURE_EXT_RTC
4488+
// I2C Watchdog???? Settings.WDI2CAddress
4489+
#ifdef PLUGIN_BUILD_MINIMAL_OTA
4490+
#ifdef USES_P180
4491+
#define FEATURE_I2C 1
4492+
#else
4493+
#define FEATURE_I2C 0
4494+
#endif
4495+
#else
4496+
#define FEATURE_I2C 1
4497+
#endif
4498+
#endif
4499+
#endif
4500+
4501+
#if !FEATURE_I2C
4502+
# ifdef WEBSERVER_I2C_SCANNER
4503+
# undef WEBSERVER_I2C_SCANNER
4504+
# endif
4505+
#endif
4506+
4507+
#ifndef FEATURE_SPI
4508+
#if FEATURE_SD
4509+
#define FEATURE_SPI 1
4510+
// TODO TD-er: Add check for plugins requiring SPI
4511+
#else
4512+
#if defined(USES_NW004) || defined(USES_P039) || defined(USES_P046) || defined(USES_P095) || defined(USES_P096) || defined(USES_P099) || defined(USES_P104) || defined(USES_P111) || defined(USES_P116) || defined(USES_P118) || defined(USES_P125) || defined(USES_P141) || defined(USES_P162) || defined(USES_P172)
4513+
#define FEATURE_SPI 1
4514+
#else
4515+
#define FEATURE_SPI 0
4516+
#endif
4517+
#endif
4518+
#endif
4519+
4520+
4521+
#if !FEATURE_SPI && !FEATURE_I2C
4522+
#ifdef WEBSERVER_INTERFACES
4523+
#undef WEBSERVER_INTERFACES
4524+
#endif
4525+
#endif
4526+
44744527
#endif // CUSTOMBUILD_DEFINE_PLUGIN_SETS_H

src/src/DataStructs/DeviceStruct.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,23 @@ void DeviceStruct::clear() {
5757
bool DeviceStruct::connectedToGPIOpins() const {
5858
switch(Type) {
5959
case DEVICE_TYPE_SINGLE: // Single GPIO
60+
#if FEATURE_SPI
6061
case DEVICE_TYPE_SPI:
62+
#endif
6163
case DEVICE_TYPE_CUSTOM1:
6264

6365
case DEVICE_TYPE_DUAL: // Dual GPIOs
6466
case DEVICE_TYPE_SERIAL:
67+
#if FEATURE_SPI
6568
case DEVICE_TYPE_SPI2:
69+
#endif
6670
case DEVICE_TYPE_CUSTOM2:
6771

6872
case DEVICE_TYPE_TRIPLE: // Triple GPIOs
6973
case DEVICE_TYPE_SERIAL_PLUS1:
74+
#if FEATURE_SPI
7075
case DEVICE_TYPE_SPI3:
76+
#endif
7177
case DEVICE_TYPE_CUSTOM3:
7278
return true;
7379
default:
@@ -81,12 +87,16 @@ bool DeviceStruct::usesTaskDevicePin(int pin) const {
8187
if (pin == 2)
8288
return connectedToGPIOpins() &&
8389
!(Type == DEVICE_TYPE_SINGLE ||
90+
#if FEATURE_SPI
8491
Type == DEVICE_TYPE_SPI ||
92+
#endif
8593
Type == DEVICE_TYPE_CUSTOM1);
8694
if (pin == 3)
8795
return Type == DEVICE_TYPE_TRIPLE ||
8896
Type == DEVICE_TYPE_SERIAL_PLUS1 ||
97+
#if FEATURE_SPI
8998
Type == DEVICE_TYPE_SPI3 ||
99+
#endif
90100
Type == DEVICE_TYPE_CUSTOM3;
91101
return false;
92102
}
@@ -95,12 +105,13 @@ bool DeviceStruct::isSerial() const {
95105
return (Type == DEVICE_TYPE_SERIAL) ||
96106
(Type == DEVICE_TYPE_SERIAL_PLUS1);
97107
}
98-
108+
#if FEATURE_SPI
99109
bool DeviceStruct::isSPI() const {
100110
return (Type == DEVICE_TYPE_SPI) ||
101111
(Type == DEVICE_TYPE_SPI2) ||
102112
(Type == DEVICE_TYPE_SPI3);
103113
}
114+
#endif
104115

105116
bool DeviceStruct::isCustom() const {
106117
return (Type == DEVICE_TYPE_CUSTOM0) ||

src/src/DataStructs/DeviceStruct.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@
1717
#define DEVICE_TYPE_DUAL 2 // connected through 2 datapins
1818
#define DEVICE_TYPE_TRIPLE 3 // connected through 3 datapins
1919
#define DEVICE_TYPE_ANALOG 10 // AIN/tout pin
20+
#if FEATURE_I2C
2021
#define DEVICE_TYPE_I2C 20 // connected through I2C
22+
#endif
2123
#define DEVICE_TYPE_SERIAL 21 // connected through UART/Serial
2224
#define DEVICE_TYPE_SERIAL_PLUS1 22 // connected through UART/Serial + 1 extra signal pin
25+
#if FEATURE_SPI
2326
#define DEVICE_TYPE_SPI 23 // connected through SPI
2427
#define DEVICE_TYPE_SPI2 24 // connected through SPI, 2 GPIOs
2528
#define DEVICE_TYPE_SPI3 25 // connected through SPI, 3 GPIOs
29+
#endif
2630
#define DEVICE_TYPE_CUSTOM0 30 // Custom labels, Not using TaskDevicePin1 ... TaskDevicePin3
2731
#define DEVICE_TYPE_CUSTOM1 31 // Custom labels, 1 GPIO
2832
#define DEVICE_TYPE_CUSTOM2 32 // Custom labels, 2 GPIOs
@@ -73,8 +77,9 @@ struct DeviceStruct
7377
}
7478

7579
bool isSerial() const;
76-
80+
#if FEATURE_SPI
7781
bool isSPI() const;
82+
#endif
7883

7984
bool isCustom() const;
8085

0 commit comments

Comments
 (0)