ZigEmbeddedGroup / microzig

Unified abstraction layer and HAL for several microcontrollers
zlib License
1.24k stars 102 forks source link

USB driver: support chunked data #201

Closed arkadiuszwojcik closed 5 months ago

arkadiuszwojcik commented 5 months ago

This PR adds support for chunked data in the USB driver. This is especially required for configuration sections larger than the endpoint's maximum packet size.

r4gus commented 5 months ago

I'll look at this as soon as I got time (probably the weekend).

Did you test this somehow? If you have used any scripts etc. for testing, it would be nice if you attach them to this thread.

arkadiuszwojcik commented 5 months ago

I will try to put something on weekend. I have draft code for RP2040 that uses USB (CEC ADC) config so windows detect it as serial port, it required quite long config descriptor so it have to be splited in 2 packets.

r4gus commented 5 months ago

If you have a working implementation you could add a minimal working project to the examples.

arkadiuszwojcik commented 5 months ago

Such example require some futher changes in current API but I created for you a branch with working CDC example above changes introduced by this PR for testing purpose. By working example I mean point where serial port is discovered by host. There is hovever one issue, this handshake process is very slow (up to 15s?) I don't think this is related to this PR but to CDC config from my example. I should take a look on that today or tomorrow.

EDIT: When I inspected packets in USBPcap initial handshake is nominal (fast), probably later on Windows expect some kind of other handshake related to CDC and this is causing some deley before Windows displays serial port in devices list.

arkadiuszwojcik commented 5 months ago

@r4gus I just found issue responsible for that bug with long delay. My code didn't send fianal empty packet after command response. PR and example were updated. Now Serial detection from CDC example branch work instantly. This PR introduce only chunked data, CDC support require some more discussions.

r4gus commented 5 months ago

@ikskuh

ikskuh commented 5 months ago

Wonderful, nice work!