mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 23:37:34 +00:00
Fix comments: ESP8266 logging uses Serial, not ets_printf
This commit is contained in:
@@ -264,7 +264,9 @@ async def to_code(config):
|
||||
|
||||
# Wrap FILE*-based printf functions to eliminate newlib's _vfiprintf_r
|
||||
# (~1.6 KB). See printf_stubs.cpp for implementation.
|
||||
if not config.get(CONF_ENABLE_FULL_PRINTF):
|
||||
if config.get(CONF_ENABLE_FULL_PRINTF):
|
||||
cg.add_define("USE_FULL_PRINTF")
|
||||
else:
|
||||
for symbol in ("vprintf", "printf", "fprintf"):
|
||||
cg.add_build_flag(f"-Wl,--wrap={symbol}")
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
*
|
||||
* The ESP8266 Arduino framework and libraries may reference printf(),
|
||||
* vprintf(), and fprintf() which pull in newlib's _vfprintf_r (~900 bytes).
|
||||
* ESPHome never uses these — all logging goes through ets_printf/ets_vsnprintf
|
||||
* directly, so the libc FILE*-based printf path is dead code.
|
||||
* ESPHome never uses these — all logging writes directly to the UART via
|
||||
* Arduino's Serial, so the libc FILE*-based printf path is dead code.
|
||||
*
|
||||
* These stubs redirect through vsnprintf() (which is already in the binary
|
||||
* for ESPHome's logging) and fwrite(), allowing the linker to dead-code
|
||||
* eliminate _vfprintf_r.
|
||||
*
|
||||
* Saves ~900 bytes of flash.
|
||||
* Saves ~1.6 KB of flash.
|
||||
*/
|
||||
|
||||
#if defined(USE_ESP8266) && !defined(USE_FULL_PRINTF)
|
||||
@@ -22,8 +22,8 @@ namespace esphome::esp8266 {}
|
||||
|
||||
static constexpr size_t PRINTF_BUFFER_SIZE = 256;
|
||||
|
||||
// These stubs are essentially dead code at runtime — ESPHome uses ets_printf
|
||||
// for logging, and the Arduino core's Serial.printf() has its own implementation.
|
||||
// These stubs are essentially dead code at runtime — ESPHome writes directly
|
||||
// to the UART via Arduino's Serial, and Serial.printf() has its own implementation.
|
||||
// The buffer overflow check is purely defensive and should never trigger.
|
||||
static int write_printf_buffer(FILE *stream, char *buf, int len) {
|
||||
if (len < 0) {
|
||||
|
||||
Reference in New Issue
Block a user