-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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 MSC fails 'Command Set Test' from USB3CV. #26275
Comments
I'm unable to replicate this on a Linux host with current master with the nrf52840dk_nrf52840 board-specific configurations removed and building
If the overlay and configuration in In neither case do I get the output described. Presumably there's some external tool being used to produce the failure, so it'll have to be diagnosed by somebody who has access to it. |
Neither do I but from that commit the test starts to fail. I will take some time to investigate it. |
Works just fine with |
That's a lot more plausible. I suspect a mismatch between the 4 KiBy block size and the block size the test and Windows is expecting. Maybe setting I'll look into this when I'm working zephyr next week. |
I don't think so. EP size is well defined by USB spec and its just number of Bytes that could be send at once. It has nothing to the block sizes of flash storage. Furthermore FS USB device Bulk endpoints could be 8, 16, 32 or 64 bytes in size. |
I will do a pre-study of that. |
Looking at the details of the test image capture above it appears the test involves trying to write FAT file system data to the mass storage device. That isn't going to work with the littlefs file system, because the flash device is configured for littlefs operations using 16 4 KiBy blocks. Does a generic mass storage device have to present a disk architecture that is compatible with a FAT file system? If not, the test failure is not due to a bug in Zephyr. |
Hi, the test tool is using FAT fs data to write/read form the device so I expected it to work when I change: diff --git a/samples/subsys/usb/mass/boards/nrf52840dk_nrf52840.conf b/samples/subsys/usb/mass/boards/nrf52840dk_nrf52840.conf
index ae48b5c29f..8f6f69ff4c 100644
--- a/samples/subsys/usb/mass/boards/nrf52840dk_nrf52840.conf
+++ b/samples/subsys/usb/mass/boards/nrf52840dk_nrf52840.conf
@@ -8,7 +8,7 @@ CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_MASS_STORAGE_DISK_NAME="NAND"
CONFIG_FILE_SYSTEM=y
-CONFIG_FILE_SYSTEM_LITTLEFS=y
+CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FLASH_LOG_LEVEL_INF=y
CONFIG_FLASH_MAP=y Same result as with littlefs. I think the file system may have nothing to it. I tried to find requirements for USB 3CV test tool when it comes to filesystem but I can not find any info about it. @jfischer-phytec-iot any clues? |
I checked with Flash based app (internal flash, not the MX25R64) with LITTLEFS file system and the tests are passing. I am not sure what is going on here. diff --git a/samples/subsys/usb/mass/boards/nrf52840dk_nrf52840.conf b/samples/subsys/usb/mass/boards/nrf52840dk_nrf52840.conf
index ae48b5c29f..0f42340af7 100644
--- a/samples/subsys/usb/mass/boards/nrf52840dk_nrf52840.conf
+++ b/samples/subsys/usb/mass/boards/nrf52840dk_nrf52840.conf
@@ -1,7 +1,3 @@
-# Storage is on MX25R64
-CONFIG_NORDIC_QSPI_NOR=y
-CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
-
# Must match the registered name for the selected disk access variant:
# "RAM" via DISK_RAM_VOLUME_NAME for DISK_ACCESS_RAM
# "NAND" via DISK_FLASH_VOLUME_NAME for DISK_ACCESS_FLASH
@@ -11,12 +7,14 @@ CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y
CONFIG_FLASH_LOG_LEVEL_INF=y
+CONFIG_MPU_ALLOW_FLASH_WRITE=y
+
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_DISK_ACCESS_FLASH=y
-CONFIG_DISK_FLASH_DEV_NAME="MX25R64"
-CONFIG_DISK_FLASH_START=0x0
+CONFIG_DISK_FLASH_DEV_NAME="NRF_FLASH_DRV_NAME"
+CONFIG_DISK_FLASH_START=0xf8000
CONFIG_DISK_VOLUME_SIZE=0x10000
CONFIG_DISK_FLASH_MAX_RW_SIZE=4096
CONFIG_DISK_FLASH_ERASE_ALIGNMENT=0x1000 There are tons of errors form mass storage class saying:
|
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
I had another look into this issue. The fact that the test is failing is because the write is so slow that it gets time outed. This is not the fail by itself. The test fails due to fact than in case of timeout the device is being Reset through MSC reset. This is the part that does not work and need fix. Im working to find a solution for that. |
The fact that the test is failing exposed two weaknesses within the sample:
Measurements: Additional context Screenshot from USB logic analyzer of the USB traffic: Screenshot from USB3CV test tool: This is not easy task to be fixed as a simple bug fix. To fix that we need:
Summon @pabigot, @kamlaz, @carlescufi (fyi) + whoever is responsible for disk access API. Could not any Codeowner for that. |
For the time being the proposed solution would be instead to offload the calls to the disk access API to a separate queue or thread, and find a way to report to the Host that the data has not been written yet to prevent new data from coming in. |
There is no documented way to stop Host from sending when the device is busy. USB is driven by Host and the only thing we can do i not accepting the data, what we clearly do. The problem is writes are slow and the test timeouts. |
Due to relatively long sector-erase times of the QSPI in SoC Flash, and the fact that MSC block size and Flash sector size are different, and disk subsystem accesses are not cached, this sample fails during USB CV test. Reduce partition size for nrf52840dk_nrf52840 as a workaround. The RAM disk configuration is not affected by this and has shorter runtimes during testing. Resolves: zephyrproject-rtos#26275 Signed-off-by: Johann Fischer <[email protected]>
USB MSC sample has been expanded over time. Config overlays for RAM disk and flash disks were added. Board specific overlays followed. It was overlooked that they forced a specific configuration for the nrf52840dk_nrf52840 board, even if it was not explicitly desired (for example RAM-disk). This also caused strange behaviour during automatic MSC USB3CV tests (which explicit selects RAM-disk) so that nrf5340dk_nrf5340_cpuapp board passed test but nrf52840dk_nrf52840 failed. Rework disk and file system configuration, and initialization code, allow to use FAT file system on top of RAM disk. This sample can be built with none or one of two supported file systems, LittleFS or FATFS. Disk subsystem can be flash or RAM based. LittleFS only works with flash disk. There are four useful possibilities: - RAM disk without any file system for testing (default) - RAM disk with FAT file system - flash disk with FAT file system - flash disk with LittleFS Flash disk configurations is only available (as before) for nordic,qspi-nor compatible, but only need the device tree overlay per platform without a config overlay. This path also revises test cases. Remove invalid "flash" tag from depends_on key. Remove unnecessary gpio tag and exclude native platform. Resolves: zephyrproject-rtos#26275 Signed-off-by: Johann Fischer <[email protected]>
USB MSC sample has been expanded over time. Config overlays for RAM disk and flash disks were added. Board specific overlays followed. It was overlooked that they forced a specific configuration for the nrf52840dk_nrf52840 board, even if it was not explicitly desired (for example RAM-disk). This also caused strange behaviour during automatic MSC USB3CV tests (which explicit selects RAM-disk) so that nrf5340dk_nrf5340_cpuapp board passed test but nrf52840dk_nrf52840 failed. Rework disk and file system configuration, and initialization code, allow to use FAT file system on top of RAM disk. This sample can be built with none or one of two supported file systems, LittleFS or FATFS. Disk subsystem can be flash or RAM based. LittleFS only works with flash disk. There are four useful possibilities: - RAM disk without any file system for testing (default) - RAM disk with FAT file system - flash disk with FAT file system - flash disk with LittleFS Flash disk configurations is only available (as before) for nordic,qspi-nor compatible, but only need the device tree overlay per platform without a config overlay. This path also revises test cases. Remove invalid "flash" tag from depends_on key. Remove unnecessary gpio tag and exclude native platform. Resolves: zephyrproject-rtos#26275 Signed-off-by: Johann Fischer <[email protected]>
USB MSC sample has been expanded over time. Config overlays for RAM disk and flash disks were added. Board specific overlays followed. It was overlooked that they forced a specific configuration for the nrf52840dk_nrf52840 board, even if it was not explicitly desired (for example RAM-disk). This also caused strange behaviour during automatic MSC USB3CV tests (which explicit selects RAM-disk) so that nrf5340dk_nrf5340_cpuapp board passed test but nrf52840dk_nrf52840 failed. Rework disk and file system configuration, and initialization code, allow to use FAT file system on top of RAM disk. This sample can be built with none or one of two supported file systems, LittleFS or FATFS. Disk subsystem can be flash or RAM based. LittleFS only works with flash disk. There are four useful possibilities: - RAM disk without any file system for testing (default) - RAM disk with FAT file system - flash disk with FAT file system - flash disk with LittleFS Flash disk configurations is only available (as before) for nordic,qspi-nor compatible, but only need the device tree overlay per platform without a config overlay. This path also revises test cases. Remove invalid "flash" tag from depends_on key. Remove unnecessary gpio tag and exclude native platform. Resolves: #26275 Signed-off-by: Johann Fischer <[email protected]>
USB MSC fails 'Command Set Test' from USB3CV.
Platform: nRF52840dk (nRF52840dk_nrf52840).
The issue was introduced by #24696. cc @pabigot.
Originally posted by @emob-nordic in #14302 (comment)
The text was updated successfully, but these errors were encountered: