I am relieved, I was scheduled for a semaphore-related bug nightmare this night
Giovanni
USB Mass Storage Device
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
-
- Posts: 9
- Joined: Wed Oct 03, 2012 9:12 am
Re: USB Mass Storage Device
Hi guys,
I posted a new question related to the Mass Storage device, here: viewtopic.php?f=3&t=666#p6704
Fred
I posted a new question related to the Mass Storage device, here: viewtopic.php?f=3&t=666#p6704
Fred
-
- Posts: 26
- Joined: Fri Oct 05, 2012 3:16 pm
- Been thanked: 1 time
Re: USB Mass Storage Device
Hi,
I am playing a bit with USB Mass Storage and it works out of the box...but I have some questions
To be noted that I tried everything on a P407 board tweaked to have the SD card operating in SDIO mode instead of SPI.
So, when I read/write some files from the micro-SD card (4GB SDHC, FatFS) through UMS, the performance are really poor. It took around 13 minutes to copy a 170MB file on the SD card while it took only 18 seconds with the same card but using a USB/micro-SD card reader.
I have compared what lsusb tells me about both devices. The only differences are:
- UMS code declares the end point addresses to be "0x81 EP 1 IN" and "0x01 EP 1 OUT" while the USB/SD reader declares "0x82 EP 2 IN" and "0x01 EP 1 OUT"
- the wMaxPacketSize for both end points are "0x0040 1x 64 bytes" against "0x0200 1x 512 bytes"
- the bInterval for both end points are 5 against 0
Looking at the USB specs, it seems that bInterval is ignored in bulk mode. Moreover, wMaxPacketSize must be 64 bytes max. So it seems that everything is ok.
I've found on the net that for High Speed USB the wMaxPacketSize should be 512. But I didn't find anything in the USB specs.
I obviously tried to set 512 as wMaxPacketSize but everything became unstable, lot of USB reset requested (apparently it is not handled properly according to the TODO)... In the end, I did not succeed in copying my test file...
What's going wrong?!
Shouldn't we be able to reach the same transfer rate as a USB/micro-SD reader?
What is the problem with 512 packet size?
Does the USB-OTG port of the P407 act like a USB-FS rather than USB-HS? How to check that? (to be noted that I use USBD2 in my code, not USBD1, so this is the correct port!)
Any hint? I've read all the threads on the forum regarding USB, SD stuff... but I have no clue!
I am playing a bit with USB Mass Storage and it works out of the box...but I have some questions
To be noted that I tried everything on a P407 board tweaked to have the SD card operating in SDIO mode instead of SPI.
So, when I read/write some files from the micro-SD card (4GB SDHC, FatFS) through UMS, the performance are really poor. It took around 13 minutes to copy a 170MB file on the SD card while it took only 18 seconds with the same card but using a USB/micro-SD card reader.
I have compared what lsusb tells me about both devices. The only differences are:
- UMS code declares the end point addresses to be "0x81 EP 1 IN" and "0x01 EP 1 OUT" while the USB/SD reader declares "0x82 EP 2 IN" and "0x01 EP 1 OUT"
- the wMaxPacketSize for both end points are "0x0040 1x 64 bytes" against "0x0200 1x 512 bytes"
- the bInterval for both end points are 5 against 0
Looking at the USB specs, it seems that bInterval is ignored in bulk mode. Moreover, wMaxPacketSize must be 64 bytes max. So it seems that everything is ok.
I've found on the net that for High Speed USB the wMaxPacketSize should be 512. But I didn't find anything in the USB specs.
I obviously tried to set 512 as wMaxPacketSize but everything became unstable, lot of USB reset requested (apparently it is not handled properly according to the TODO)... In the end, I did not succeed in copying my test file...
What's going wrong?!
Shouldn't we be able to reach the same transfer rate as a USB/micro-SD reader?
What is the problem with 512 packet size?
Does the USB-OTG port of the P407 act like a USB-FS rather than USB-HS? How to check that? (to be noted that I use USBD2 in my code, not USBD1, so this is the correct port!)
Any hint? I've read all the threads on the forum regarding USB, SD stuff... but I have no clue!
Re: USB Mass Storage Device
I'm away from my computer at the moment so I can't answer in much detail, but as far as I'm aware on f4 the ports are only FS unless you use an external PHY, so that's going to limit it severely. I've got an oilmex stm32 e407 that I intend to do proper testing with one day...
Re: USB Mass Storage Device
For full-speed USB, bulk endpoints are limited to a maximum of 64 byte endpoints. Based on your timing, you are writing at ~225kB/sec, which is well below the USB bandwidth so I would expect the slowness you are seeing is related to writing to the SD card. To get the best performance on an SD card you should be writing in erase-block sizes (which requires a lot of ram, depending on the card), and this is likely what the card reader is doing. However, is likely that you are writing to the card in smaller chunks (since you have an stm32 w/ limited ram), which will kill performance.
Perhaps you can test the write speed of your sd-card without usb getting involved (using the same block size writes that the msd driver uses). Then, if you want to see how fast you can really go, try to write in erase sized blocks, or keep increasing the size of the write and at some point it will go much quicker.
Perhaps you can test the write speed of your sd-card without usb getting involved (using the same block size writes that the msd driver uses). Then, if you want to see how fast you can really go, try to write in erase sized blocks, or keep increasing the size of the write and at some point it will go much quicker.
Re: USB Mass Storage Device
Question:
Shouldn't this code...
... be something like this ... ?
Shouldn't this code...
Code: Select all
/**
* @brief IN EP1 state.
*/
static USBInEndpointState ep1InState, ep1OutState;
... be something like this ... ?
Code: Select all
/**
* @brief IN EP1 state.
*/
static USBInEndpointState ep1InState;
static USBOutEndpointState ep1OutState;
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: USB Mass Storage Device
Hello,
- is this code still the preferred way to ease USB Mass Storage Device for ChibiOS version 3 ?
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: USB Mass Storage Device
Hi,
There is no official MS support yet, this is still the best attempt so far. I think adapting it to 3.0 should not take long.
Giovanni
There is no official MS support yet, this is still the best attempt so far. I think adapting it to 3.0 should not take long.
Giovanni
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 14 guests