message_name() returned bare string literals that stayed in RAM on
ESP8266. Change return type to const LogString * and wrap with LOG_STR()
so they are stored in flash. Update log_send_message_ to use
LOG_STR_ARG() accordingly.
Also fix clang-tidy: rename append_p_esp8266_ to append_p_esp8266,
add NOLINTNEXTLINE for conditionally-unused dump_field overloads.
All string literals in api_pb2_dump.cpp (field names, message names,
enum value names) were stored in rodata which occupies RAM on ESP8266.
This meant every API protobuf change appeared as a RAM increase in CI
when using very_verbose logging.
Add append_p() to DumpBuffer for PROGMEM-safe string reading and update
the code generator to wrap all dump string literals with ESPHOME_PSTR().
On non-ESP8266 platforms, these are no-ops with zero overhead.
Guard detection_range_to_log_string() with #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
so it is compiled out when the log level is below DEBUG, matching its callers
(ESP_LOGD and ESP_LOGCONFIG) which are also compiled out at that level.
Fixes https://github.com/esphome/esphome/issues/14975
Move logger codegen priority above platform init so that
global_logger is set before setup_preferences() or any other
platform code that may contain ESP_LOG* calls.
Previously the logger initialized at DIAGNOSTICS priority (90),
which ran after PLATFORM (1000). With VERY_VERBOSE, the
ESP_LOGVV in ESP8266Preferences::setup() fired before
global_logger was set, causing a nullptr dereference crash.
Also hardcode `using namespace esphome;` in writer.py so it
precedes all variable declarations regardless of codegen
priority ordering.
Fixes#14970
Clear residual IOMUX function on UART0 default pins before calling
uart_set_pin(). The ROM bootloader configures these pins via IOMUX
for console output. ESP-IDF's uart_set_pin() has an asymmetry: when
routing TX via GPIO matrix it calls gpio_func_sel(PIN_FUNC_GPIO) to
clear IOMUX, but for RX it only calls gpio_input_enable() which does
NOT clear the IOMUX function select.
If a default UART0 TX pin is later reassigned as RX via GPIO matrix
(common on ESP32-C3 where users swap GPIO20/GPIO21), the old IOMUX TX
function remains active, causing transmitted data to loop back into RX.
This is a targeted fix using gpio_func_sel() which only writes the
IO MUX function register - unlike the previous gpio_reset_pin()
approach which also changed direction, pulls, and drive strength,
breaking external components that rely on default pin state (#11823).
Fixes#14973Fixes#14612
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>