stm32_mw_usb_host
stm32_mw_usb_host copied to clipboard
USB Class MSC SCSI CB Length is wrong for 3 commands
Describe the set-up
Custom board with USB Host and stm32-mw-usb-host.
A Zephyr device with a USB Device with MSC Class with the new USB Stack Next.
CONFIG_USB_DEVICE_STACK_NEXT=y
Describe the bug
The new Zephyr USB Device Stack checks the length of the SCSI command.
The log of the Zephyr RTOS shows following:
<err> usbd_msc: Unknown SCSI opcode 0x12
The message is not correct, because the length is wrong for this opcode.
The bug is that the stm32-mw-usb-host sets for all SCSI commands a length of 10. But the following commands has a length of 6:
Opcode: TEST_UNIT_READY
Function: USBH_MSC_SCSI_TestUnitReady
Opcode: INQUIRY
Function: USBH_MSC_SCSI_Inquiry
Opcode: REQUEST_SENSE
Function: USBH_MSC_SCSI_RequestSense
In this functions it should be:
MSC_Handle->hbot.cbw.field.CBLength = 6;
instead of:
MSC_Handle->hbot.cbw.field.CBLength = CBW_LENGTH;
#define CBW_LENGTH 10
For the other 3 commands (READ_CAPACITY10, WRITE10 and READ10) the length of 10 is correct.
How To Reproduce
Use a Zephyr RTOS on a board (ST Board) and the Mass Storage example.
A board with the stm32-mw-usb-host and MSC Class.
For Zephyr RTOS you can enable following to show the error Message:
CONFIG_USBD_MSC_LOG_LEVEL_ERR=y
Additional context SCSI commands description for example: https://www.seagate.com/files/staticfiles/support/docs/manual/Interface%20manuals/100293068j.pdf INQUIRY command page 92 REQUEST SENSE command page 195 TEST UNIT READY command page 230
The most software will ignore this problem, but not the new Zephyr USB Stack.