From e64aff28e76c419337ce3ccf6f9496ff06230294 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 21 Jul 2023 22:46:20 +0200 Subject: [PATCH] (experimental) compiler optimization for speed instead of size only for [env:esp32_4MB_S] and [env:esp32_16MB_V4_S] --- platformio.ini | 52 ++++++++++++++++++++++++++++++++++++++++++++++---- wled00/wled.h | 2 +- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/platformio.ini b/platformio.ini index 46925922..d2ca8123 100644 --- a/platformio.ini +++ b/platformio.ini @@ -44,7 +44,7 @@ ; =================== default_envs = - ; esp32_4MB_S + ; esp32_4MB_S ;; experimental, optimized for speed esp32_4MB_M ; recommended default esp32_4MB_M_debug esp32_4MB_XL @@ -71,6 +71,7 @@ default_envs = esp32c3dev_4MB_M ;; experimental seeed_esp32c3_4MB_S ;; experimental esp32_4MB_V4_S ;; experimental + esp32_16MB_V4_S ;; experimental, optimized for speed esp32_16MB_V4_M ;; experimental esp32_16MB_V4_M_debug ;; experimental esp8266pro_16MB_S @@ -1068,6 +1069,15 @@ build_flags = ; -D MIC_LOGGER ; for sound input monitoring & debugging (use arduino serial plotter) ; NetDebug moved to build_flags_M +[Speed_Flags] +build_flags = + -O2 ;; optimize for performance instead of size + ;-O3 ;; try this to optimize even more + -mtarget-align -free -fipa-pta ;; these are very useful, too + -fno-jump-tables -fno-tree-switch-conversion ;; needed + -freorder-blocks -Wwrite-strings -fstrict-volatile-bitfields ;; needed +build_unflags = + -Os ;; to disable standard optimization for size ; end of base entries @@ -1076,11 +1086,24 @@ build_flags = [env:esp32_4MB_S] extends = esp32_4MB_S_base +build_unflags = ${esp32_4MB_S_base.build_unflags} + ${Speed_Flags.build_unflags} ;; to override -Os build_flags = ${esp32_4MB_S_base.build_flags} + ${Speed_Flags.build_flags} ;; -O2 -> optimize for speed instead of size -D WLED_RELEASE_NAME=esp32_4MB_S -D WLEDMM_FASTPATH ; WLEDMM experimental option. Reduces audio lag (latency), and allows for faster LED framerates. May break compatibility with previous versions. + ;; for speed builds, we need to disable some features to stay within 4MB flash + ;-D WLED_DISABLE_ALEXA + -D WLED_DISABLE_HUESYNC + -D WLED_DISABLE_LOXONE + ;-D WLED_DISABLE_MQTT + ;-D WLED_DISABLE_INFRARED +;; normal build ; RAM: [=== ] 25.0% (used 81988 bytes from 327680 bytes) ; Flash: [========= ] 87.4% (used 1374677 bytes from 1572864 bytes) WLEDMM: Earlier 85.7 +;; optimized-for-speed build +; RAM: [=== ] 25.1% (used 82092 bytes from 327680 bytes) +; Flash: [==========] 98.8% (used 1553629 bytes from 1572864 bytes) [env:esp32_4MB_M] extends = esp32_4MB_M_base @@ -1336,9 +1359,9 @@ build_flags = ${esp32_4MB_V4_S_base.build_flags} ; -D WLED_DEBUG ; -D SR_DEBUG ; -D MIC_LOGGER - ; RAM: [== ] 24.2% (used 79372 bytes from 327680 bytes) - ; Flash: [========= ] 88.8% (used 1396073 bytes from 1572864 bytes) -;lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation +lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation + ; RAM: [=== ] 25.1% (used 82176 bytes from 327680 bytes) + ; Flash: [========= ] 93.8% (used 1474893 bytes from 1572864 bytes) ; compiled with ESP-IDF 4.4.1 [env:esp32_4MB_V4_M] @@ -1356,6 +1379,27 @@ lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compila ;; RAM: [== ] 24.7% (used 80884 bytes from 327680 bytes) ;; Flash: [==========] 99.0% (used 1556429 bytes from 1572864 bytes) +;; V4 build for 16MB flash, optimized for speed +[env:esp32_16MB_V4_S] +extends = esp32_4MB_V4_S_base +build_unflags = ${esp32_4MB_V4_S_base.build_unflags} + ${Speed_Flags.build_unflags} ;; to override -Os +build_flags = ${esp32_4MB_V4_S_base.build_flags} + ${Speed_Flags.build_flags} ;; optimize for speed instead of size + -D WLED_RELEASE_NAME=esp32_16MB_V4_S + -D WLED_WATCHDOG_TIMEOUT=0 #-D WLED_DISABLE_BROWNOUT_DET + -D ARDUINO_USB_CDC_ON_BOOT=0 ; needed for arduino-esp32 >=2.0.4; avoids errors on startup + -D WLEDMM_FASTPATH ; WLEDMM experimental option. Reduces audio lag (latency), and allows for faster LED framerates. May break compatibility with previous versions. +board = esp32_16MB +board_build.partitions = tools/WLED_ESP32_16MB.csv ;; WLED standard for 16MB flash: 2MB firmware, 12 MB filesystem +;board_build.partitions = tools/WLED_ESP32_16MB_9MB_FS.csv ;; WLED extended for 16MB flash: 3.2MB firmware, 9 MB filesystem +;; normal build +; RAM: [=== ] 25.4% (used 83312 bytes from 327680 bytes) +; Flash: [======= ] 73.3% (used 1536317 bytes from 2097152 bytes) +;; optimized-for-speed build +; RAM: [=== ] 25.4% (used 83376 bytes from 327680 bytes) +; Flash: [======== ] 82.9% (used 1739469 bytes from 2097152 bytes) + ; compiled with ESP-IDF 4.4.1 [env:esp32_16MB_V4_M] extends = esp32_4MB_V4_M_base diff --git a/wled00/wled.h b/wled00/wled.h index d33a25a9..7701edeb 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2307150 +#define VERSION 2307210 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG