ESP32C3 USB CDC loosing characters on reception of stream of data.

michalk
Posts: 24
Joined: Wed Mar 24, 2021 7:09 pm

Re: ESP32C3 USB CDC loosing characters on reception of stream of data.

Postby michalk » Mon Jul 07, 2025 3:15 pm

I am having this problem as well:
usage:

Code: Select all

    for (int i=0x0000; i<0x0004; i++){b = htonl(i);tusbwa1((const uint8_t *)&b, 4);}vTaskDelay(pdMS_TO_TICKS(100));
    for (int i=0x00F0; i<0x00F8; i++){b = htonl(i);tusbwa1((const uint8_t *)&b, 4);}vTaskDelay(pdMS_TO_TICKS(100));
    for (int i=0x0F00; i<0x0F0F; i++){b = htonl(i);tusbwa1((const uint8_t *)&b, 4);}vTaskDelay(pdMS_TO_TICKS(100));
    for (int i=0xF000; i<0xF00F; i++){b = htonl(i);tusbwa1((const uint8_t *)&b, 4);}vTaskDelay(pdMS_TO_TICKS(100));
method:

Code: Select all

bool tusbwa1(const uint8_t* data, size_t len) {
    int max_retries = 100;
    size_t total_sent = 0;
    int retries = 0;
    while (total_sent < len) {
        vTaskDelay(pdMS_TO_TICKS(1));
        size_t sent = tinyusb_cdcacm_write_queue(TINYUSB_CDC_ACM_1, data + total_sent, len - total_sent);
        vTaskDelay(pdMS_TO_TICKS(1));
        tud_remote_wakeup();
        vTaskDelay(pdMS_TO_TICKS(1));
        if (sent == 0) {
            tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_1, pdMS_TO_TICKS(100));
            retries++;
            if (retries > max_retries) {                return false;            }
        } else {
            total_sent += sent;
            retries = 0; // Reset retries after progress
        }
    }
    // tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_1, pdMS_TO_TICKS(100));
    return true;
}
desktop:~$ cat /dev/ttyACM3 | xxd

Code: Select all

00000000: 0000 0f00 000f 0500 000f 0600 000f 0700  ................
00000010: 000f 0800 000f 0900 000f 0a00 000f 0b00  ................
That's all of the output I get.

CORRECTION:
My problem is that cat /dev/ttyACM3 needed to have settings on the TTY for this to work properly.

Code: Select all

stty -F /dev/ttyACM3 raw -echo
is required.

toybuilder
Posts: 9
Joined: Thu Jan 31, 2019 6:02 pm

Re: ESP32C3 USB CDC loosing characters on reception of stream of data.

Postby toybuilder » Thu Nov 06, 2025 5:17 pm

Any update on this? I have the same issue on the ESP32-S3 at even modest rate of data transfer.

jared_s
Posts: 9
Joined: Sat Oct 04, 2025 10:22 am

Re: ESP32C3 USB CDC loosing characters on reception of stream of data.

Postby jared_s » Thu Nov 06, 2025 6:41 pm

Hi,

Did you find a fix for your problem with CDC? I have a similar problem with MIDI on the OTG port of ESP32 P4.
See my post in this category.

J.

User avatar
Danjovic
Posts: 8
Joined: Fri Apr 04, 2025 3:17 am

Re: ESP32C3 USB CDC loosing characters on reception of stream of data.

Postby Danjovic » Tue Jan 06, 2026 2:54 am

Any update on this? I have the same issue on the ESP32-S3 at even modest rate of data transfer.
None, so far.

User avatar
Danjovic
Posts: 8
Joined: Fri Apr 04, 2025 3:17 am

Re: ESP32C3 USB CDC loosing characters on reception of stream of data.

Postby Danjovic » Tue Jan 06, 2026 3:01 am

Hi,

Did you find a fix for your problem with CDC? I have a similar problem with MIDI on the OTG port of ESP32 P4.
See my post in this category.

J.
The problem have been reported by Sprite to Espressif, but so far I have no feedback about the solution
As of today the list of chips with the same problem are :
-ESP32C3
-ESP32C6
-ESP32S3
-ESP32P4

Who is online

Users browsing this forum: No registered users and 1 guest