Skip to main content
Graduate
November 8, 2025
Solved

Can USB CDC receive more than 256 bytes of data from the host?

  • November 8, 2025
  • 6 replies
  • 484 views

Hi everyone.

I'm trying to send more than 256 bytes of data from the host to the STM32 using USB CDC VCP, and I don't know why VCP won't accept more than 64 bytes of data. My project is already halfway done. If I switch to the USB bulk method, do I have to replace the USB CDC library and rewrite all the code from scratch? And do I have to create my own library to replace USB CDC?

I'm using an STM32F407VET6.

I appreciate all your answers.
Thank you:).

    This topic has been closed for replies.
    Best answer by TDK

    You can send more than 256 bytes of data, but they will be split up into chunks of up to 64 bytes. The 64-byte limit is a limitation of USB FS. There is no way around this. You have to piece data together on the receiving end.

    The is no way to "use a bulk endpoint" or change the CDC code or otherwise change things to avoid this. It is a limitation of USB FS.

    6 replies

    Graduate
    November 8, 2025

    CDC data is sent in 64-byte packets. You may send any amount of data but it will be received as multiple 64-byte packets. Bigger packets are possible with High-Speed USB but it rarely matters for CDC VCP. CDC already uses Bulk transfer.

    No_NameAuthor
    Graduate
    November 8, 2025

    Yes.
    This is so that the STM32 can receive larger amounts of data at once without having to break it down into 64-byte chunks.

    Super User
    November 8, 2025

    Hi,

    64 B packet size is defined by USB full speed CDC , not the involved cpu.

    +

    When receiving data larger than the endpoint packet size (e.g., 512 bytes or more), the STM32 USB CDC firmware uses the USB core's multi-packet feature. The core automatically manages the transfer by receiving several packets of the configured endpoint size and reassembling them as needed. The application must process the data promptly to avoid buffer overruns, and the OUT endpoint is re-enabled for the next packet in the appropriate callback or handler.

    single USB CDC transfer is determined by the endpoint's maximum packet size, which is typically:

    • 64 bytes for Full Speed (FS)
    • 512 bytes for High Speed (HS)

    So USB CDC can receive more than 256 bytes from the host. The STM32 USB device core and middleware handle large data transfers by splitting them into multiple endpoint-sized packets and reassembling them in the firmware.

    Graduate
    November 8, 2025

    AFAIK, ST USB device stack may handle device-to-host (IN) multipacket transfers but not host-to device (OUT). The data received callback is called upon packet reception, at least for CDC VCP.

    No_NameAuthor
    Graduate
    November 8, 2025

    @AScha.3 @gbm 

    So, in conclusion, USB CDC VCP can receive more than 256 bytes, but it will be divided into 64-byte blocks, right?

    If I want to migrate from USB CDC VCP to USB BULK so that STM32 can receive more than 64/256 bytes of data at once from the host, do I have to replace all USB CDC libraries, or can USB CDC be modified to receive 256 bytes or more at once?

    No_NameAuthor
    Graduate
    November 8, 2025

    Will all host-to-interface communications involving large data sizes, such as 256/512 bytes or more, still be divided into multiple packets?

    What this means is, will all communications equally split packets larger than 256/512 bytes?

    TDKAnswer
    Super User
    November 8, 2025

    You can send more than 256 bytes of data, but they will be split up into chunks of up to 64 bytes. The 64-byte limit is a limitation of USB FS. There is no way around this. You have to piece data together on the receiving end.

    The is no way to "use a bulk endpoint" or change the CDC code or otherwise change things to avoid this. It is a limitation of USB FS.

    No_NameAuthor
    Graduate
    November 8, 2025

    Okay, so all USB communication between the host and the interface will still be divided into 64 bytes? So there is no way to receive data all at once without it being divided?

    Super User
    November 8, 2025

    > all USB [FS] communication between the host and the interface will still be divided into 64 bytes

    > there is no way to receive data all at once without it being divided

    That is correct.

    No_NameAuthor
    Graduate
    November 9, 2025

    @Pavel A. @TDK @gbm @AScha.3 

    Okay, I understand. So, what is meant by VCP or bulk is the communication method on the host side, so the delay depends on the driver used by the host? So on the firmware side, regardless of the communication method used, larger data will still be divided into 64 bytes. It all depends on the host.

    I used to think that splitting packets would cause significant delays, but it turns out that's not the case because the data is sent quickly even though it's split into 64 bytes/packet.

    Graduate
    November 9, 2025

    Practically you may reach around 300 kB/s data reception with FS CDC VCP on almost any STM32 communicating with a PC using a terminal emulator. You receive packets of up to 64 B (the most common/maximum setting for FS EP size) and how you handle them is up to you.