tinyusb icon indicating copy to clipboard operation
tinyusb copied to clipboard

Zerocopy support

Open rhgndf opened this issue 5 months ago • 2 comments

Related area

Avoids memcpy with calling write functions

Hardware specification

Probably applicable to all hardware, user probably needs to be careful in only passing DMA capable buffer

Is your feature request related to a problem?

Streaming on webusb vendor endpoint as fast as possible

The speed jumped from 10MB/s to 26.5MB/s with the modification below. Hardware details: CH32V305, USBHS, CFG_TUD_VENDOR_EPSIZE=512

Describe the solution you'd like

Current solution as a proof of concept:

Within this piece of code: https://github.com/hathach/tinyusb/blob/8a78804ff91271fb32008288777fad9fe73f5735/src/tusb.c#L431

I replaced it with

    //memcpy(s->ep_buf, buffer, xact_len);
    s->ep_buf = buffer;

I have checked existing issues, dicussion and documentation

  • [x] I confirm I have checked existing issues, dicussion and documentation.

rhgndf avatar Jul 19 '25 14:07 rhgndf

yeah, I agree, but we need to do this in the portable way, since not all mcu support this. E.g DMA only mcu require data must be at leat 32/64 byte aligned and need to be placed in specific SRAM section. I have solution in mind, just need some time to write it down.

hathach avatar Aug 05 '25 14:08 hathach

what do you envision for buffer API changes?

spnirmal avatar Oct 24 '25 06:10 spnirmal