-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USB Host MSC class driver fails if device does not respond to Get Max LUN request #259
Comments
If device support only one lun also need support this command, this is the basic msc request. |
CherryUSB/class/msc/usbd_msc.c Line 89 in a8ef0c4
|
I did a little research to see how several other USB host stacks handle this situation. They all have slight differences in the comments or control flow, but none of them require a successful Get Max LUN request to attach an MSC device.
|
Thank you for such a detailed explanation,could you pr a patch for this? |
…ngore error and set lun=0, refs:#259
Done |
…ngore error and set lun=0, refs:#259
With the change from cherry-embedded#259, this buffer no longer needs to be so large. It can be reduced to the save a lot of memory.
描述一下这个bug / Describe the bug
This issue occurs within the USB Host class driver for MSC (mass storage) devices:
https://github.com/cherry-embedded/CherryUSB/blob/master/class/msc/usbh_msc.c#L279
In the
usbh_msc_connect()
function, a call is made tousbh_msc_get_maxlun()
which attempts to perform a "Get Max LUN" request on the USB device. If this request fails, the class driver will not load and the device will not be usable.On some USB storage devices, this command fails with a
USB_ERR_STALL
, and thus those devices cannot be used with CherryUSB.However, according to the USB Mass Storage Class Bulk-Only Transport specification:
https://www.usb.org/sites/default/files/usbmassbulk_10.pdf
(Page 7, section "3.2 Get Max LUN")
"Devices that do not support multiple LUNs may STALL this command."
In other words, a stall error in response to this request should not cause the MSC connect function to fail.
Changing the error handling around
usbh_msc_get_maxlun()
as follows, fixes the issue:复现步骤 / To Reproduce
Most USB thumbdrives I tested do not have this problem. However, I found one that does. It has a VID=0x058F and PID=0x6387 and was received as a freebie at a tech conference many years ago. However, just knowing that these things exist, makes me worried that an end-user might try to use one.
设备信息 / Target Device
STM32F446RE, DWC2 port, FreeRTOS
日志 / Log
配置 / Configuration
No response
USB中断 / USB Interrupt
No response
缓存 / Cache
No response
商业 / Business
The text was updated successfully, but these errors were encountered: