From 23ce580a28e40ad2f4ec1bce8806138b492e0133 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Sat, 29 Nov 2025 21:26:24 +0100 Subject: [PATCH] post-merge * reduce memory footprint by removing all unneeded functions in ota_update.cpp * don't compile ota_update.cpp when WLED_DISABLE_OTA is defined --- wled00/ota_update.cpp | 17 ++++++++++++----- wled00/ota_update.h | 8 ++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/wled00/ota_update.cpp b/wled00/ota_update.cpp index e0a3c3c8..f108c06d 100644 --- a/wled00/ota_update.cpp +++ b/wled00/ota_update.cpp @@ -1,3 +1,5 @@ +#if defined(ARDUINO_ARCH_ESP32) && !defined(WLED_DISABLE_OTA) // WLEDMM we only want getBootloaderSHA256Hex() + #include "ota_update.h" #include "wled.h" @@ -31,6 +33,9 @@ constexpr size_t METADATA_OFFSET = 0x1000; // ESP8266: metadata appears at 4 #endif constexpr size_t METADATA_SEARCH_RANGE = 512; // bytes +#endif + +#if 0 // WLEDMM not needed - we only want getBootloaderSHA256Hex(); /** * Check if OTA should be allowed based on release compatibility using custom description @@ -75,7 +80,7 @@ struct UpdateContext { // Buffer to hold block data across posts, if needed std::vector releaseMetadataBuffer; -}; +} static void endOTA(AsyncWebServerRequest *request) { @@ -106,7 +111,7 @@ static void endOTA(AsyncWebServerRequest *request) { } delete context; } -}; +} static bool beginOTA(AsyncWebServerRequest *request, UpdateContext* context) { @@ -271,11 +276,13 @@ void handleOTAData(AsyncWebServerRequest *request, size_t index, uint8_t *data, } } +#endif + #if defined(ARDUINO_ARCH_ESP32) && !defined(WLED_DISABLE_OTA) static String bootloaderSHA256HexCache = ""; // Calculate and cache the bootloader SHA256 digest as hex string -void calculateBootloaderSHA256() { +static void calculateBootloaderSHA256() { if (!bootloaderSHA256HexCache.isEmpty()) return; // Calculate SHA256 @@ -317,7 +324,7 @@ String getBootloaderSHA256Hex() { } // Invalidate cached bootloader SHA256 (call after bootloader update) -void invalidateBootloaderSHA256Cache() { +static void invalidateBootloaderSHA256Cache() { bootloaderSHA256HexCache = ""; } -#endif \ No newline at end of file +#endif diff --git a/wled00/ota_update.h b/wled00/ota_update.h index 6513e975..1181e43f 100644 --- a/wled00/ota_update.h +++ b/wled00/ota_update.h @@ -9,6 +9,8 @@ #pragma once +#if 0 // WLEDMM not needed - we only want getBootloaderSHA256Hex(); + // Platform-specific metadata locations #ifdef ESP32 #define BUILD_METADATA_SECTION ".rodata_custom_desc" @@ -51,12 +53,14 @@ std::pair getOTAResult(AsyncWebServerRequest *request); */ void handleOTAData(AsyncWebServerRequest *request, size_t index, uint8_t *data, size_t len, bool isFinal); +#endif + #if defined(ARDUINO_ARCH_ESP32) && !defined(WLED_DISABLE_OTA) /** * Calculate and cache the bootloader SHA256 digest * Reads the bootloader from flash at offset 0x1000 and computes SHA256 hash */ -void calculateBootloaderSHA256(); +static void calculateBootloaderSHA256(); /** * Get bootloader SHA256 as hex string @@ -68,5 +72,5 @@ String getBootloaderSHA256Hex(); * Invalidate cached bootloader SHA256 (call after bootloader update) * Forces recalculation on next call to calculateBootloaderSHA256 or getBootloaderSHA256Hex */ -void invalidateBootloaderSHA256Cache(); +static void invalidateBootloaderSHA256Cache(); #endif