Slow USB MSC transfer speed on nRF5340 with SD card

In our design, we wired the SD card in SPI mode on SPI bus 4 wich a maximum SPI frequency of 50 MHz or 25 MHz as these are supported by the SD card. We used FAT32 file system, but later enabled support for exFAT and formated the SD card with exFAT. For internal logging from our device to the SD card, there is no issue. However, when we try to offload the data from SD card to a host machine, we are having an extremely slow transfer speed: When offloading a 10.5 MB binary file, it takes around 420 seconds, which effectively is only 90 KB/s. We have tried both 25 and 50 MHz SPI frequency but the result is very similar.

We are using USB legacy stack with NCS 3.0.2. I attached here our Kconfigs related to USB.

# Configure USB device
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="BORUS"
CONFIG_USB_DEVICE_PID=0x0001
CONFIG_USB_DEVICE_VID=0x0001
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_SERIAL=n
CONFIG_USB_CDC_ACM=n
CONFIG_UART_INTERRUPT_DRIVEN=n
CONFIG_UART_LINE_CTRL=n
CONFIG_BOARD_SERIAL_BACKEND_CDC_ACM=n
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n

# Configure USB device to appear as DFU class
# Configure DFU autoupdate and reset
CONFIG_USB_DFU_CLASS=y
CONFIG_USB_REQUEST_BUFFER_SIZE=128
CONFIG_USB_DFU_ENABLE_UPLOAD=y
CONFIG_USB_DFU_PERMANENT_DOWNLOAD=y
CONFIG_USB_DFU_REBOOT=y
CONFIG_IMG_MANAGER=y
CONFIG_STREAM_FLASH=y
CONFIG_BOOTLOADER_MCUBOOT=y

# Configure file system 
CONFIG_FLASH_MAP=y
CONFIG_FLASH=y
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=n
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FS_FATFS_LFN=y
CONFIG_FS_FATFS_EXFAT=y
CONFIG_FS_LOG_LEVEL_INF=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

# Configure mass storage
CONFIG_USB_MASS_STORAGE=y
CONFIG_DISK_ACCESS=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y
CONFIG_DISK_LOG_LEVEL_DBG=y
CONFIG_DISK_DRIVERS=y
CONFIG_DISK_DRIVER_SDMMC=y
CONFIG_DISK_DRIVER_FLASH=y
CONFIG_MASS_STORAGE_DISK_NAME="SD"

Parents Reply
  • I used MacOS as host machine. I have a single 10.5 MB binary file in the SD card, I copy the file and start counting time then a simple divide. Transfer speed is very similar with FAT32 and exFAT. The only difference I can observe from exFAT is increased stability. When we use FAT32 at the beginning, copying large files like 10 MB will sometime trigger an automatic ejection of SD card from host machine. While exFAT won't cause this issue. 

Children
Related