USB Full-Speed Transfer

Hello

I am looking to use [as much as possible of] the full-speed USB bandwidth of 12 Mbps (or 1.5 MBps).

I have been able to use the USB MSC for my initial testing (with the only modification of expanding the file system size to the full 8 MB of the MX25R64 chip) on the nrf5340 DK.

I am successful in my attempts to generate a 4 MB file, and test the transfer from the board (as a FAT32 fs) to a Windows machine or Linux machine.

Using the article  RE: USB speed issue on nRF52840, I am observing a transfer speed of only 395 KBps, or 0.395 MBps. This is only a fraction of the full-speed capability.

Here is my output when I plug in the DK to a Raspberry Pi  4 Model B and run the "sudo dd" command. I made sure to plug the DK via USB into the USB 2 port as well as the USB 3 port (this resulted in a transfer speed of 391 KBps).

Note also that I tested the transfer speed on a windows machine with both the PowerShell command,

Measure-Command { Copy-Item D:/test_file.txt . } # Copy from the removable drive (D:) to this directory

as well as a simple python script:

import time, shutil, os

def file_transfer_test():
    filename = "test_file.txt"
    source = "D:/"
    destination = "C:/Users/Robert.deBrum/"

    print("deleting file")
    os.unlink(destination + filename)

    print("copying file")
    startTime = time.time()
    shutil.copy(source + filename, destination)
    diff = time.time() - startTime

    print("file transfer time = " + str(diff))
    print("file transfer speed = " + str(1 / diff) + " MB/s")

    return diff

Both testing procedures reported transfer speeds of ~0.3 MBps as well, so I am seeing consistent results.

Are there any considerations or configurations that I can employ to use the full bandwidth of the supported Full-Speed USB protocol?

Thanks

  • Hello Hakon,

    Thanks very much for your help on this. I appreciate your time.

    Could you advise/elaborate a little further on some of these topics then? I would love to be able to make some progress as quickly as possible:

    1. We went with the nrf5340 thinking that we could utilize the Full-Speed USB bus to transfer up to 230MB in under 6 minutes (This is  232 / (6*60) = 0.640 MBps). The specification of 12Mbps was very appealing to us. Is there is any hope that we can achieve 640+ KBps USB speeds?
    2. How fast can we expect transfer speeds to be with an HID or CDC USB sample running on the n4f5340? This would get us away from the Bulk Endpoint, correct?
    3. According to the USB Developers Guide (https://doc.lagout.org/science/0_Computer%20Science/9_Others/9_Misc/USB%20Complete%20The%20Developer%27s%20Guide%204th%20Ed.pdf - page 74), Full-Speed USB should be able to achieve up to 1.2 MBps. This is calculated by the same 64B per frame that you mentioned, so where does the 125 us that you mention come into play? It is also mentioned in here that Full-Speed does not use microframes.
    4. At the very least, could we implement DPPI or EasyDMA in any way to get closer to the calculated max speed of 500KBps? How would you propose we implement these components?

  • Hi,

     

    Robert de Brum said:
    Full-Speed USB should be able to achieve up to 1.2 MBps. This is calculated by the same 64B per frame that you mentioned, so where does the 125 us that you mention come into play? It is also mentioned in here that Full-Speed does not use microframes.

    My apologies for misinforming you. You're right, the full speed PHY does not have microframes, but high speed (ie. usb 2.0) has.

    The USBD peripheral is USB 2.0 compliant, but operates on USB 1.1 PHY, and I mixed up the properties of these two. 

    Robert de Brum said:
    How fast can we expect transfer speeds to be with an HID

    HID is interrupt based, which has a restriction of 64 kB/s max (64 bytes each 1 ms).

    Robert de Brum said:
    CDC USB sample running on the n4f5340?

    CDC is also bulk. You will get similar numbers as with MSC.

    Robert de Brum said:
    At the very least, could we implement DPPI or EasyDMA in any way to get closer to the calculated max speed of 500KBps? How would you propose we implement these components?

    I have reported to R&D that they should look at the overall throughput, but the limiting factor here looks to be the processing in the zephyr usb subsys and the nrfx layer.

    When doing a test at 128 MHz (by setting HFCLKCTRL register: https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/clock/doc/clock.html?cp=3_0_0_3_10_2_43#register.HFCLKCTRL) I was able to get a bit better throughput.

     

    Kind regards,

    Håkon

Related