mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 16:38:16 +01:00
[Logger] ESP32 S3 serial logger (#4853)
* Add support for ESP32 S3 logger. * fix default * Remove cpp & h changes to combine with PR #4658 * Not enough attention to details. * Add build flag * Validation fix * Fix validation for real this time --------- Co-authored-by: Your Name <you@example.com> Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
This commit is contained in:
parent
777cdb1c21
commit
8c37066ed9
2 changed files with 58 additions and 5 deletions
|
@ -97,7 +97,7 @@ UART_SELECTION_LIBRETINY = {
|
|||
COMPONENT_RTL87XX: [DEFAULT, UART0, UART1, UART2],
|
||||
}
|
||||
|
||||
ESP_IDF_UARTS = [USB_CDC, USB_SERIAL_JTAG]
|
||||
ESP_ARDUINO_UNSUPPORTED_USB_UARTS = [USB_SERIAL_JTAG]
|
||||
|
||||
UART_SELECTION_RP2040 = [USB_CDC, UART0, UART1]
|
||||
|
||||
|
@ -124,6 +124,8 @@ is_log_level = cv.one_of(*LOG_LEVELS, upper=True)
|
|||
|
||||
def uart_selection(value):
|
||||
if CORE.is_esp32:
|
||||
if CORE.using_arduino and value.upper() in ESP_ARDUINO_UNSUPPORTED_USB_UARTS:
|
||||
raise cv.Invalid(f"Arduino framework does not support {value}.")
|
||||
variant = get_esp32_variant()
|
||||
if variant in UART_SELECTION_ESP32:
|
||||
return cv.one_of(*UART_SELECTION_ESP32[variant], upper=True)(value)
|
||||
|
@ -169,6 +171,8 @@ CONFIG_SCHEMA = cv.All(
|
|||
CONF_HARDWARE_UART,
|
||||
esp8266=UART0,
|
||||
esp32=UART0,
|
||||
esp32_s2=USB_CDC,
|
||||
esp32_s3=USB_CDC,
|
||||
rp2040=USB_CDC,
|
||||
bk72xx=DEFAULT,
|
||||
rtl87xx=DEFAULT,
|
||||
|
@ -256,6 +260,10 @@ async def to_code(config):
|
|||
if config.get(CONF_ESP8266_STORE_LOG_STRINGS_IN_FLASH):
|
||||
cg.add_build_flag("-DUSE_STORE_LOG_STR_IN_FLASH")
|
||||
|
||||
if CORE.using_arduino:
|
||||
if config[CONF_HARDWARE_UART] == USB_CDC:
|
||||
cg.add_build_flag("-DARDUINO_USB_CDC_ON_BOOT=1")
|
||||
|
||||
if CORE.using_esp_idf:
|
||||
if config[CONF_HARDWARE_UART] == USB_CDC:
|
||||
add_idf_sdkconfig_option("CONFIG_ESP_CONSOLE_USB_CDC", True)
|
||||
|
|
|
@ -1528,6 +1528,12 @@ class SplitDefault(Optional):
|
|||
esp32=vol.UNDEFINED,
|
||||
esp32_arduino=vol.UNDEFINED,
|
||||
esp32_idf=vol.UNDEFINED,
|
||||
esp32_s2=vol.UNDEFINED,
|
||||
esp32_s2_arduino=vol.UNDEFINED,
|
||||
esp32_s2_idf=vol.UNDEFINED,
|
||||
esp32_s3=vol.UNDEFINED,
|
||||
esp32_s3_arduino=vol.UNDEFINED,
|
||||
esp32_s3_idf=vol.UNDEFINED,
|
||||
rp2040=vol.UNDEFINED,
|
||||
bk72xx=vol.UNDEFINED,
|
||||
rtl87xx=vol.UNDEFINED,
|
||||
|
@ -1541,6 +1547,26 @@ class SplitDefault(Optional):
|
|||
self._esp32_idf_default = vol.default_factory(
|
||||
esp32_idf if esp32 is vol.UNDEFINED else esp32
|
||||
)
|
||||
self._esp32_s2_arduino_default = vol.default_factory(
|
||||
(esp32_s2_arduino if esp32 is vol.UNDEFINED else esp32)
|
||||
if esp32_s2 is vol.UNDEFINED
|
||||
else esp32_s2
|
||||
)
|
||||
self._esp32_s2_idf_default = vol.default_factory(
|
||||
(esp32_s2_idf if esp32 is vol.UNDEFINED else esp32)
|
||||
if esp32_s2 is vol.UNDEFINED
|
||||
else esp32_s2
|
||||
)
|
||||
self._esp32_s3_arduino_default = vol.default_factory(
|
||||
(esp32_s3_arduino if esp32 is vol.UNDEFINED else esp32)
|
||||
if esp32_s3 is vol.UNDEFINED
|
||||
else esp32_s3
|
||||
)
|
||||
self._esp32_s3_idf_default = vol.default_factory(
|
||||
(esp32_s3_idf if esp32 is vol.UNDEFINED else esp32)
|
||||
if esp32_s3 is vol.UNDEFINED
|
||||
else esp32_s3
|
||||
)
|
||||
self._rp2040_default = vol.default_factory(rp2040)
|
||||
self._bk72xx_default = vol.default_factory(bk72xx)
|
||||
self._rtl87xx_default = vol.default_factory(rtl87xx)
|
||||
|
@ -1550,9 +1576,28 @@ class SplitDefault(Optional):
|
|||
def default(self):
|
||||
if CORE.is_esp8266:
|
||||
return self._esp8266_default
|
||||
if CORE.is_esp32 and CORE.using_arduino:
|
||||
if CORE.is_esp32:
|
||||
from esphome.components.esp32 import get_esp32_variant
|
||||
from esphome.components.esp32.const import (
|
||||
VARIANT_ESP32S2,
|
||||
VARIANT_ESP32S3,
|
||||
)
|
||||
|
||||
variant = get_esp32_variant()
|
||||
if variant == VARIANT_ESP32S2:
|
||||
if CORE.using_arduino:
|
||||
return self._esp32_s2_arduino_default
|
||||
if CORE.using_esp_idf:
|
||||
return self._esp32_s2_idf_default
|
||||
elif variant == VARIANT_ESP32S3:
|
||||
if CORE.using_arduino:
|
||||
return self._esp32_s3_arduino_default
|
||||
if CORE.using_esp_idf:
|
||||
return self._esp32_s3_idf_default
|
||||
else:
|
||||
if CORE.using_arduino:
|
||||
return self._esp32_arduino_default
|
||||
if CORE.is_esp32 and CORE.using_esp_idf:
|
||||
if CORE.using_esp_idf:
|
||||
return self._esp32_idf_default
|
||||
if CORE.is_rp2040:
|
||||
return self._rp2040_default
|
||||
|
|
Loading…
Reference in a new issue