From da5f67af693a7dc7b77307c2fcc19dd9762e937f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 20 Feb 2026 20:30:29 -0600 Subject: [PATCH] Reduce logger UART RX buffer to minimum The logger only writes to UART, never reads. Previously it used tx_buffer_size (512 bytes) for both RX and TX buffers. Since ESP-IDF requires rx_buffer_size > UART_HW_FIFO_LEN (128), use the minimum of 129 bytes instead of 512, saving ~383 bytes of heap. Co-Authored-By: Claude Opus 4.6 --- esphome/components/logger/logger_esp32.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/components/logger/logger_esp32.cpp b/esphome/components/logger/logger_esp32.cpp index 23bed89ec2..9d64771aec 100644 --- a/esphome/components/logger/logger_esp32.cpp +++ b/esphome/components/logger/logger_esp32.cpp @@ -77,8 +77,10 @@ void init_uart(uart_port_t uart_num, uint32_t baud_rate, int tx_buffer_size) { uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE; uart_config.source_clk = UART_SCLK_DEFAULT; uart_param_config(uart_num, &uart_config); - const int uart_buffer_size = tx_buffer_size; - uart_driver_install(uart_num, uart_buffer_size, uart_buffer_size, 0, nullptr, 0); + // The logger only writes to UART, never reads, so use the minimum RX buffer. + // ESP-IDF requires rx_buffer_size > UART_HW_FIFO_LEN (128 bytes). + const int min_rx_buffer_size = UART_HW_FIFO_LEN(uart_num) + 1; + uart_driver_install(uart_num, min_rx_buffer_size, tx_buffer_size, 0, nullptr, 0); } void Logger::pre_setup() {