USB Mass Storage Device

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
DrTon
Posts: 6
Joined: Sat Oct 22, 2016 9:30 pm

Re: USB Mass Storage Device

Postby DrTon » Sat Oct 22, 2016 9:39 pm

Hi all!

First of all thanks a lot for the great OS and MSD driver! :)
I'm trying to run code of DeusExMachina from https://github.com/Nomados/Chibios-16.x ... age-device but on ChibiOS 3.
I had to make only two changes (uncomment usbPrepareReceive/usbPrepareTransmit) and it works fine on Windows XP.
But not on Mac OS (10.9.5), dmesg doesn't show anything useful, in system info I see the device but it's "not configured".
Any ideas what to try, maybe need to change something else for ChibiOS 3?
Hardware is Pixhawk autopilot (https://pixhawk.org/modules/pixhawk) with STM32F427.

User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Location: South Korea
Has thanked: 3 times
Been thanked: 3 times

Re: USB Mass Storage Device

Postby DeusExMachina » Mon Oct 24, 2016 11:23 am

@DrTon
Actually I have already solved this trouble with MacOS. Today I updated my code on github, please check it out again.

User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Location: Minsk, Belarus
Been thanked: 7 times

Re: USB Mass Storage Device

Postby barthess » Mon Oct 24, 2016 12:39 pm

@DeusExMachina
I have downloaded USB compliance tool USB20CV but I have no ideas
how to test exact device. What the hell are "test ID", "room number" and "test bed"?
Where I can find them?

DrTon
Posts: 6
Joined: Sat Oct 22, 2016 9:30 pm

Re: USB Mass Storage Device

Postby DrTon » Mon Oct 24, 2016 9:51 pm

@DeusExMachina, thanks a lot, now it works fine!
But is it possible to run HighSpeed USB on STM32F427VI? Datasheet says that it's supported: "USB 2.0 high-speed/full-speed device/host/OTG controller with dedicated DMA, on-chip full-speed PHY and ULPI". Could you point me how to do this?

User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Location: South Korea
Has thanked: 3 times
Been thanked: 3 times

Re: USB Mass Storage Device

Postby DeusExMachina » Tue Oct 25, 2016 12:16 am

barthess wrote:@DeusExMachina
I have downloaded USB compliance tool USB20CV but I have no ideas
how to test exact device. What the hell are "test ID", "room number" and "test bed"?
Where I can find them?

Do not care about these things, they are only for a verification report. If you want to put on "USB compatible" logo you have to pass a formal verification.
Last edited by DeusExMachina on Tue Oct 25, 2016 12:27 am, edited 1 time in total.

User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Location: South Korea
Has thanked: 3 times
Been thanked: 3 times

Re: USB Mass Storage Device

Postby DeusExMachina » Tue Oct 25, 2016 12:24 am

DrTon wrote:@DeusExMachina, thanks a lot, now it works fine!
But is it possible to run HighSpeed USB on STM32F427VI? Datasheet says that it's supported: "USB 2.0 high-speed/full-speed device/host/OTG controller with dedicated DMA, on-chip full-speed PHY and ULPI". Could you point me how to do this?

It is easy if you board has a HS PHY. You should enable USBD2 driver in mcuconf.h and redefine USBD symbol in usb_msd.h.
#define USBD USBD2
Thanks to Chibios HAL this driver is hardware-independent and works as a logical device.

Koen
Posts: 35
Joined: Mon Dec 21, 2015 12:15 am
Been thanked: 5 times

Re: USB Mass Storage Device

Postby Koen » Mon Dec 26, 2016 8:23 am

Hello, I've run a short test today. -O3 compiled, same STM32F7+USB3320 hardware, same 633x SDCard, same SDIO/ULPI configuration, same host computer with an SSD :

dsigma Chibios version reads at 1.05 MB/s (??) and writes at 2.00MB/s (BLOCK_WRITE_ITTERATION_COUNT: 16) or 3.90 MB/s (BLOCK_WRITE_ITTERATION_COUNT: 32).

STM32CubeMX exported project with no changes reads at 7.80 MB/s and writes at 6.40 MB/s.

Is there an obvious difference I missed ? A define I forgot to enable ?

Thank you very much, Koen

User avatar
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

Postby Giovanni » Mon Dec 26, 2016 8:31 am

Hi,

Does the ST driver use DMA? ChibiOS USB driver uses a "pump" thread for moving data, perhaps the performance difference is there because other thread may slow down the USB thread that has very low priority (you may try to raise priority, it is configurable).

Rationale for use of a thread is that only HS OTG has DMA and the driver has to support both FS and HS. If it is proved that the problem is indeed lack of DMA use in the driver then a separate, HS-only, driver could be created.

Apparently both OTGs on the new STM32H7 have DMA so probably such a driver will be created anyway sometime next year, it could serve also as HS-only driver on the F4/F7.

Giovanni

Koen
Posts: 35
Joined: Mon Dec 21, 2015 12:15 am
Been thanked: 5 times

Re: USB Mass Storage Device

Postby Koen » Mon Dec 26, 2016 9:03 am

For the sake of completeness, DeusExMachina version reads at 1MB/s and writes at 350kb/s.

Hello Giovanni, thank you for your answer. I'll look into it now.

Koen
Posts: 35
Joined: Mon Dec 21, 2015 12:15 am
Been thanked: 5 times

Re: USB Mass Storage Device

Postby Koen » Mon Dec 26, 2016 12:19 pm

ST uses multi-block read/write, dsigma chibios version uses multi-block write and single-block read, barthess chibios version uses single-block read/write.

Barthess chibios version (860kB/s / 400kB/s) was the most readable so I've edited it to try 32 blocks read/writes. It now reads at 4.60MB/s and writes at 3.50MB/s. So I'll look into modifying dsigma version to both read and write using its current ping-pong thingy.

STM32CubeMX test did not have any DMA in use, nor for SDIO, nor for HS-USB. And it is twice as fast. I'll look into it later.


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 9 guests