I wrote some code to intercept a UART connection. So my wiring is:
DEVICE1_TX -> [GPIO11 - ESP32-S3 - GPIO12] -> DEVICE2_RX
DEVICE1_RX <- [GPIO13 - ESP32-S3 - GPIO14] <- DEVICE2_TX
GPIO11 and GPIO12 mapped to UART1 (@115200)
GPIO14 and GPIO13 mapped to UART2 (@115200)
UART0 is just used for debug messages (@921600, but tried lower baud rates too)
As long as I don't print anything on UART0, everything seems to work just fine and if I only print very short/few messages on UART0, everything keeps working fine for a minute or so.
But as soon as I print for example all messages received from UART1 and UART2 on UART0, it keeps crashing almost immediately with a weird looking message that I don't understand:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42024902
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2920
entry 0x403c98d8
In reality it looks more like this:
Debug Serial initialized
UART Interceptor ready
test...
test...
test...
test...
tesESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42024902
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2920
entry 0x403c98d8
Debug Serial initialized
UART Interceptor ready
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42024902
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2920
entry 0x403c98d8
Debug Serial initialized
UART Interceptor ready
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42024902
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2920
entry 0x403c98d8
Debug Serial initialized
UART Interceptor ready
test...
test...
test...
test...
test...
tESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42024902
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2920
entry 0x403c98d8
Unfortunately I can't really provide a test sketch because of the complexity of needing to have 3 separate devices, but I'm basically just using this class UARTInterceptor.cpp along with some Serial.print
s.
Am I missing anything obvious?
At first I thought SoftwareSerial might be the issue, but since the ESP32 can map the 3 hardware serial UARTs to any pin, I switched to HardwareSerial, but I'm still having these issues.
I also tried increasing the baud rate of UART0 to way more than UART1+UART2 together, but it's still not working reliably.
Is this a common issue? Do I have to increase the ring buffer size or something like that?
I tested this on a standard ESP32 as well as on an ESP32-S3 btw. Same result.
Edit:
One more important detail: If No data is received/sent on UART1 and UART2, I can spam UART0 without any crashes.
Edit2:
The messages I'm dealing with are usually around 15 bytes in size with same exceptions of 234 bytes.
Edit3:
Increased the ringbuffer size to 2048 for tx and rx of UART1 and UART2. Still the same crashes.