Add enable_full_printf escape hatch

This commit is contained in:
J. Nick Koston
2026-03-08 01:18:02 -10:00
parent 6d3c738de2
commit f28ac86879
2 changed files with 8 additions and 4 deletions
+7 -4
View File
@@ -23,6 +23,7 @@ from esphome.helpers import copy_file_if_changed
from .boards import BOARDS, ESP8266_LD_SCRIPTS
from .const import (
CONF_EARLY_PIN_INIT,
CONF_ENABLE_FULL_PRINTF,
CONF_ENABLE_SERIAL,
CONF_ENABLE_SERIAL1,
CONF_RESTORE_FROM_FLASH,
@@ -179,6 +180,7 @@ CONFIG_SCHEMA = cv.All(
),
cv.Optional(CONF_ENABLE_SERIAL): cv.boolean,
cv.Optional(CONF_ENABLE_SERIAL1): cv.boolean,
cv.Optional(CONF_ENABLE_FULL_PRINTF, default=False): cv.boolean,
}
),
set_core_data,
@@ -260,10 +262,11 @@ async def to_code(config):
if CORE.testing_mode:
cg.add_build_flag("-DESPHOME_TESTING_MODE")
# Wrap FILE*-based printf functions to eliminate newlib's _vfprintf_r
# (~900 bytes). See printf_stubs.cpp for implementation.
for symbol in ("vprintf", "printf", "fprintf"):
cg.add_build_flag(f"-Wl,--wrap={symbol}")
# 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):
for symbol in ("vprintf", "printf", "fprintf"):
cg.add_build_flag(f"-Wl,--wrap={symbol}")
cg.add_platformio_option("board_build.flash_mode", config[CONF_BOARD_FLASH_MODE])
+1
View File
@@ -6,6 +6,7 @@ KEY_BOARD = "board"
KEY_PIN_INITIAL_STATES = "pin_initial_states"
CONF_RESTORE_FROM_FLASH = "restore_from_flash"
CONF_EARLY_PIN_INIT = "early_pin_init"
CONF_ENABLE_FULL_PRINTF = "enable_full_printf"
CONF_ENABLE_SERIAL = "enable_serial"
CONF_ENABLE_SERIAL1 = "enable_serial1"
KEY_FLASH_SIZE = "flash_size"