From 72892b89133fabb3930f2e4dca64147e25e3be32 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 6 Jan 2026 00:31:40 -1000 Subject: [PATCH] fix --- esphome/components/esphome/ota/__init__.py | 2 +- esphome/components/esphome/ota/ota_esphome.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/esphome/components/esphome/ota/__init__.py b/esphome/components/esphome/ota/__init__.py index 2f637d714d..f6b6e80d97 100644 --- a/esphome/components/esphome/ota/__init__.py +++ b/esphome/components/esphome/ota/__init__.py @@ -28,7 +28,7 @@ CODEOWNERS = ["@esphome/core"] DEPENDENCIES = ["network"] -AUTO_LOAD = ["sha256", "socket"] +AUTO_LOAD = ["md5", "sha256", "socket"] esphome = cg.esphome_ns.namespace("esphome") diff --git a/esphome/components/esphome/ota/ota_esphome.cpp b/esphome/components/esphome/ota/ota_esphome.cpp index dccaf781d8..7669cffcd9 100644 --- a/esphome/components/esphome/ota/ota_esphome.cpp +++ b/esphome/components/esphome/ota/ota_esphome.cpp @@ -1,6 +1,7 @@ #include "ota_esphome.h" #ifdef USE_OTA #ifdef USE_OTA_PASSWORD +#include "esphome/components/md5/md5.h" #include "esphome/components/sha256/sha256.h" #endif #include "esphome/components/network/util.h" @@ -575,8 +576,11 @@ bool ESPHomeOTAComponent::handle_auth_send_() { // CRITICAL ESP32-S3 HARDWARE SHA ACCELERATION: Hash object must stay in same stack frame // (no passing to other functions). All hash operations must happen in this function. - // Create hasher AFTER heap allocations to avoid potential cache/DMA interference. + // NOTE: On ESP32-S3 with IDF 5.5.x, having only SHA256 on the stack causes crashes with + // hardware SHA acceleration. Adding an MD5 object provides the necessary stack alignment. sha256::SHA256 hasher; + md5::MD5Digest md5_dummy; // Required for ESP32-S3 IDF 5.5.x stack alignment + (void) md5_dummy; // Suppress unused variable warning hasher.init(); hasher.add(buf, nonce_len); hasher.calculate(); @@ -636,7 +640,11 @@ bool ESPHomeOTAComponent::handle_auth_read_() { // CRITICAL ESP32-S3 HARDWARE SHA ACCELERATION: Hash object must stay in same stack frame // (no passing to other functions). All hash operations must happen in this function. + // NOTE: On ESP32-S3 with IDF 5.5.x, having only SHA256 on the stack causes crashes with + // hardware SHA acceleration. Adding an MD5 object provides the necessary stack alignment. sha256::SHA256 hasher; + md5::MD5Digest md5_dummy; // Required for ESP32-S3 IDF 5.5.x stack alignment + (void) md5_dummy; // Suppress unused variable warning hasher.init(); hasher.add(this->password_.c_str(), this->password_.length());