Issue stopping OTGv1 driver when active

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

Moderator: RoccoMarco

Post Reply
User avatar
lilvinz
Posts: 130
Joined: Sat Dec 21, 2013 2:56 pm
Has thanked: 1 time
Been thanked: 6 times

Issue stopping OTGv1 driver when active

Post by lilvinz »

Hi,

when i try to usbStop an OTGv1 usb driver which is in state USB_ACTIVE,
it hangs here with i being 1:

Code: Select all

static void otg_disable_ep(USBDriver *usbp) {
      ...
      /* Wait for endpoint disable.*/
      while (!(otgp->ie[i].DIEPINT & DIEPINT_EPDISD))
        ;
      ...
}


This happens when having written to a serial over usb device without a host having consumed that data before usbStop().
I can "fix" it by calling _usb_reset() before usbStop() but that doesn't seem to be the intended way of doing it.
Is this a driver issue or misusage by myself?

Thanks in advance and with best regards,

Vinz

PS: The more i work with it, the more i like ChibiOS!
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Issue stopping OTGv1 driver when active

Post by Giovanni »

Hi,

This is one of those hard-to-test corner cases. Probably the reset approach is correct considering we are enforcing a stop while the peripheral is active and there are filled FIFOs. Are you able to restart after enforcing the stop this way?

Also, are you running with assertions enabled?

Giovanni
User avatar
lilvinz
Posts: 130
Joined: Sat Dec 21, 2013 2:56 pm
Has thanked: 1 time
Been thanked: 6 times

Re: Issue stopping OTGv1 driver when active

Post by lilvinz »

Giovanni wrote:Hi,

This is one of those hard-to-test corner cases. Probably the reset approach is correct considering we are enforcing a stop while the peripheral is active and there are filled FIFOs. Are you able to restart after enforcing the stop this way?

Also, are you running with assertions enabled?

Giovanni


Hi Giovanni,

i am able to restart - this code is inside a bootloader and the main application is using usb without issues.
Also all debug options are enabled so there seems to be no misusage.
If there is no negative side effect of executing this reset, i am fine with keeping it.

Cheers,

Vinz
Post Reply