From 1a8e7854c7548322402f4d70de528d0b7f66fdb1 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Fri, 15 Dec 2023 11:24:52 +1100 Subject: [PATCH 1/6] ESP32-S3 and ESP-IDF don't play well with USB_CDC and need USB_SERIAL_JTAG (#5929) Co-authored-by: Keith Burzinski --- esphome/components/logger/__init__.py | 4 +- esphome/config_validation.py | 27 +++++++--- tests/test8.1.yaml | 78 +++++++++++++++++++++++++++ tests/test8.2.yaml | 75 ++++++++++++++++++++++++++ 4 files changed, 177 insertions(+), 7 deletions(-) create mode 100644 tests/test8.1.yaml create mode 100644 tests/test8.2.yaml diff --git a/esphome/components/logger/__init__.py b/esphome/components/logger/__init__.py index be302bd489..6cad783db9 100644 --- a/esphome/components/logger/__init__.py +++ b/esphome/components/logger/__init__.py @@ -172,7 +172,9 @@ CONFIG_SCHEMA = cv.All( esp8266=UART0, esp32=UART0, esp32_s2=USB_CDC, - esp32_s3=USB_CDC, + esp32_s3_idf=USB_SERIAL_JTAG, + esp32_c3_idf=USB_SERIAL_JTAG, + esp32_s3_arduino=USB_CDC, rp2040=USB_CDC, bk72xx=DEFAULT, rtl87xx=DEFAULT, diff --git a/esphome/config_validation.py b/esphome/config_validation.py index 7b94608509..8f2e080b46 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -1541,6 +1541,9 @@ class SplitDefault(Optional): esp32_s3=vol.UNDEFINED, esp32_s3_arduino=vol.UNDEFINED, esp32_s3_idf=vol.UNDEFINED, + esp32_c3=vol.UNDEFINED, + esp32_c3_arduino=vol.UNDEFINED, + esp32_c3_idf=vol.UNDEFINED, rp2040=vol.UNDEFINED, bk72xx=vol.UNDEFINED, rtl87xx=vol.UNDEFINED, @@ -1549,22 +1552,28 @@ class SplitDefault(Optional): super().__init__(key) self._esp8266_default = vol.default_factory(esp8266) self._esp32_arduino_default = vol.default_factory( - _get_priority_default(esp32, esp32_arduino) + _get_priority_default(esp32_arduino, esp32) ) self._esp32_idf_default = vol.default_factory( - _get_priority_default(esp32, esp32_idf) + _get_priority_default(esp32_idf, esp32) ) self._esp32_s2_arduino_default = vol.default_factory( - _get_priority_default(esp32_s2, esp32, esp32_s2_arduino, esp32_arduino) + _get_priority_default(esp32_s2_arduino, esp32_s2, esp32_arduino, esp32) ) self._esp32_s2_idf_default = vol.default_factory( - _get_priority_default(esp32_s2, esp32, esp32_s2_idf, esp32_idf) + _get_priority_default(esp32_s2_idf, esp32_s2, esp32_idf, esp32) ) self._esp32_s3_arduino_default = vol.default_factory( - _get_priority_default(esp32_s3, esp32, esp32_s3_arduino, esp32_arduino) + _get_priority_default(esp32_s3_arduino, esp32_s3, esp32_arduino, esp32) ) self._esp32_s3_idf_default = vol.default_factory( - _get_priority_default(esp32_s3, esp32, esp32_s3_idf, esp32_idf) + _get_priority_default(esp32_s3_idf, esp32_s3, esp32_idf, esp32) + ) + self._esp32_c3_arduino_default = vol.default_factory( + _get_priority_default(esp32_c3_arduino, esp32_c3, esp32_arduino, esp32) + ) + self._esp32_c3_idf_default = vol.default_factory( + _get_priority_default(esp32_c3_idf, esp32_c3, esp32_idf, esp32) ) self._rp2040_default = vol.default_factory(rp2040) self._bk72xx_default = vol.default_factory(bk72xx) @@ -1580,6 +1589,7 @@ class SplitDefault(Optional): from esphome.components.esp32.const import ( VARIANT_ESP32S2, VARIANT_ESP32S3, + VARIANT_ESP32C3, ) variant = get_esp32_variant() @@ -1593,6 +1603,11 @@ class SplitDefault(Optional): return self._esp32_s3_arduino_default if CORE.using_esp_idf: return self._esp32_s3_idf_default + elif variant == VARIANT_ESP32C3: + if CORE.using_arduino: + return self._esp32_c3_arduino_default + if CORE.using_esp_idf: + return self._esp32_c3_idf_default else: if CORE.using_arduino: return self._esp32_arduino_default diff --git a/tests/test8.1.yaml b/tests/test8.1.yaml new file mode 100644 index 0000000000..bc1d2e22a4 --- /dev/null +++ b/tests/test8.1.yaml @@ -0,0 +1,78 @@ +# Tests for ESP32-S3 boards - IDf +--- +wifi: + ssid: "ssid" + +network: + enable_ipv6: true + +esp32: + board: esp32s3box + variant: ESP32S3 + framework: + type: esp-idf + +esphome: + name: esp32-s3-test + +logger: + +debug: + +psram: + +spi: + - id: spi_id_1 + clk_pin: + number: GPIO7 + allow_other_uses: false + mosi_pin: GPIO6 + interface: any + +spi_device: + id: spidev + data_rate: 2MHz + spi_id: spi_id_1 + mode: 3 + bit_order: lsb_first + +display: + - platform: ili9xxx + id: displ8 + model: ili9342 + cs_pin: GPIO5 + dc_pin: GPIO4 + reset_pin: + number: GPIO48 + allow_other_uses: true + +i2c: + scl: GPIO18 + sda: GPIO8 + +touchscreen: + - platform: tt21100 + display: displ8 + interrupt_pin: + number: GPIO3 + ignore_strapping_warning: true + allow_other_uses: false + reset_pin: + number: GPIO48 + allow_other_uses: true + +binary_sensor: + - platform: tt21100 + name: Home Button + index: 1 + +sensor: + - platform: debug + free: + name: "Heap Free" + block: + name: "Max Block Free" + loop_time: + name: "Loop Time" + psram: + name: "PSRAM Free" diff --git a/tests/test8.2.yaml b/tests/test8.2.yaml new file mode 100644 index 0000000000..69525b333b --- /dev/null +++ b/tests/test8.2.yaml @@ -0,0 +1,75 @@ +# Tests for ESP32-C3 boards - IDf +--- +wifi: + ssid: "ssid" + +network: + enable_ipv6: true + +esp32: + board: lolin_c3_mini + variant: ESP32C3 + framework: + type: esp-idf + +esphome: + name: esp32-c3-test + +logger: + +debug: + +psram: + +spi: + - id: spi_id_1 + clk_pin: + number: GPIO7 + allow_other_uses: false + mosi_pin: GPIO6 + interface: any + +spi_device: + id: spidev + data_rate: 2MHz + spi_id: spi_id_1 + mode: 3 + bit_order: lsb_first + +display: + - platform: ili9xxx + id: displ8 + model: ili9342 + cs_pin: GPIO5 + dc_pin: GPIO4 + reset_pin: + number: GPIO21 + +i2c: + scl: GPIO18 + sda: GPIO8 + +touchscreen: + - platform: tt21100 + display: displ8 + interrupt_pin: + number: GPIO3 + allow_other_uses: false + reset_pin: + number: GPIO20 + +binary_sensor: + - platform: tt21100 + name: Home Button + index: 1 + +sensor: + - platform: debug + free: + name: "Heap Free" + block: + name: "Max Block Free" + loop_time: + name: "Loop Time" + psram: + name: "PSRAM Free" From 2a69a49061080365c6e199e4f9a661549667fd88 Mon Sep 17 00:00:00 2001 From: CVan Date: Thu, 21 Dec 2023 17:55:10 -0500 Subject: [PATCH 2/6] Update libtiff6 (#5985) --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ee7c70bb0f..7c162fc316 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -50,7 +50,7 @@ RUN \ libssl-dev=3.0.11-1~deb12u2 \ libffi-dev=3.4.4-1 \ libopenjp2-7=2.5.0-2 \ - libtiff6=4.5.0-6 \ + libtiff6=4.5.0-6+deb12u1 \ cargo=0.66.0+ds1-1 \ pkg-config=1.8.1-1 \ gcc-arm-linux-gnueabihf=4:12.2.0-3; \ From 872519f7f6e44a31055cbd01efc32ef73b27682f Mon Sep 17 00:00:00 2001 From: davidmonro Date: Fri, 22 Dec 2023 09:57:12 +1100 Subject: [PATCH 3/6] Override GPIOs 12 and 13 on the airm2m (LuatOS) board (#5982) Co-authored-by: David Monro --- esphome/components/esp32/boards.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/esp32/boards.py b/esphome/components/esp32/boards.py index e6c23c4d96..eaeab2caec 100644 --- a/esphome/components/esp32/boards.py +++ b/esphome/components/esp32/boards.py @@ -133,6 +133,10 @@ ESP32_BOARD_PINS = { "BUTTON": 0, "SWITCH": 0, }, + "airm2m_core_esp32c3": { + "LED1_BUILTIN": 12, + "LED2_BUILTIN": 13, + }, "alksesp32": { "A0": 32, "A1": 33, From 4f8e3211bf9427f739585268516645042611e521 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Thu, 21 Dec 2023 19:42:12 -0600 Subject: [PATCH 4/6] Add workaround for crash in Arduino 2.0.9 when CDC is configured (#5987) --- esphome/components/logger/logger.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index 05b97a5f64..e0f7e77d2c 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -285,6 +285,7 @@ void Logger::pre_setup() { #if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) #if ARDUINO_USB_CDC_ON_BOOT this->hw_serial_ = &Serial; + Serial.setTxTimeoutMs(0); // workaround for 2.0.9 crash when there's no data connection Serial.begin(this->baud_rate_); #else this->hw_serial_ = &Serial; From 8e13c3e1b0a413cc0820f1932ed2521ec05b404e Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Fri, 22 Dec 2023 14:58:30 +1300 Subject: [PATCH 5/6] web_server.py: return empty content when file doesn't exist (#5980) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/dashboard/web_server.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/esphome/dashboard/web_server.py b/esphome/dashboard/web_server.py index 4552aebf7b..c4b84d3fe3 100644 --- a/esphome/dashboard/web_server.py +++ b/esphome/dashboard/web_server.py @@ -792,13 +792,22 @@ class EditRequestHandler(BaseHandler): """Get the content of a file.""" loop = asyncio.get_running_loop() filename = settings.rel_path(configuration) - content = await loop.run_in_executor(None, self._read_file, filename) - self.write(content) + content = await loop.run_in_executor( + None, self._read_file, filename, configuration + ) + if content is not None: + self.write(content) - def _read_file(self, filename: str) -> bytes: + def _read_file(self, filename: str, configuration: str) -> bytes | None: """Read a file and return the content as bytes.""" - with open(file=filename, encoding="utf-8") as f: - return f.read() + try: + with open(file=filename, encoding="utf-8") as f: + return f.read() + except FileNotFoundError: + if configuration in const.SECRETS_FILES: + return "" + self.set_status(404) + return None def _write_file(self, filename: str, content: bytes) -> None: """Write a file with the given content.""" From 19e5a4a81a01611d0f6620165bdb438bc94a1adb Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 22 Dec 2023 11:04:00 +0900 Subject: [PATCH 6/6] Bump version to 2023.12.2 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 4537c276c5..5fa2d91e33 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2023.12.1" +__version__ = "2023.12.2" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = (