ESP32-S3 USB CDC Console misses chunks for large serial data transmits

BDesterBE
Posts: 4
Joined: Wed Dec 13, 2023 7:24 pm

ESP32-S3 USB CDC Console misses chunks for large serial data transmits

Postby BDesterBE » Tue Mar 12, 2024 10:06 pm

Hello,

I am creating a python script which serially connects to a esp32-s3 USB CDC console device with 115200 baud. I am sending a large command, the contents of a certificate, which is a ~2400 character string. I observe that the esp32 only receives in total ~250 characters.

What's interesting is that the esp32 will always receive ~90 characters from the beginning, as well as some bytes from the end of the certificate, indicating that data from the middle of the string is being missed. I also can observe this behavior occurring in real time on the secondary console port in picocom, e.g. the first ~90 bytes show up, a pause, and this repeating a couple more times until the end of the certificate is sent. Pasting the command directly into the console exhibits the same behavior, granted it is able to receive ~600 characters.

I have troubleshooted several different likely culprits, including increasing the console's max_cmdline_length and task_priority, and have looked for config options relating to the USB CDC buffer size with no luck.

If I split the command into multiple chunks on the python script side, sleeping in between chunk transmits, and I am able to send the entirety of the command. This should be a fine solution for now, however, I would expect that the esp32s3 would be capable of keeping up with this data size and rate.

I haven't been able to find documentation regarding flow control on the USB port, but I suspect it may be related to this issue.

ESP_Sprite
Posts: 9052
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 USB CDC Console misses chunks for large serial data transmits

Postby ESP_Sprite » Wed Mar 13, 2024 1:53 am

USB bulk transfers (as used by CDC) have integrated flow control: per the protocol it is impossible to loose data, when data isn't processed fast enough the host simply will wait until the buffers are empty again.

Who is online

Users browsing this forum: Bing [Bot], YaCy [Bot] and 168 guests