[logger] Fix USB JTAG VFS symbols linked when logging is disabled (#15721)

Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
Jon Little
2026-06-03 15:54:34 -05:00
committed by GitHub
parent 7b8cbe2de1
commit 92819d8658
6 changed files with 36 additions and 5 deletions

View File

@@ -461,7 +461,11 @@ async def _late_logger_init(config: ConfigType) -> None:
cg.add_define("USE_LOGGER_USB_SERIAL_JTAG")
# USB Serial JTAG code is compiled when platform supports it.
# Enable secondary USB serial JTAG console so the VFS functions are available.
if CORE.is_esp32 and config[CONF_HARDWARE_UART] != USB_SERIAL_JTAG:
if (
CORE.is_esp32
and config[CONF_HARDWARE_UART] != USB_SERIAL_JTAG
and has_serial_logging
):
require_usb_serial_jtag_secondary()
require_vfs_termios()
except cv.Invalid:

View File

@@ -6,7 +6,7 @@
#include <driver/uart.h>
#ifdef USE_LOGGER_USB_SERIAL_JTAG
#ifdef USE_LOGGER_UART_SELECTION_USB_SERIAL_JTAG
#include <driver/usb_serial_jtag.h>
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
#include <esp_vfs_dev.h>
@@ -29,7 +29,7 @@ namespace esphome::logger {
static const char *const TAG = "logger";
#ifdef USE_LOGGER_USB_SERIAL_JTAG
#ifdef USE_LOGGER_UART_SELECTION_USB_SERIAL_JTAG
static void init_usb_serial_jtag_() {
setvbuf(stdin, NULL, _IONBF, 0); // Disable buffering on stdin
@@ -108,7 +108,9 @@ void Logger::pre_setup() {
#endif
#ifdef USE_LOGGER_USB_SERIAL_JTAG
case UART_SELECTION_USB_SERIAL_JTAG:
#ifdef USE_LOGGER_UART_SELECTION_USB_SERIAL_JTAG
init_usb_serial_jtag_();
#endif
break;
#endif
}

View File

@@ -358,11 +358,12 @@
#define USE_LOGGER_USB_SERIAL_JTAG
#elif defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C5) || \
defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32C61) || defined(USE_ESP32_VARIANT_ESP32H2) || \
defined(USE_ESP32_VARIANT_ESP32H4) || defined(USE_ESP32_VARIANT_ESP32P4) || defined(USE_ESP32_VARIANT_ESP32S3) || \
defined(USE_ESP32_VARIANT_ESP32S31)
defined(USE_ESP32_VARIANT_ESP32H21) || defined(USE_ESP32_VARIANT_ESP32H4) || defined(USE_ESP32_VARIANT_ESP32P4) || \
defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32S31)
#define USE_LOGGER_USB_CDC
#define USE_LOGGER_UART_SELECTION_USB_CDC
#define USE_LOGGER_USB_SERIAL_JTAG
#define USE_LOGGER_UART_SELECTION_USB_SERIAL_JTAG
#endif
#endif

View File

@@ -0,0 +1,3 @@
logger:
hardware_uart: UART0
baud_rate: 0

View File

@@ -0,0 +1 @@
<<: !include common-uart0_no_logging.yaml

View File

@@ -0,0 +1,20 @@
esphome:
name: componenttestesp32h2idf
friendly_name: $component_name
esp32:
board: esp32-h2-devkitm-1
framework:
type: esp-idf
# Use custom partition table with larger app partition (3MB)
# Default IDF partitions only allow 1.75MB which is too small for grouped tests
partitions: ../partitions_testing.csv
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_test_file: $component_test_file