Serial over USB problem

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Serial over USB problem

Post by alexblack »

Hi,
Giovanni wrote:Just a note "sd" functions are specific of the serial driver, they do work with the "sdu" driver but are not meant for that. you should use chnReadTimeout() instead.

Thanks, I got it.

About the timeout, what is the state of the system when it hangs? crashed or just some thread hung and others working?

The state is normal, all threads are working, except "USB_THREAD" (maybe I can look at its state too, but I did not think to do it), USB driver even responding to system requests. When I unplug USB cable the cable detection function resets the USB queues as I wrote once before and likely this is resume the USB thread.
In addition I have saw that data in "USB hang state" still sent succesfully from device to host (hangs only receive function).

Maybe it is only my problem, could someone check it on on their board?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Serial over USB problem

Post by Giovanni »

My idea is to create a stress test and benchmark starting from your code, my problem is that right now I am very busy with other tasks, please be patient.

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Serial over USB problem

Post by alexblack »

Giovanni wrote:My idea is to create a stress test and benchmark starting from your code, my problem is that right now I am very busy with other tasks, please be patient.
Giovanni

Yes, I will wait. But I do some tests to help you to understand the problem.
Today I tested STM32 USB-FS-Device-Driver library and VirtualComPort example with my usb_test program.
After some modifications it started to work without such problems. Also I measured exchange speed - it is ~330 kB/sec in each direction, ie 600kB/sec in one. The ChibiOS driver give max speed 75 - 100kB/sec from device to host direction. In both tests it is raw transfer speed without data processing.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Serial over USB problem

Post by Giovanni »

Could you post your executable? I don't have Delphi where I am.

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Serial over USB problem

Post by alexblack »

Yes.
Attachments
usb_test.zip
(50.38 KiB) Downloaded 406 times
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Serial over USB problem

Post by alexblack »

Hi. Happy New Year!
Are there any news ?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Serial over USB problem

Post by Giovanni »

I Alex,

Probably I will able to give it a try next week.

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Serial over USB problem

Post by alexblack »

Hi...
Up!
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Serial over USB problem

Post by Giovanni »

Hi Alex.

I am not ignoring the issue not you :) I am just taken by problems of various kind lately.

Giovanni
sven.984
Posts: 2
Joined: Sat Feb 23, 2013 11:58 pm

Re: Serial over USB problem

Post by sven.984 »

Hi...

I had a similar problem with the serial usb. After the first line of text sent from device to host, the usb analyzer shows a lot of zero size packets. I think the problem can be found in the following line (serial_usb.c: sduDataTransmitted):

Code: Select all

else if (!(usbp->epc[ep]->in_state->txsize &
    (usbp->epc[ep]->in_maxsize - 1))) {
...
    usbPrepareQueuedTransmit(usbp, ep, &sdup->oqueue, 0);


Running once into this "else if" the controller is running into a dead lock (including an interrupt)

It should be:

Code: Select all

else if ((usbp->epc[ep]->in_state->txsize &
    (usbp->epc[ep]->in_maxsize - 1))) {
...
    usbPrepareQueuedTransmit(usbp, ep, &sdup->oqueue, 0);


Best regards

Sven
Post Reply