USB CDC ACM and 64 bytes transaction Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
russian
Posts: 368
Joined: Mon Oct 29, 2012 3:17 am
Has thanked: 16 times
Been thanked: 14 times

Re: USB CDC ACM and 64 bytes transaction

Post by russian »

Thank you for looking into this!
Dron_Gus
Posts: 34
Joined: Wed Apr 22, 2020 1:03 am
Has thanked: 5 times
Been thanked: 10 times

Re: USB CDC ACM and 64 bytes transaction

Post by Dron_Gus »

Giovanni wrote:Hi,

Could you post your changes?

Hi.

Sorry for late reply.

Attached. Did not have time to clean-up it.

With this set of patches I see no delays with 64 bytes OUT transaction. As soon as I do dd to ACM in one terminal I see "received 64" in minicom (I'm using SD for debug messages).
But 64, 128 .. bytes transaction is still marked timeout in sniffer. 63 and 65 bytes transactions are not.
Screenshot from 2024-10-29 00-32-01.png

Screenshot from 2024-10-29 00-32-38.png
Attachments
patches.zip
(7.01 KiB) Downloaded 385 times
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB CDC ACM and 64 bytes transaction

Post by Giovanni »

Hi,

Is that an USB analyzer that you use for those logs or some kind of SW?

Giovanni
Dron_Gus
Posts: 34
Joined: Wed Apr 22, 2020 1:03 am
Has thanked: 5 times
Been thanked: 10 times

Re: USB CDC ACM and 64 bytes transaction

Post by Dron_Gus »

Giovanni wrote:Hi,

Is that an USB analyzer that you use for those logs or some kind of SW?

Giovanni

Hi
I rented a TotalPhase Beagle 480 https://www.totalphase.com/products/beagle-usb480/ .
Initial bug hunting was done with WireShark under Linux.
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: USB CDC ACM and 64 bytes transaction

Post by FXCoder »

FYI from Great Scott...
cynthion

In addition to the list of suppliers...
Mouser
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB CDC ACM and 64 bytes transaction

Post by Giovanni »

Hi,

Thanks Bob, I was just searching for something like this, usually analyzers are not that cheap.

Giovanni
Dron_Gus
Posts: 34
Joined: Wed Apr 22, 2020 1:03 am
Has thanked: 5 times
Been thanked: 10 times

Re: USB CDC ACM and 64 bytes transaction

Post by Dron_Gus »

Seems we found a workaround for our case: https://github.com/rusefi/ChibiOS/pull/48 .
At least I do not see any communication freeze any more. 64-bytes writes are still marked red/timeout, but this does not affect anything (I hope)
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB CDC ACM and 64 bytes transaction

Post by Giovanni »

Thanks for confirming, will give it a try ASAP.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB CDC ACM and 64 bytes transaction

Post by Giovanni »

Hi,

What I am seeing using the USB_RAW demo on an STM32F746:

Reading data from the demo always works using:

Code: Select all

dd if=/dev/ttyACM1 of=/dev/null bs=512 count=1000


It works regardless of the count and block size.

Writing data to the demo only works for packets up to 64 bytes, anything bigger fails and DD is stuck.....

Code: Select all

dd if=/dev/zero of=/dev/ttyACM1 bs=64 count=1000


So far I have not an explanation for this, adding the retry to the ISR does not help.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: USB CDC ACM and 64 bytes transaction

Post by Giovanni »

Hi,

Wanted to share some strangeness. I am using Linux Mint as host.

If I start an USB_RAW demo any attempt to use "dd" or "stty" or even "cat" to send/receive data causes the command to hang, presumably on open() of the port (/dev/ttyACMx).

If I 1st open the port using the Eclipse terminal it works (is it doing anything special????), I see the data in the terminal and afterward also dd, stty and cat work as expected. I verified this using both OTGv1 on STM32F746 and USBv2 on STM32G4, this makes me thing that it is not a driver problem because those two drivers are entirely different. Any idea about what could cause this? I added a rule to the "modem manager" to make it not interfere with those ports but no luck.

This is very repeatable.

The second problem is specific of OTGv1, using "dd" with any buffer size greater that 64 does not work, it works with USBv2, this is likely a separate issue.

Adding the retry loop to the ISR made no difference for both issues.

Giovanni
Post Reply