mirror of
https://github.com/esphome/esphome.git
synced 2026-05-22 01:42:49 +08:00
Add enable_full_printf escape hatch
This commit is contained in:
@@ -21,7 +21,13 @@ from esphome.const import (
|
||||
from esphome.core import CORE, CoroPriority, EsphomeError, coroutine_with_priority
|
||||
from esphome.helpers import copy_file_if_changed, read_file, write_file_if_changed
|
||||
|
||||
from .const import KEY_BOARD, KEY_PIO_FILES, KEY_RP2040, rp2040_ns
|
||||
from .const import (
|
||||
CONF_ENABLE_FULL_PRINTF,
|
||||
KEY_BOARD,
|
||||
KEY_PIO_FILES,
|
||||
KEY_RP2040,
|
||||
rp2040_ns,
|
||||
)
|
||||
|
||||
# force import gpio to register pin schema
|
||||
from .gpio import rp2040_pin_to_code # noqa
|
||||
@@ -153,6 +159,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.positive_time_period_milliseconds,
|
||||
cv.Range(max=cv.TimePeriod(milliseconds=8388)),
|
||||
),
|
||||
cv.Optional(CONF_ENABLE_FULL_PRINTF, default=False): cv.boolean,
|
||||
}
|
||||
),
|
||||
set_core_data,
|
||||
@@ -191,9 +198,12 @@ async def to_code(config):
|
||||
)
|
||||
|
||||
# Wrap FILE*-based printf functions to eliminate newlib's _vfprintf_r
|
||||
# (~8.9 KB). See printf_stubs.cpp for implementation.
|
||||
for symbol in ("vprintf", "printf", "fprintf"):
|
||||
cg.add_build_flag(f"-Wl,--wrap={symbol}")
|
||||
# (~9.2 KB). See printf_stubs.cpp for implementation.
|
||||
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}")
|
||||
|
||||
cg.add_platformio_option("board_build.core", "earlephilhower")
|
||||
cg.add_platformio_option("board_build.filesystem_size", "1m")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import esphome.codegen as cg
|
||||
|
||||
CONF_ENABLE_FULL_PRINTF = "enable_full_printf"
|
||||
KEY_BOARD = "board"
|
||||
KEY_RP2040 = "rp2040"
|
||||
KEY_PIO_FILES = "pio_files"
|
||||
|
||||
Reference in New Issue
Block a user