espressif/qemu

UART Echo Example not working as expected in ESP32C3 Qemu (QEMU-150)

lcgamboa opened this issue · 7 comments

The idf UART Echo Example not working as expected in ESP32C3 Qemu.
In the figure below on the left is the output on a real C3 chip and on the right the output of Qemu's ESP32C3 for keys typed in sequence ( 1, 2 , 3 ...).

uarterror

The example works correctly with Qemu for ESP32.

Hi @lcgamboa ,

Thanks for reporting this issue. As far as I know, this example requires an external USB-to-UART adapter as it uses another UART controller than the default one, with given pins from Kconfig.

I cannot reproduce what you are getting, even on the real chip. What is your configuration for this example?

I'm sorry I forgot to let you know that I modified the code to use the default pins for ease of use with many different processors. I modified the lines 29 and 30 of file uart_echo_example_main.c from :

#define ECHO_TEST_TXD (CONFIG_EXAMPLE_UART_TXD)
#define ECHO_TEST_RXD (CONFIG_EXAMPLE_UART_RXD)

to:

#define ECHO_TEST_TXD (UART_PIN_NO_CHANGE)
#define ECHO_TEST_RXD (UART_PIN_NO_CHANGE)

Hi @lcgamboa ,

Thanks for the details, I also needed to use the UART port number 0 in the menuconfig to reproduce the issue.
I will investigate this issue.

Thanks for the support, now the example works correctly.

I did some more tests and it seems that there is some difference when the sent string is greater than 128 bytes. For real hardware the string limit is 1024 bytes, for Qemu esp32-c3 the limit is a multiple of 128. In the figure below a string of 2048 bytes is sent, for real hardware (top terminal) it is split into two parts of 1024 (in the most times). For Qemu esp32-c3 (bottom terminal) it is always split into several parts with sizes x*128 randomly. Same with ESP32 for hardware and on Qemu esp32. Apparently this is not a problem and is probably due to a limitation in the Qemu implementation.

echo

Hi @lcgamboa ,

The reason behind this is that the ESP32-C3 UART controller underneath uses the ESP32 UART implementation, which explains why it has the same behavior. This choice was made to quickly get something up and running while developping other controllers.
If you think this is a critical bug and it needs to be fixed as soon as possible, feel free to open a new issue

Hi @o-marshmallow ,

I believe it is not critical, this limitation is because the buffers always have a fixed size of 128 in the Qemu implementation.

Another problem that occurs is that when the uart receive threshold is set to a value lower than 128, the interruption only happens when the buffer reaches 128 and throttle_rx=true occurs. It's not critical either, but it can disturb an application that needs to process exactly the configured threshold.