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.
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 » Fri Sep 02, 2016 3:16 am

It seems that all MAC OS and Linux problems are related to an unhandled MSD_REQ_RESET
As required by the BOT specification, the Bulk-only mass storage reset request (classspecific
request) is implemented. This request is used to reset the mass storage device and
its associated interface. This class-specific request should prepare the device for the next
CBW from the host.
To generate the BOT Mass Storage Reset, the host must send a device request on the
default pipe of:
• bmRequestType: Class, interface, host to device
• bRequest field set to 255 (FFh)
• wValue field set to ‘0’
• wIndex field set to the interface number
• wLength field set to ‘0’


Giovanni, Is it possible to reset all endpoints? I have looked for this in the USB driver and found nothing like that.

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 Sep 06, 2016 5:46 am

Well, some results so far...
I got USB-IF USB20CV compliance tool and ran tests for the MSC device.
The main trouble is in the error recovery:
► Show Spoiler

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 » Thu Oct 13, 2016 3:51 pm

Hello there.
In our new project we need to store debug data in NAND and read it later. Writing to
ring buffer organized in NAND is not a big deal but downloading it from device to PC is.
Doing it via UART looks ugly so we decided to use USB mass storage class. I have
working proof of concept driver running on Nucleo-F767zi board. I can
move further development to community repository if any body interested.

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 17, 2016 2:32 pm

I think that the standard MSD driver will be very useful. My driver works but cannot pass USB consortium tests. I will upload the latest version soon

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 17, 2016 2:52 pm

I have pushed code to community repo. Code has many places to cleanups and improvements.
Any way it works fine in my Gentoo Linux:

Code: Select all

[  567.208067] usb 3-1: USB disconnect, device number 3
[  587.420015] usb 3-1: new full-speed USB device number 4 using uhci_hcd
[  587.595112] usb 3-1: New USB device found, idVendor=0483, idProduct=5740
[  587.595115] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  587.595117] usb 3-1: Product: ChibiOS/RT Mass Storage Device
[  587.595119] usb 3-1: Manufacturer: STMicroelectronics
[  587.595121] usb 3-1: SerialNumber: AECCECCCC400
[  587.599163] usb-storage 3-1:1.0: USB Mass Storage device detected
[  587.600241] scsi host3: usb-storage 3-1:1.0
[  588.644124] scsi 3:0:0:0: Direct-Access     Chibios  Mass Storage     v4.0 PQ: 0 ANSI: 4
[  588.651114] sd 3:0:0:0: [sdc] 700 512-byte logical blocks: (358 kB/350 KiB)
[  588.654110] sd 3:0:0:0: [sdc] Write Protect is on
[  588.654113] sd 3:0:0:0: [sdc] Mode Sense: 03 00 80 00
[  588.657107] sd 3:0:0:0: [sdc] No Caching mode page found
[  588.657110] sd 3:0:0:0: [sdc] Assuming drive cache: write through
[  588.699113] sd 3:0:0:0: [sdc] Attached SCSI removable disk
[  588.797104] romfs: Mounting image 'rom 57fca96e' through the block layer

But it windose it locks in debug trap

Code: Select all

  osalDbgAssert(!usbGetTransmitStatusI(usbp, ep), "already transmitting");
in usbStartTransmitI() function. I have no ideas why but I did not do any investigations there.

I use NUCLEO-F767 board for development. I think code may run on any Nuclen-144 board.
Any suggestions/bugreports you can submit in this topic on directly on github.

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: USB Mass Storage Device

Postby Giovanni » Mon Oct 17, 2016 3:00 pm

hi,

Is the state checker enabled too?

Apparently a transmission is attempted while the endpoint is not yet ready.

Giovanni

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 17, 2016 3:07 pm

Giovanni wrote:Is the state checker enabled too?

Yes, all checks enabled.

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 17, 2016 3:39 pm

@Giovanni
Are there any "standard" switchable debug printing macros somewhere in ChibiOS?
They would be very useful for debugging such subsystems like SCSI, mass storage, etc.

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: USB Mass Storage Device

Postby Giovanni » Mon Oct 17, 2016 3:44 pm

Not yet, that would be useful, it should go in the HAL probably. I'll add it to the things to do next in the HAL. The others are a critical errors handler and a runtime errors events handler.

Giovanni

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 » Wed Oct 19, 2016 12:16 am

@bartness, have you tried the USB compliance tool USB20CV?
http://www.usb.org/developers/tools/usb20_tools/
There are many MSD drivers now, but the main purporse should be compliance with the standard...


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 40 guests