Closed P-R-O-C-H-Y closed 1 month ago
Relevant underlying code (from ESP-IDF): https://github.com/espressif/esp-idf/issues/12826#issuecomment-1862540712
Upon further investigation, the issue is that the code is trying to output the same signal on multiple pins (e.g. on ESP32, U2TXD is mapped both to 25 and 26), and wokwi won't handle that correctly - it would only route the signal to the first defined pin (25 in the example).
I'm looking at what changes we'd need to do for supporting this scenario.
Update: still on it
Should be fixed now.
Solving the original issue uncovered a few more issues with the UART implementation (baud rate not calculated correctly on ESP32-S3/C3, UART1 interrupt broken on ESP32-S2, incorrect RX FIFO timeout calculation), but now I believe UART should behave well in your tests.
Can you please rerun the tests and report?
@urish H2 still fails one of the tests: https://github.com/lucasssvaz/arduino-esp32/actions/runs/9190470217/job/25275142106?pr=12
Thanks @lucasssvaz!
I looked into this. It seems like the tests use pins 6/7 for the pin swap test: https://github.com/espressif/arduino-esp32/blob/d164df89de350aa945ccb0cb4261f56306bfdb3c/tests/validation/uart/uart.ino#L51-L52
Looking at the datasheet, the H2 does not have GPIO6 / GPIO7 pins:
So that's why it fails on Wokwi.
I'm not sure what's the correct behavior in this case, as even the TRM mentions GPIO6/7 are not configurable in the IO MUX:
Thanks @lucasssvaz!
I looked into this. It seems like the tests use pins 6/7 for the pin swap test: https://github.com/espressif/arduino-esp32/blob/d164df89de350aa945ccb0cb4261f56306bfdb3c/tests/validation/uart/uart.ino#L51-L52
Looking at the datasheet, the H2 does not have GPIO6 / GPIO7 pins:
So that's why it fails on Wokwi.
I'm not sure what's the correct behavior in this case, as even the TRM mentions GPIO6/7 are not configurable in the IO MUX:
Then Idk why the hardware tests work fine π
I'll take a look, thanks!
Then Idk why the hardware tests work fine π
Yeah, that's strange!
@urish Also, this is what I mentioned that some random bytes appear in the buffer for ESP32-S2
https://github.com/lucasssvaz/arduino-esp32/actions/runs/9197178547/job/25297205058?pr=12
It happened 2 times while I'm testing the refactoring in my fork.
2024-05-22 19:26:48 /home/runner/work/arduino-esp32/arduino-esp32/tests/validation/uart/uart.ino:101:periman_test:FAIL: Expected 'Hello from Serial1 (UART1) >>> via loopback >>> Serial1 (UART1) while I2C is disabled' Was '\xC1Hello from Serial1 (UART1) >>> via loopback >>> Serial1 (UART1) while I2C is disabled'
So this sometimes happens sometimes not?
2024-05-22 19:26:48 /home/runner/work/arduino-esp32/arduino-esp32/tests/validation/uart/uart.ino:101:periman_test:FAIL: Expected 'Hello from Serial1 (UART1) >>> via loopback >>> Serial1 (UART1) while I2C is disabled' Was '\xC1Hello from Serial1 (UART1) >>> via loopback >>> Serial1 (UART1) while I2C is disabled'
So this sometimes happens sometimes not?
Yep, most of the time it works fine. Now it happened for ESP32:
https://github.com/lucasssvaz/arduino-esp32/actions/runs/9197367574/job/25297810900?pr=12
I never saw this happening with the tests in actual hardware. So I guess in this case it might be related to wokwi.
I see. It might happen because of a floating wire for the UART receiver that generates some noise. I guess we are not properly resetting the receiver or something like that. How often does this happen? if it's about 50% of the times, then it's most likely a floating wire.
No, it's around 20-30% of the time if I had to guess
I've been seeing this issue more frequently. One interesting thing is that the "garbage text" is always the same for the chips: In S2 it is \xC1
and ESP32 it's \xFE
.
I would suspect that something that was meant to be sent as a byte is being sent as a string, based on the error message:
/home/runner/work/arduino-esp32/arduino-esp32/tests/validation/uart/uart.ino:108:change_pins_test:FAIL: Expected 'Hello from Serial1 (UART1) >>> to >>> Serial2 (UART2) using new pins' Was '\xFEHello from Serial1 (UART1) >>> to >>> Serial2 (UART2) using new pins'
Thanks for investigating! I pushed a fix that implements the UART RX FIFO reset functionality, and I believe this should fix the random bytes issue. Can you please test once more?
No problem, I'll report back once I have performed enough tests
Still happening on ESP32: https://github.com/lucasssvaz/arduino-esp32/actions/runs/9240024519/job/25419849144?pr=12
I'll check for S2 tomorrow
Thanks for checking! Should be fixed now too :-)
Describe the bug We use internal loopbacks to test the UART on real HW, but in Wokwi this test is failing. I don't know if the feature is supported in Wokwi or if it's not working correctly (7 out of 11 tests were failing).
To Reproduce To reproduce the issue you can run the test sketch: https://github.com/espressif/arduino-esp32/blob/master/tests/validation/uart/uart.ino
Log:
Expected behavior Expected is to pass all tests as it does on real HW.
Environment (please complete the following information):
Additional context