diff --git a/esphome/components/api/api_frame_helper_noise.cpp b/esphome/components/api/api_frame_helper_noise.cpp index 5b60cee143..0781c501e5 100644 --- a/esphome/components/api/api_frame_helper_noise.cpp +++ b/esphome/components/api/api_frame_helper_noise.cpp @@ -489,7 +489,7 @@ APIError APINoiseFrameHelper::encrypt_noise_message_(uint8_t *buf_start, const M } // Outlined multi-message path to keep the single-message fast path's stack frame small. -APIError __attribute__((noinline)) +APIError __attribute__((noinline, flatten)) APINoiseFrameHelper::write_protobuf_messages_batch_(uint8_t *buffer_data, std::span messages) { StaticVector iovs; uint16_t total_write_len = 0; diff --git a/esphome/components/api/api_frame_helper_plaintext.cpp b/esphome/components/api/api_frame_helper_plaintext.cpp index 64c8882afa..9d560a0333 100644 --- a/esphome/components/api/api_frame_helper_plaintext.cpp +++ b/esphome/components/api/api_frame_helper_plaintext.cpp @@ -288,7 +288,7 @@ static inline uint8_t *write_plaintext_header(uint8_t *buf_start, const MessageI // Outlined multi-message path to keep the single-message fast path's stack frame small. // The StaticVector would force a ~300-byte stack frame // even when only sending one message if it were in the same function. -APIError __attribute__((noinline)) +APIError __attribute__((noinline, flatten)) APIPlaintextFrameHelper::write_protobuf_messages_batch_(uint8_t *buffer_data, std::span messages) { StaticVector iovs; uint16_t total_write_len = 0;