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.
jayalfredprufrock
Posts: 36
Joined: Tue Jan 13, 2015 6:33 am
Has thanked: 8 times

Re: USB Mass Storage Device

Post by jayalfredprufrock »

I've been integrating some of the MSD code DeusExMachina shared and have noticed some weird behavior. Files saved to the root directory of the device are not persisted. This happens regardless of how I disconnect the MSD device (eject, software disconnect, etc.) Saving files in subfolders works great, and reading files anywhere on the filesystem also works as expected. I've tried copying files on both Windows and OSX and everything appears to work on the computer side, but when I reboot the device, any files saved to the root directory are no where to be found. Has anybody experienced this problem or have any ideas as to what could be going on??
jayalfredprufrock
Posts: 36
Joined: Tue Jan 13, 2015 6:33 am
Has thanked: 8 times

Re: USB Mass Storage Device

Post by jayalfredprufrock »

The problem ended up being how I was switching between the Serial and MSD drivers. I needed the ability to move between the two without a reset so I carefully disable one usb driver and reenable the other when everything is idle. The SDC driver remains active the entire time, I just make sure no sd card actions can be performed while in MSD mode and that any pending actions complete before switching drivers.

I discovered the problem with root files not persisting only occurs when transitioning from MSD -> Serial and that everything works fine if I shutdown the system while in MSD mode without transitioning back to Serial. If I explicitly unmount the filesystem after disconnecting the MSD driver and remount before enabling the Serial driver my problem goes away. I'm not entirely sure why that step is necessary, but I wanted to share the solution nonetheless.

P.S. Performance is meh and the device doesn't pass MSC tests so I'm still really hoping Koen comes through with his code!! Thanks to all!
Koen
Posts: 35
Joined: Mon Dec 21, 2015 12:15 am
Been thanked: 5 times

Re: USB Mass Storage Device

Post by Koen »

Hey, I will but I have too much to do until next weekend.
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: USB Mass Storage Device

Post by DeusExMachina »

jayalfredprufrock wrote:The problem ended up being how I was switching between the Serial and MSD drivers. I needed the ability to move between the two without a reset so I carefully disable one usb driver and reenable the other when everything is idle.

I had the same requirements although I have implemented the serial driver in a bootloader and now an app switches here and there if necessary. BTW I have found another trouble - it seems that serial SDU driver does not work well in Linux. I do have ttyACM0 device, but actual communications fail.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: USB Mass Storage Device

Post by Giovanni »

SDU works for me in Mint using CuteCom. The driver does not implement all CDC commands so if your communication program tries to use unimplemented commands the driver stops.

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

Re: USB Mass Storage Device

Post by DeusExMachina »

I tried with minicom console app. I will try another terminal program.
puff
Posts: 1
Joined: Thu May 04, 2017 10:47 pm

Re: USB Mass Storage Device

Post by puff »

DeusExMachina wrote:
Another issue was revealed today - MSD device does not work in iOS El-Capitan.
I really should find some time to put out my code on github...

Hey!
What's the reason that it works on older macs and it doesn't in El Capitan?
Actually, I'm having troubles with cdc thing on El Capitan. (with /dev/usbmodem311 device - hope, I'm not mistaken, it's a cdc device, right?)
Although it works just fine with older systems (e.g. Yosemite). Moreover, it seems that while with ChibiOS v.2 the usb hub helped, with upgrade to 3.2, this trick doesn't work anymore...
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: USB Mass Storage Device

Post by DeusExMachina »

puff wrote:Hey!
What's the reason that it works on older macs and it doesn't in El Capitan?
Actually, I'm having troubles with cdc thing on El Capitan. (with /dev/usbmodem311 device - hope, I'm not mistaken, it's a cdc device, right?)
Although it works just fine with older systems (e.g. Yosemite). Moreover, it seems that while with ChibiOS v.2 the usb hub helped, with upgrade to 3.2, this trick doesn't work anymore...


It seems that you have mixed up Mass storage device class (MSD) and CDC (communication device class)
MSD allows working with USB disks.
CDC emulates serial port (roughly).

You may check my latest MSD code, it should work in El Capitan (I hope), but speed is quite slow (~800Kb/s).
As for CDC I did test it with Mac OS, and it was not functional.
Ceco
Posts: 40
Joined: Tue Nov 27, 2012 12:16 pm
Been thanked: 3 times

Re: USB Mass Storage Device

Post by Ceco »

Hello to everyone.

What is the current state of MSD implementation? Us I understand there is no (and probably will not have) an official release of such a driver in Chibios. Is this correct?

From other side, there are few contributed projects (links inside the forum thread), but it's difficult for me to find a summarized results achieved by deferent peoples.

What is the maximum throughput achieved with USB-HS in MSD mode and F4/F7 cores? Is it works stable with Windows and Linux? Where is the bottle neck?

I'm searching for a solution to access SD card with around 8-10 Mbytes/s read access. Is it possible at all?
jayalfredprufrock
Posts: 36
Joined: Tue Jan 13, 2015 6:33 am
Has thanked: 8 times

Re: USB Mass Storage Device

Post by jayalfredprufrock »

I noticed today that MSD code (hacked together mainly from DeusExMachina's contributions) is suddenly performing very poorly on Windows 10. When the device is plugged in, the drivers seem to install fine and windows recognizes everything properly within device manager without any warnings, however it generally takes at least 3-5 minutes for the drive to actually mount and become available as a disk. Windows 7 works great, and at some point Windows 10 was working just fine too. I'm not positive, but I think this started happening after installing the latest windows 10 "creator's update". I'm wondering if anybody with an updated Windows 10 machine that has been using any of the MSD code in this thread can confirm that they see this behavior as well. These kinds of problems can quickly become a black hole and I want to be sure the problem doesn't lie specifically within my own code.
Post Reply