hathach / tinyusb

An open source cross-platform USB stack for embedded system
https://www.tinyusb.org
MIT License
4.95k stars 1.04k forks source link

STM32F7 Queue EP 83 with 36 bytes ... #1622

Open SL-RU opened 2 years ago

SL-RU commented 2 years ago

Operating System

Linux

Board

Custom stm32f769 with HS phy

Firmware

examples/device/cdc_msc_freertos with synopsis_dcd2

What happened ?

After booting and plugging in the first time everything works fine. But if I unplug USB cable when there is msc transmissions after plugging again tusb don't work correctly. Transmission stops every time in the same place:

USBD Setup Received A1 FE [00 00 02 00 01 00](tel:00 00 02 00 01 00)
  MSC control request
  MSC Get Max Lun
  Queue EP 80 with 1 bytes ...
USBD Xfer Complete on EP 80 with 1 bytes
  MSC control complete
  Queue EP 00 with 0 bytes ...
USBD Xfer Complete on EP 00 with 0 bytes
USBD Xfer Complete on EP 03 with 31 bytes
  MSC xfer callback
  SCSI Command [Lun0]: Inquiry
  Queue EP 83 with 36 bytes ...

Also there is no UNPLUG events. On unplug there is only suspend event.

I've fixed this issue doing tud_init again with removed checking tud_inited() if device is suspended

How to reproduce ?

Use example with mentioned MCU

Debug Log as txt file

No response

Screenshots

No response

I have checked existing issues, dicussion and documentation

hathach commented 2 years ago

Thanks for the issue, unplug/suspend indeed isn't fully working with all STM32 mcus. Some requires an configure to OTG A/B register setting. Look like it is the case here, unplug is mistaken as suspend and device isn't reset/re-init state/endpoint as it should be. I think the old driver at st/synopsys does handle this better, maybe you could give it a try. I will revise this later on when having time.