zephyr: usb mass storage on mimxrt595_evk_cm33 mount very slow
Describe the bug Built and ran the usb mass storage demo with zephyr v3.2.0 on mimxrt595_evk_cm33, wait for 30 seconds to usb msc can mount to PC.
To Reproduce
Steps to reproduce the behavior:
build: west build -b mimxrt595_evk_cm33 zephyr/samples/subsys/usb/mass --pristine
connect usb port to PC.
Expected behavior
Logs and console output
*** Booting Zephyr OS build zephyr-v3.2.0-4384-ga5e04ccd4ab9 ***
[00:38:16.011,298] <inf> usb_msc: Sect Count 64
[00:38:16.011,303] <inf> usb_msc: Memory Size 32768
[00:38:17.466,109] <inf> main: No file system selected
[00:38:17.466,118] <dbg> usb_device: usb_enable: lock usb_enable_lock mutex
[00:38:17.466,141] <dbg> usb_dc_mcux: usb_dc_attach: Attached
[00:38:17.466,192] <dbg> usb_device: composite_setup_ep_cb: set cb, ep: 0x1
[00:38:17.466,198] <dbg> usb_device: composite_setup_ep_cb: set cb, ep: 0x81
[00:38:17.466,209] <dbg> usb_device: usb_enable: unlock usb_enable_lock mutex
[00:38:17.466,216] <inf> main: The device is put in USB mass storage mode.
[00:38:17.778,356] <dbg> usb_msc: mass_storage_status_cb: USB device reset detected
--- 31 messages dropped ---
[00:38:17.824,034] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x00
--- 8 messages dropped ---
[00:38:17.824,045] <dbg> usb_device: custom_handler: bRequest 0x06, wIndex 0x0000
[00:38:17.824,052] <dbg> usb_device: usb_get_descriptor: Get Descriptor request
[00:38:17.824,092] <dbg> usb_device: usb_handle_control_transfer: ep 0x80, status 0x02
[00:38:17.824,101] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x01
[00:38:17.824,293] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x00
[00:38:17.824,303] <dbg> usb_device: custom_handler: bRequest 0x06, wIndex 0x0000
[00:38:17.824,310] <dbg> usb_device: usb_get_descriptor: Get Descriptor request
[00:38:17.824,345] <dbg> usb_device: usb_handle_control_transfer: ep 0x80, status 0x02
[00:38:17.824,355] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x01
[00:38:17.824,693] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x00
[00:38:17.824,704] <dbg> usb_device: custom_handler: bRequest 0x09, wIndex 0x0000
[00:38:17.824,711] <dbg> usb_device: usb_set_configuration: Set Configuration 1 request
[00:38:17.824,721] <dbg> usb_device: set_endpoint: Set endpoint 0x81 type 2 MPS 512
[00:38:17.824,743] <dbg> usb_device: set_endpoint: Set endpoint 0x1 type 2 MPS 512
[00:38:17.824,791] <dbg> usb_msc: mass_storage_status_cb: USB device configured
[00:38:17.824,819] <dbg> usb_device: usb_handle_control_transfer: ep 0x80, status 0x02
[00:38:17.831,347] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x00
[00:38:17.831,360] <dbg> usb_device: class_handler: bRequest 0xfe, wIndex 0x0000
[00:38:17.831,370] <dbg> usb_msc: mass_storage_class_handle_req: MSC_REQUEST_GET_MAX_LUN
[00:38:17.831,398] <dbg> usb_device: usb_handle_control_transfer: ep 0x80, status 0x02
[00:38:17.831,407] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x01
[00:38:17.831,659] <dbg> usb_msc: mass_storage_bulk_out: > BO - MSC_READ_CBW
[00:38:17.831,673] <dbg> usb_msc: CBWDecode: >> TUR
[00:38:17.831,725] <dbg> usb_msc: mass_storage_bulk_in: < BI - MSC_WAIT_CSW
[00:38:17.934,591] <dbg> usb_msc: mass_storage_bulk_out: > BO - MSC_READ_CBW
[00:38:17.934,601] <dbg> usb_msc: CBWDecode: >> INQ
[00:38:17.934,643] <dbg> usb_msc: mass_storage_bulk_in: < BI - MSC_SEND_CSW
[00:38:17.934,760] <dbg> usb_msc: mass_storage_bulk_in: < BI - MSC_WAIT_CSW
[00:38:17.935,353] <dbg> usb_msc: mass_storage_bulk_out: > BO - MSC_READ_CBW
[00:38:17.935,360] <dbg> usb_msc: CBWDecode: >> TUR
[00:38:17.935,414] <dbg> usb_msc: mass_storage_bulk_in: < BI - MSC_WAIT_CSW
[00:38:17.935,583] <dbg> usb_msc: mass_storage_bulk_out: > BO - MSC_READ_CBW
[00:38:17.935,590] <dbg> usb_msc: CBWDecode: >> INQ
[00:38:17.935,678] <dbg> usb_msc: mass_storage_bulk_in: < BI - MSC_SEND_CSW
[00:38:17.935,780] <dbg> usb_msc: mass_storage_bulk_in: < BI - MSC_WAIT_CSW
[00:38:18.131,360] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x00
[00:38:18.131,389] <dbg> usb_device: custom_handler: bRequest 0x06, wIndex 0x0000
[00:38:18.131,394] <dbg> usb_device: usb_get_descriptor: Get Descriptor request
[00:38:18.131,415] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x01
[00:38:18.131,424] <dbg> usb_device: usb_handle_control_transfer: ep 0x80, status 0x02
[00:38:18.964,313] <dbg> usb_msc: mass_storage_bulk_out: > BO - MSC_READ_CBW
[00:38:18.964,320] <dbg> usb_msc: CBWDecode: >> TUR
[00:38:18.964,562] <dbg> usb_msc: mass_storage_bulk_in: < BI - MSC_WAIT_CSW
[00:38:18.964,886] <dbg> usb_msc: mass_storage_bulk_out: > BO - MSC_READ_CBW
[00:38:18.964,896] <dbg> usb_msc: CBWDecode: >> MEDIA_REMOVAL
[00:38:18.965,065] <dbg> usb_msc: mass_storage_bulk_in: < BI - MSC_WAIT_CSW
[00:38:18.965,522] <dbg> usb_msc: mass_storage_bulk_out: > BO - MSC_READ_CBW
[00:38:18.965,533] <dbg> usb_msc: CBWDecode: >> READ_CAPACITY
[00:38:18.965,669] <dbg> usb_msc: mass_storage_bulk_in: < BI - MSC_SEND_CSW
[00:38:18.965,958] <dbg> usb_msc: mass_storage_bulk_in: < BI - MSC_WAIT_CSW
[00:38:18.966,617] <dbg> usb_msc: mass_storage_bulk_out: > BO - MSC_READ_CBW
[00:38:18.966,625] <wrn> usb_msc: >> default CB[0] 5a
[00:38:18.966,643] <err> usb_dc_mcux: Failed to fill ep 0x81 buffer
[00:38:18.966,649] <err> usb_msc: usb write failure
[00:38:18.967,026] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x00
[00:38:18.967,036] <dbg> usb_device: custom_handler: bRequest 0x00, wIndex 0x0081
[00:38:18.967,088] <dbg> usb_device: usb_handle_control_transfer: ep 0x80, status 0x02
[00:38:18.967,097] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x01
[00:38:18.967,606] <dbg> usb_device: usb_handle_control_transfer: ep 0x00, status 0x00
[00:38:18.967,614] <dbg> usb_device: custom_handler: bRequest 0x01, wIndex 0x0081
[00:38:18.967,622] <inf> usb_device: Clear halt ep 0x81
[00:38:18.967,637] <dbg> usb_msc: mass_storage_status_cb: USB unknown state
[00:38:18.967,660] <dbg> usb_device: usb_handle_control_transfer: ep 0x80, status 0x02
Environment (please complete the following information): OS: Linux (Ubuntu 22.04.1 LTS). Toolchain: Zephyr SDK 0.15.2
Additional context
I found the issue was from MODE_SENSE10 command do not support by zephyr msc.
[00:38:18.966,625] <wrn> usb_msc: >> default CB[0] 5a
[00:38:18.966,643] <err> usb_dc_mcux: Failed to fill ep 0x81 buffer
[00:38:18.966,649] <err> usb_msc: usb write failure
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (15 by maintainers)
It looks different to me, I think it is more about throughput, nRF52840DK has a full-speed device controller and SD card is connected via SPI, the throughput is very low, the disk (SD card), based on the data from pcap file has no partitions and is formatted FAT32,
During the mount, the host filesystem driver will read a lot of clusters, to get information about the filesystem, BPBs, FATs, RD… And because throughput is very low (about 127 kB/s, reading 1000 clusters) it will take some time (16s for me using disk with the same geometry). One will see the same low throughput coping files from the disk. The same SD card in a modern card reader, but forced to full-speed, has a throughput of about 789 kB/s. On nRF52840, the throughput for the bulk transfers is about 460 kB/s. Emulating the disk geometry above with #62286, I see throughput of about 386 kB/s (577 kB/s on FRDM K64F, there is also some MSC communication overhead and based on sector number emulation overhead). The limiting factor is the SD card connected via SPI interface and there is nothing we can do to improve it.