[ESP-IDF5.1] Use LTO on ESP32 IDF5.1 builds to reduce build size

This commit is contained in:
TD-er
2023-11-28 13:23:44 +01:00
parent e551c2ba5a
commit 8331cf9dde
8 changed files with 82 additions and 66 deletions
+17 -15
View File
@@ -87,6 +87,7 @@ build_flags = -DNDEBUG
; remove the 4-bytes alignment for PSTR()
-DPSTR_ALIGN=1
-Werror=return-type
build_unflags = ${esp82xx_common.build_unflags}
lib_ignore = ${esp82xx_defaults.lib_ignore}
EspSoftwareSerial
@@ -95,7 +96,14 @@ lib_ignore = ${esp82xx_defaults.lib_ignore}
build_flags = ${esp82xx_2_7_x.build_flags}
-DCORE_POST_3_0_0
-Wno-deprecated-declarations
; -flto=auto
; -Wl,-flto
build_unflags = -DDEBUG_ESP_PORT
-fexceptions
-Wall
; -fno-lto
lib_ignore = ${esp82xx_defaults.lib_ignore}
extra_scripts = pre:tools/pio/pre_custom_esp8266_toolchain.py
@@ -112,21 +120,10 @@ build_flags = ${esp82xx_2_7_x.build_flags}
-Wno-deprecated-declarations
-DLIBRARIES_NO_LOG=1
lib_ignore = ${esp82xx_2_7_x.lib_ignore}
build_unflags = ${esp82xx_2_7_x.build_unflags}
extra_scripts =
[core_4_1_0]
extends = esp82xx_3_0_x
platform = espressif8266@4.2.1
platform_packages =
build_flags = ${esp82xx_3_0_x.build_flags}
-DPIO_FRAMEWORK_ARDUINO_MMU_CUSTOM
-DMMU_IRAM_SIZE=0xC000
-DMMU_ICACHE_SIZE=0x4000
-DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3
-DUSES_LATEST_SOFTWARE_SERIAL_LIBRARY=1
-DLIBRARIES_NO_LOG=1
lib_ignore = ${esp82xx_defaults.lib_ignore}
[core_stage]
extends = esp82xx_3_0_x
platform = espressif8266@4.2.1
@@ -136,7 +133,10 @@ build_flags = ${esp82xx_3_0_x.build_flags}
-DUSES_LATEST_SOFTWARE_SERIAL_LIBRARY=1
-DLIBRARIES_NO_LOG=1
-DPHASE_LOCKED_WAVEFORM
build_unflags = ${esp82xx_3_0_x.build_unflags}
lib_ignore = ${esp82xx_defaults.lib_ignore}
;extra_scripts = ${esp82xx_3_0_x.extra_scripts}
extra_scripts =
@@ -152,7 +152,9 @@ build_flags = ${esp82xx_3_0_x.build_flags}
-DPHASE_LOCKED_WAVEFORM
-DPIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
-DUSE_SECOND_HEAP
build_unflags = ${esp82xx_3_0_x.build_unflags}
lib_ignore = ${core_stage.lib_ignore}
extra_scripts = ${esp82xx_3_0_x.extra_scripts}
@@ -206,8 +208,8 @@ lib_ignore =
;platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.12/platform-espressif32.zip
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1787/framework-arduinoespressif32-release_v5.1-f61c914469.zip
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.11.11/platform-espressif32.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1818/framework-arduinoespressif32-release_v5.1-e5ff26581f.zip
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1830/framework-arduinoespressif32-release_v5.1-6225c6435e.zip
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1818/framework-arduinoespressif32-release_v5.1-e5ff26581f.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1831/framework-arduinoespressif32-release_v5.1-29db12e32f.zip
build_flags = -DESP32_STAGE
-DESP_IDF_VERSION_MAJOR=5
-DLIBRARIES_NO_LOG=1
+2 -2
View File
@@ -46,14 +46,14 @@ extra_scripts = post:tools/pio/post_esp32.py
; more detail: https://embeddedartistry.com/blog/2020/04/13/prefer-gcc-ar-to-ar-in-your-buildsystems/
; pre:tools/pio/apply_patches.py
build_unflags = -Wall
; -fno-lto
-fno-lto
build_flags = ${core_esp32_IDF5_1__3_0_0.build_flags}
; ${mqtt_flags.build_flags}
-DMQTT_MAX_PACKET_SIZE=2048
-DCONFIG_FREERTOS_ASSERT_DISABLE
-DCONFIG_LWIP_ESP_GRATUITOUS_ARP
-fno-strict-aliasing
; -flto
-flto=auto
-Wswitch
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
monitor_filters = esp32_exception_decoder
+10
View File
@@ -8,6 +8,8 @@ build_flags = ${core_2_7_4.build_flags}
platform = ${core_2_7_4.platform}
platform_packages = ${core_2_7_4.platform_packages}
lib_ignore = ${core_2_7_4.lib_ignore}
build_unflags = ${core_2_7_4.build_unflags}
extra_scripts =
[core312_platform]
@@ -15,12 +17,15 @@ build_flags = ${core_stage.build_flags}
platform = ${core_stage.platform}
platform_packages = ${core_stage.platform_packages}
lib_ignore = ${core_stage.lib_ignore}
build_unflags = ${core_stage.build_unflags}
extra_scripts = ${core_stage.extra_scripts}
[regular_platform]
build_flags = ${core_2_7_4.build_flags}
platform = ${core_2_7_4.platform}
platform_packages = ${core_2_7_4.platform_packages}
lib_ignore = ${core_2_7_4.lib_ignore}
build_unflags = ${core_2_7_4.build_unflags}
[beta_platform_2ndheap]
@@ -28,12 +33,16 @@ build_flags = ${core_stage_2ndheap.build_flags}
platform = ${core_stage_2ndheap.platform}
platform_packages = ${core_stage_2ndheap.platform_packages}
lib_ignore = ${core_stage_2ndheap.lib_ignore}
build_unflags = ${core_stage_2ndheap.build_unflags}
extra_scripts = ${core_stage_2ndheap.extra_scripts}
[beta_platform]
build_flags = ${core_stage.build_flags}
platform = ${core_stage.platform}
platform_packages = ${core_stage.platform_packages}
lib_ignore = ${core_stage.lib_ignore}
build_unflags = ${core_stage.build_unflags}
extra_scripts = ${core_stage.extra_scripts}
[no_ir]
@@ -198,6 +207,7 @@ build_flags = ${esp82xx_1M.build_flags}
-DPLUGIN_BUILD_MINIMAL_OTA
-DDISABLE_SC16IS752_Serial
-DFEATURE_GPIO_USE_ESP8266_WAVEFORM=0
extra_scripts = ${esp82xx_1M.extra_scripts}
;lib_ignore = ${esp82xx_1M.lib_ignore}
; Adding the libs below to the lib_ignore will even increase build size
; Adafruit TCS34725
+13
View File
@@ -15,6 +15,8 @@ build_flags = ${core_stage.build_flags}
-DBUILD_NO_DEBUG
-DPLUGIN_BUILD_CUSTOM
-DFEATURE_DEFINE_SERIAL_CONSOLE_PORT=0
extra_scripts = ${extra_scripts_esp8266.extra_scripts}
${core_stage.extra_scripts}
[esp8266_custom_common_274]
@@ -47,6 +49,7 @@ lib_ignore = ESP32_ping
I2C AXP192 Power management
extra_scripts = pre:tools/pio/pre_custom_esp82xx.py
${extra_scripts_esp8266.extra_scripts}
${core_stage.extra_scripts}
; Custom: 4M1M version --------------------------
@@ -316,17 +319,27 @@ lib_ignore = ${core274_platform.lib_ignore}
extends = esp8266_1M_OTA, core312_platform
build_flags = ${core312_platform.build_flags}
${minimal_OTA_domoticz.build_flags}
build_unflags = ${core312_platform.build_unflags}
extra_scripts = ${core312_platform.extra_scripts}
${esp8266_1M_OTA.extra_scripts}
[env:minimal_core_312_ESP8266_1M_OTA_Domoticz_MQTT]
extends = esp8266_1M_OTA, core312_platform
build_flags = ${core312_platform.build_flags}
${minimal_OTA_domoticz_MQTT.build_flags}
build_unflags = ${core312_platform.build_unflags}
extra_scripts = ${core312_platform.extra_scripts}
${esp8266_1M_OTA.extra_scripts}
[env:minimal_core_312_ESP8266_1M_OTA_FHEM_HA]
extends = esp8266_1M_OTA, core312_platform
build_flags = ${core312_platform.build_flags}
${minimal_OTA_FHEM_HA.build_flags}
build_unflags = ${core312_platform.build_unflags}
extra_scripts = ${core312_platform.extra_scripts}
${esp8266_1M_OTA.extra_scripts}
+5 -3
View File
@@ -102,7 +102,6 @@ String minutesToDayHourMinute(int minutes) {
int hours = (minutes % 1440) / 60;
int mins = (minutes % 1440) % 60;
char TimeString[20] = {0};
sprintf_P(TimeString, PSTR("%d%c%02d%c%02d%c"), days, 'd', hours, 'h', mins, 'm');
return TimeString;
}
@@ -123,8 +122,11 @@ String secondsToDayHourMinuteSecond(int seconds) {
int hours = (minutes % 1440) / 60;
int mins = (minutes % 1440) % 60;
char TimeString[20] = {0};
sprintf_P(TimeString, PSTR("%d%c%02d%c%02d%c%02d"), days, 'd', hours, ':', mins, ':', sec);
if (days == 0) {
sprintf_P(TimeString, PSTR("%02d%c%02d%c%02d"), hours, ':', mins, ':', sec);
} else {
sprintf_P(TimeString, PSTR("%d%c% 02d%c%02d%c%02d"), days, 'd', hours, ':', mins, ':', sec);
}
return TimeString;
}
+21 -44
View File
@@ -300,14 +300,14 @@ String getValue(LabelType::Enum label) {
case LabelType::LOCAL_TIME: return node_time.getDateTimeString('-', ':', ' ');
case LabelType::TIME_SOURCE:
{
String timeSource_str = toString(node_time.timeSource);
if (((node_time.timeSource == timeSource_t::ESPEASY_p2p_UDP) ||
(node_time.timeSource == timeSource_t::ESP_now_peer)) &&
(node_time.timeSource_p2p_unit != 0))
{
return concat(toString(node_time.timeSource), ' ') +
wrap_braces(String(node_time.timeSource_p2p_unit));
return strformat(F("%s (%u)"), timeSource_str.c_str(), node_time.timeSource_p2p_unit);
}
return toString(node_time.timeSource);
return timeSource_str;
}
case LabelType::TIME_WANDER: return String(node_time.timeWander, 1);
#if FEATURE_EXT_RTC
@@ -415,13 +415,14 @@ String getValue(LabelType::Enum label) {
case LabelType::WIFI_CONNECTION: break;
case LabelType::WIFI_RSSI: retval = WiFi.RSSI(); break;
case LabelType::IP_CONFIG: return String(useStaticIP() ? getLabel(LabelType::IP_CONFIG_STATIC) : getLabel(
LabelType::IP_CONFIG_DYNAMIC));
case LabelType::IP_CONFIG: return useStaticIP()
? getLabel(LabelType::IP_CONFIG_STATIC)
: getLabel(LabelType::IP_CONFIG_DYNAMIC);
case LabelType::IP_CONFIG_STATIC: break;
case LabelType::IP_CONFIG_DYNAMIC: break;
case LabelType::IP_ADDRESS: return formatIP(NetworkLocalIP());
case LabelType::IP_SUBNET: return formatIP(NetworkSubnetMask());
case LabelType::IP_ADDRESS_SUBNET: return getValue(LabelType::IP_ADDRESS) + F(" / ") + getValue(LabelType::IP_SUBNET);
case LabelType::IP_ADDRESS_SUBNET: return strformat(F("%s / %s"), getValue(LabelType::IP_ADDRESS).c_str(), getValue(LabelType::IP_SUBNET).c_str());
case LabelType::GATEWAY: return formatIP(NetworkGatewayIP());
case LabelType::CLIENT_IP: return formatIP(web_server.client().remoteIP());
#if FEATURE_INTERNAL_TEMPERATURE
@@ -431,7 +432,7 @@ String getValue(LabelType::Enum label) {
#if FEATURE_MDNS
case LabelType::M_DNS: return NetworkGetHostname() + F(".local");
#endif // if FEATURE_MDNS
case LabelType::DNS: return getValue(LabelType::DNS_1) + F(" / ") + getValue(LabelType::DNS_2);
case LabelType::DNS: return strformat(F("%s / %s"), getValue(LabelType::DNS_1).c_str(), getValue(LabelType::DNS_2).c_str());
case LabelType::DNS_1: return formatIP(NetworkDnsIP(0));
case LabelType::DNS_2: return formatIP(NetworkDnsIP(1));
case LabelType::ALLOWED_IP_RANGE: return describeAllowedIPrange();
@@ -536,8 +537,10 @@ String getValue(LabelType::Enum label) {
#if FEATURE_ETHERNET
case LabelType::ETH_IP_ADDRESS: return formatIP(NetworkLocalIP());
case LabelType::ETH_IP_SUBNET: return formatIP(NetworkSubnetMask());
case LabelType::ETH_IP_ADDRESS_SUBNET: return String(getValue(LabelType::ETH_IP_ADDRESS) + F(" / ") +
getValue(LabelType::ETH_IP_SUBNET));
case LabelType::ETH_IP_ADDRESS_SUBNET: return strformat(
F("%s / %s"),
getValue(LabelType::ETH_IP_ADDRESS).c_str(),
getValue(LabelType::ETH_IP_SUBNET).c_str());
case LabelType::ETH_IP_GATEWAY: return formatIP(NetworkGatewayIP());
case LabelType::ETH_IP_DNS: return formatIP(NetworkDnsIP(0));
case LabelType::ETH_MAC: return NetworkMacAddress().toString();
@@ -559,8 +562,8 @@ String getValue(LabelType::Enum label) {
case LabelType::ISNTP: return jsonBool(Settings.UseNTP());
case LabelType::UPTIME_MS: return ull2String(getMicros64() / 1000);
case LabelType::TIMEZONE_OFFSET: retval = Settings.TimeZone; break;
case LabelType::LATITUDE: return String(Settings.Latitude);
case LabelType::LONGITUDE: return String(Settings.Longitude);
case LabelType::LATITUDE: return toString(Settings.Latitude, 6);
case LabelType::LONGITUDE: return toString(Settings.Longitude, 6);
case LabelType::MAX_LABEL:
break;
@@ -571,29 +574,17 @@ String getValue(LabelType::Enum label) {
#if FEATURE_ETHERNET
String getEthSpeed() {
String result;
result.reserve(7);
result += EthLinkSpeed();
result += F("Mbps");
return result;
return strformat(F("%dMbps"), EthLinkSpeed());
}
String getEthLinkSpeedState() {
String result;
result.reserve(29);
if (EthLinkUp()) {
result += getValue(LabelType::ETH_STATE);
result += ' ';
result += getValue(LabelType::ETH_DUPLEX);
result += ' ';
result += getEthSpeed();
} else {
result = getValue(LabelType::ETH_STATE);
return strformat(F("%s %s %s"),
getValue(LabelType::ETH_STATE).c_str(),
getValue(LabelType::ETH_DUPLEX).c_str(),
getEthSpeed().c_str());
}
return result;
return getValue(LabelType::ETH_STATE);
}
#endif // if FEATURE_ETHERNET
@@ -603,21 +594,7 @@ String getExtendedValue(LabelType::Enum label) {
{
case LabelType::UPTIME:
{
String result;
result.reserve(40);
int minutes = getUptimeMinutes();
int days = minutes / 1440;
minutes = minutes % 1440;
int hrs = minutes / 60;
minutes = minutes % 60;
result += days;
result += F(" days ");
result += hrs;
result += F(" hours ");
result += minutes;
result += F(" minutes");
return result;
return minutesToDayHourMinute(getUptimeMinutes());
}
default:
+4 -2
View File
@@ -468,8 +468,10 @@ void handle_sysinfo_Network() {
const int64_t tsf_time = WiFi_get_TSF_time();
if (tsf_time > 0) {
addRowLabel(F("WiFi TSF time"));
addHtmlInt(WiFi_get_TSF_time());
addUnit(F("usec"));
// Split it while printing, so we're not loosing a lot of decimals in the float conversion
addHtml(secondsToDayHourMinuteSecond(tsf_time / 1000000));
addHtml('.');
addHtmlInt(tsf_time % 1000000);
}
#endif
+10
View File
@@ -0,0 +1,10 @@
Import("env")
env.Replace(
AR="xtensa-lx106-elf-gcc-ar",
RANLIB="xtensa-lx106-elf-gcc-ranlib"
)
# May need to manually change in platform of the esp8266 in folder
# .platformio/../platforms/esp8266xxx in python script builder/main.py