From ed35bbff844f18a8527390c1b1328a664abe84c1 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 5 Sep 2025 12:49:50 +0200 Subject: [PATCH] Unable to use default serial GPIOs by TasmotaSerial regression from v14.5.0 with IDF 5.3.2.250120 (#23775) --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + .../README.md | 0 .../examples/swsertest/swsertest.ino | 0 .../keywords.txt | 0 .../library.json | 2 +- .../library.properties | 2 +- .../src/TasmotaSerial.cpp | 34 +++++++++++++++---- .../src/TasmotaSerial.h | 0 9 files changed, 32 insertions(+), 8 deletions(-) rename lib/default/{TasmotaSerial-3.6.0 => TasmotaSerial-3.7.0}/README.md (100%) rename lib/default/{TasmotaSerial-3.6.0 => TasmotaSerial-3.7.0}/examples/swsertest/swsertest.ino (100%) rename lib/default/{TasmotaSerial-3.6.0 => TasmotaSerial-3.7.0}/keywords.txt (100%) rename lib/default/{TasmotaSerial-3.6.0 => TasmotaSerial-3.7.0}/library.json (94%) rename lib/default/{TasmotaSerial-3.6.0 => TasmotaSerial-3.7.0}/library.properties (94%) rename lib/default/{TasmotaSerial-3.6.0 => TasmotaSerial-3.7.0}/src/TasmotaSerial.cpp (93%) rename lib/default/{TasmotaSerial-3.6.0 => TasmotaSerial-3.7.0}/src/TasmotaSerial.h (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd92e609d..bf191cd3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Syslog RFC5424 compliance (#23509) - Berry calling `setmember` with a function (#23825) +- Unable to use default serial GPIOs by TasmotaSerial regression from v14.5.0 with IDF 5.3.2.250120 (#23775) ### Removed - `user-scalable=no` from HTTP HEADER (#23798) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 0706935d9..a8ed33d98 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -152,6 +152,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Fixed - Syslog RFC5424 compliance [#23509](https://github.com/arendst/Tasmota/issues/23509) +- Unable to use default serial GPIOs by TasmotaSerial regression from v14.5.0 with IDF 5.3.2.250120 [#23775](https://github.com/arendst/Tasmota/issues/23775) - AHT30 sensor start with null values after deep sleep [#23624](https://github.com/arendst/Tasmota/issues/23624) - NeoPool reset to default settings [#23734](https://github.com/arendst/Tasmota/issues/23734) - Berry vulnerability in JSON parsing for unicode [#23603](https://github.com/arendst/Tasmota/issues/23603) diff --git a/lib/default/TasmotaSerial-3.6.0/README.md b/lib/default/TasmotaSerial-3.7.0/README.md similarity index 100% rename from lib/default/TasmotaSerial-3.6.0/README.md rename to lib/default/TasmotaSerial-3.7.0/README.md diff --git a/lib/default/TasmotaSerial-3.6.0/examples/swsertest/swsertest.ino b/lib/default/TasmotaSerial-3.7.0/examples/swsertest/swsertest.ino similarity index 100% rename from lib/default/TasmotaSerial-3.6.0/examples/swsertest/swsertest.ino rename to lib/default/TasmotaSerial-3.7.0/examples/swsertest/swsertest.ino diff --git a/lib/default/TasmotaSerial-3.6.0/keywords.txt b/lib/default/TasmotaSerial-3.7.0/keywords.txt similarity index 100% rename from lib/default/TasmotaSerial-3.6.0/keywords.txt rename to lib/default/TasmotaSerial-3.7.0/keywords.txt diff --git a/lib/default/TasmotaSerial-3.6.0/library.json b/lib/default/TasmotaSerial-3.7.0/library.json similarity index 94% rename from lib/default/TasmotaSerial-3.6.0/library.json rename to lib/default/TasmotaSerial-3.7.0/library.json index aa1fda280..46dca632b 100644 --- a/lib/default/TasmotaSerial-3.6.0/library.json +++ b/lib/default/TasmotaSerial-3.7.0/library.json @@ -1,6 +1,6 @@ { "name": "TasmotaSerial", - "version": "3.6.0", + "version": "3.7.0", "keywords": [ "serial", "io", "TasmotaSerial" ], diff --git a/lib/default/TasmotaSerial-3.6.0/library.properties b/lib/default/TasmotaSerial-3.7.0/library.properties similarity index 94% rename from lib/default/TasmotaSerial-3.6.0/library.properties rename to lib/default/TasmotaSerial-3.7.0/library.properties index 3f6d5c133..42107c5a3 100644 --- a/lib/default/TasmotaSerial-3.6.0/library.properties +++ b/lib/default/TasmotaSerial-3.7.0/library.properties @@ -1,5 +1,5 @@ name=TasmotaSerial -version=3.6.0 +version=3.7.0 author=Theo Arends maintainer=Theo Arends sentence=Implementation of software serial with hardware serial fallback for ESP8266 and ESP32. diff --git a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.7.0/src/TasmotaSerial.cpp similarity index 93% rename from lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp rename to lib/default/TasmotaSerial-3.7.0/src/TasmotaSerial.cpp index 0a25a1723..3b0441e1c 100644 --- a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.7.0/src/TasmotaSerial.cpp @@ -27,6 +27,9 @@ extern "C" { #include +extern void AddLog(uint32_t loglevel, PGM_P formatP, ...); +enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE}; + #ifdef ESP8266 void IRAM_ATTR callRxRead(void *self) { ((TasmotaSerial*)self)->rxRead(); }; @@ -152,17 +155,33 @@ void TasmotaSerial::setTransmitEnablePin(int tx_enable_pin) { #ifdef ESP32 bool TasmotaSerial::freeUart(void) { - for (uint32_t i = SOC_UART_HP_NUM -1; i >= 0; i--) { - if (0 == bitRead(tasmota_serial_uart_bitmap, i)) { - m_uart = uart_port_t(i); - bitSet(tasmota_serial_uart_bitmap, m_uart); - return true; + // If users selects default serial interface keep using UART0 + // From cores\esp32\HardwareSerial.cpp: There is always Seria0 for UART0 + int pin_soc_rx0 = gpioNumberToDigitalPin(SOC_RX0); + int pin_soc_tx0 = gpioNumberToDigitalPin(SOC_TX0); + if (((pin_soc_rx0 == m_rx_pin) && (pin_soc_tx0 == m_tx_pin)) || + ((pin_soc_rx0 == m_tx_pin) && (pin_soc_tx0 == m_rx_pin))) { + m_uart = uart_port_t(0); + bitSet(tasmota_serial_uart_bitmap, m_uart); + return true; + } else { + // Find a free UART which may end up as UART0 + for (uint32_t i = SOC_UART_HP_NUM -1; i >= 0; i--) { + if (0 == bitRead(tasmota_serial_uart_bitmap, i)) { + m_uart = uart_port_t(i); + bitSet(tasmota_serial_uart_bitmap, m_uart); + return true; + } } } return false; } void TasmotaSerial::Esp32Begin(void) { + // Workaround IDF #14787 introduced in Tasmota v14.5.0, Core 3.1.1, IDF 5.3.2.250120 + // which kept new Rx low instead of float + pinMode(m_rx_pin, INPUT_PULLUP); + pinMode(m_tx_pin, INPUT_PULLUP); TSerial->begin(m_speed, m_config, m_rx_pin, m_tx_pin, m_invert); // For low bit rate, below 9600, set the Full RX threshold at 10 bytes instead of the default 120 if (m_speed <= 9600) { @@ -251,10 +270,13 @@ bool TasmotaSerial::begin(uint32_t speed, uint32_t config) { #if ARDUINO_USB_MODE TSerial = new HardwareSerial(m_uart); #else - if (0 == m_uart) { + if (0 == m_uart) { // From cores\esp32\HardwareSerial.cpp: There is always Seria0 for UART0 +/* + // Not needed anymore since Core 3.1.0 Serial.flush(); Serial.end(); delay(10); // Allow time to cleanup queues - if not used hangs ESP32 +*/ TSerial = &Serial; } else { TSerial = new HardwareSerial(m_uart); diff --git a/lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.7.0/src/TasmotaSerial.h similarity index 100% rename from lib/default/TasmotaSerial-3.6.0/src/TasmotaSerial.h rename to lib/default/TasmotaSerial-3.7.0/src/TasmotaSerial.h