USBHost_t36 USB Mass Storage Driver Experiments

wwatson

Well-known member
Mass Storage Controller (MSC) library for use with Teensy 3.6

This is a project I have been working off and on for two years.
It is a very minimal working USB host mass storage driver for use with the Teensy 3.6 USB host port.
At this time there is very little error checking done. (Not completely processing error and sense codes yet).
Definitely work in progress.

The test program is a modified version of "uSDFS_test.ino" from WMXZ's uSDFS library which can be
found here
Code:
[url]https://github.com/WMXZ-EU/uSDFS[/url]
. That library also uses ELM-ChaN FatFs library.

Tested with Arduino version 1.8.9 and Teensyduino version 1.46b10.
I do not have or use Windows so MSC has not been tested with that operating system. It should work.
It is working with Linux Ubuntu 18.04 and Mate Desktop 1.12.1.

Libraries used:
* USBHost_t36 PJRC USB Host library.
* uSDFS WMXZ Teensy uSDFS library modified for use with msc.
* MSC Mass Storage Controller, USB Flash drives and USB Hard drives. (see below)

Installation:
Install MSC and uSDFS into "~/Arduino/libraries" folder.
No modifications to USBHost_t36 are needed at this time.
In the MSC folder you will find 4 files in the "MSC/uSDFS_Files_Copied_To_uSDFS" folder that
need to be copied to the "~/Arduino/libraries/uSDFS/src" folder.
They are:
diskio.h
diskio.c
ffconf.h
uSDconfig.h
I would back these files up before replacing them.

I modified uSDconfig.h to add Mass Storage drive "0:/". Drive "1:/" is now the native SDHC drive.
How to change the drive identifiers is also documented in this same file.
A drive activity LED is setup on pin 24 in diskio.c for both drives on my T36.
if needed change the define to use another pin.

Kingston, Sandisk and PNY flash drives that I have used all seem to work ok. The PNY flash drive is
really slow to come up. It takes a few seconds. Kind of like the hard drives do.

I have been using a IDE/SATA to USB adapter from StarTech.com to test the hard drives.
Tested several USB Hard Drives, Seagate, Hitachi, Western Digital, and others along with an older IDE drive.
They all take several seconds to come up but are faster than the flash drives.

Here is some output from the test program.

Hard Drive:
Drive "0:/" Mass Storage.
Code:
Mass Storage Contoller with uSDFS

Mounting MSC Device 0:/
Mounting SDHC Device 1:/

-----------------------------------------
Note: USB HD and some flash drives
      can take several seconds to
      come online.
Please Wait...

Volume Label: TEENSY36HD
Volume Serial Number: 950818267

Removable Device: NO
        VendorID: WDC WD25
       ProductID: 00YS-01SHB1     
      RevisionID: 6C06

    Sector Count: 490234751
     Sector size: 512
   Disk Capacity: 490234751 * 512 Bytes
      Free Space: 245053952 Kilo Bytes

Create a new file (hello10.txt).
Write some text lines. (Hello world!)
Close the file.

Open same file (hello10.txt).
Get the file content.
Hello world!
Second Line
Third Line
Fourth Line
Habe keine Phantasie
Close the file.

open binary file
write file
close file
Binary test done

Open root directory.
Directory listing...
      74  HELLO10.TXT
   16384  test00.bin

Done in 160ms

-----------------------------------------
Press a key to test SDHC Drive...

Flash Drive:
Drive "0:/" Mass Storage.

Code:
Mass Storage Contoller with uSDFS

Mounting MSC Device 0:/
Mounting SDHC Device 1:/

-----------------------------------------
Note: USB HD and some flash drives
      can take several seconds to
      come online.
Please Wait...

Volume Label: TEENSYFLASH
Volume Serial Number: 893713543

Removable Device: YES
        VendorID: Kingston
       ProductID: DataTraveler 3.0
      RevisionID:     

    Sector Count: 60437491
     Sector size: 512
   Disk Capacity: 60437491 * 512 Bytes
      Free Space: 30202336 Kilo Bytes

Create a new file (hello10.txt).
Write some text lines. (Hello world!)
Close the file.

Open same file (hello10.txt).
Get the file content.
Hello world!
Second Line
Third Line
Fourth Line
Habe keine Phantasie
Close the file.

open binary file
write file
close file
Binary test done

Open root directory.
Directory listing...
      74  HELLO10.TXT
   16384  test00.bin

Done in 232ms

-----------------------------------------
Press a key to test SDHC Drive...

And drive "1:/"
Code:
Volume Label: TEENSYSDHC
Volume Serial Number: 869690263


Create a new file (hello10.txt).
Write some text lines. (Hello world!)
Close the file.

Open same file (hello10.txt).
Get the file content.
Hello world!
Second Line
Third Line
Fourth Line
Habe keine Phantasie
Close the file.

open binary file
write file
close file
Binary test done

Open root directory.
Directory listing...
      74  HELLO10.TXT
   16384  test00.bin

Done in 190ms

-----------------------------------------
Press a key to test Mass Storage Drive...

I have seen talk of mass storage on Teensy recently on the forum.
I hope others with better programming skills than mine can use this code as a starting point
for development and testing.
I am also curious if and how other drives work with this driver and the T36.
Lot's left to do if people are interested.

References:
xxxajk's UHS30 - Great for understanding how to initialize, read and write to a Mass Storage device with error checking.
Dean Camera's LUFA - Also contains excellent info on Mass Storage.
SCSI https://www.seagate.com/files/staticfiles/support/docs/manual/Interface manuals/100293068j.pdf
http://www.t10.org/lists/2op.htm
USB Bulk Only Transport https://www.usb.org/sites/default/files/usbmassbulk_10.pdf
usb20.pdf

Code:
[ATTACH]16623._xfImport[/ATTACH]
 
Last edited by a moderator:
Looking forward to giving it a try.

Can you supply a link to the needed library :: "MSC Mass Storage Controller"
 
@defragster and others the attached zip file "MSC.zip" contains the MSC folder that is copied to your Arduino sketch folder. In my case that is "Arduino/libraries".
The file "msc.h" contains the class definition of msController which also includes "USBHost_t36.h". The only other libraries needed are USBHost_t36 and uSDFS.
I did it this way so that I don't have multiple versions of USBHost_t36 floating around confusing me. There are installation instructions in the readme file in "MSC.zip".
Then it should compile the example ino file in the example folder.

Got to go to work.
 
@wwatson
Great job on getting this working with UHSHost_t36. Just ordered the StarTech adapter to give it a try :)
 
Thanks for adding USB-Mass storage to uSDFS (I never had time to do it)
Will definitely try it.
 
@WMXZ - Only thing that needs some work is to get it working on the T$ - next gen Teensy :) On a to do list.
 
@WMXZ - then I will leave it to you - just went through it and you are doing things with CTAR table and port mappings that I haven't hit yet on how to do. :)

@wwatson - just gave it a try on a T3.6 with Cruz memory stick. On the second pass in the loop open the hello file failed:
Code:
Mass Storage Contoller with uSDFS

Mounting MSC Device 0:/
Mounting SDHC Device 1:/

-----------------------------------------
Note: USB HD and some flash drives
      can take several seconds to
      come online.
Please Wait...

-----------------------------------------
Press a key to test Mass Storage Drive...
Volume Label: 
Volume Serial Number: 1080426740

Removable Device: YES
        VendorID: SanDisk 
       ProductID: Cruzer Fit      
      RevisionID: 1.26

    Sector Count: 62530623
     Sector size: 512
   Disk Capacity: 62530623 * 512 Bytes
      Free Space: 21131856 Kilo Bytes

Create a new file (hello10.txt).
Write some text lines. (Hello world!)
Close the file.

Open same file (hello10.txt).
Get the file content.
Hello world!
Second Line
Third Line
Fourth Line
Habe keine Phantasie
Close the file.

open binary file
write file
close file
Binary test done

Open root directory.
Directory listing...
   <dir>  LOST.DIR
   <dir>  App Backups
      74  HELLO10.TXT
   16384  test00.bin
      74  HELLO11.TXT
   <dir>  System Volume Information
   <dir>  New folder

Done in 145ms

-----------------------------------------
Press a key to test SDHC Drive...
Volume Label: 
Volume Serial Number: 1080426740


Create a new file (hello10.txt).
Open: Failed with rc=3.
 
Yep. Funny thing is, looks like its suppose to wait for a serial input but I didn't hit any key on the second try. Think I have to look at the sketch again.
 
I will probably try this out as well SOON - but if it is waiting for Serial input on T4, it may be a long wait as we still do not have any USB Serial input support on T4... So if it needs it, you may need to hack up test app to some hardware Serial port.
 
@KurtE
Right now unless the @wmxz updates his library for the T4 it won't work on the T4, only T3.6.
 
@wwatson
Great job on getting this working with UHSHost_t36. Just ordered the StarTech adapter to give it a try :)

I think I have a pair of StarTech that I just 'put away' … but found a KingWin USB to SATA. Thanks for noting that - I stopped reading after grabbing files failed. Will see if it runs soon.

@defragster and others the attached zip file "MSC.zip" contains the MSC folder that is copied to your Arduino sketch folder. In my case that is "Arduino/libraries".
The file "msc.h" contains the class definition of msController which also includes "USBHost_t36.h". The only other libraries needed are USBHost_t36 and uSDFS.
I did it this way so that I don't have multiple versions of USBHost_t36 floating around confusing me. There are installation instructions in the readme file in "MSC.zip".
Then it should compile the example ino file in the example folder.

Got to go to work.

Thanks @wwatson - I got uSDFS and downloaded MSC.zip - but … opps … did not crack it open after looking for where that lib might be :(
 
@mjs513

@wwatson - just gave it a try on a T3.6 with Cruz memory stick. On the second pass in the loop open the hello file failed:

I have not run into this error yet with SDHC. Possibly a problem with the SD card, formatting etc...
Do you have another card you can try? or maybe see if you can read or write to it with another device.
I am using a Sandisk 8 gig SD card formatted to fat32. I have used 16 and 32 gig SD cards with success.

The error code used is defined at about line #50 in "diskio.h" and is used in "diskio.c" in this case the disk_write() function.

@defragster

Thanks @wwatson - I got uSDFS and downloaded MSC.zip - but … opps … did not crack it open after looking for where that lib might be

I'm sorry but I don't understand what you mean by "did not crack it open after looking for where that lib might be". My bad.
 
Finally got everything unzipped and in place to compile this on a T_3.6 - one embedded in a FrankB Teensy_64.

@wwatson - I meant I started pulling the things down - but not realizing the needed MSC LIB was what was in the zip - not just the sketch - I quit that late night without Cracking open that ZIP file to see the library there.

I'm on IDE 1.8.9 with latest TD 1.46b11 and using the current WIP Bluetooth for T_3.6 and T4 local copy of USBHost:
Multiple libraries were found for "USBHost_t36.h"
Used: T:\tCode\libraries\USBHost_T36
Not used: T:\arduino_1.8.9_146\hardware\teensy\avr\libraries\USBHost_t36

The closest drive at hand was an SSD sitting here - not sure when I last used that - plugged into the KingWin adapter:
Press a key to test Mass Storage Drive...
Volume Label:
Volume Serial Number: 0

Removable Device: NO
VendorID: OCZ-VERT
ProductID: EX2
RevisionID: 0008

Sector Count: 351651883
Sector size: 512
Disk Capacity: 351651883 * 512 Bytes
Free Space: 0 Kilo Bytes

Create a new file (hello10.txt).
Open: Failed with rc=13.
I put that SSD drive back into its external housing - and it got nothing.

It worked as far as it could on my Flash with write protect switch:
Press a key to test Mass Storage Drive...
Volume Label: ESD-USB
Volume Serial Number: 3901628584

Removable Device: YES
VendorID: Kanguru
ProductID: FlashBlu 30
RevisionID: PMAP

Sector Count: 30965759
Sector size: 512
Disk Capacity: 30965759 * 512 Bytes
Free Space: 10002040 Kilo Bytes

Create a new file (hello10.txt).
Write some text lines. (Hello world!)
Close the file.
Close: Failed with rc=1.

And an ADATA 64GB Flash drive - just sat after starting without a keyPress:
-----------------------------------------
Note: USB HD and some flash drives
can take several seconds to
come online.
Please Wait...
Mass Storage Contoller with uSDFS

Mounting MSC Device 0:/
Mounting SDHC Device 1:/

-----------------------------------------
Note: USB HD and some flash drives
can take several seconds to
come online.
Please Wait...

The next 8GB small flash seemed to work - to a point:
Code:
Mass Storage Contoller with uSDFS

Mounting MSC Device 0:/
Mounting SDHC Device 1:/

-----------------------------------------
Note: USB HD and some flash drives
      can take several seconds to
      come online.
Please Wait...

-----------------------------------------
Press a key to test Mass Storage Drive...
Volume Label: 
Volume Serial Number: 2763163614

Removable Device: YES
        VendorID: USB     
       ProductID: Flash DISK      
      RevisionID: 1100

    Sector Count: 15826943
     Sector size: 512
   Disk Capacity: 15826943 * 512 Bytes
      Free Space: 16856 Kilo Bytes

Create a new file (hello10.txt).
Write some text lines. (Hello world!)
Close the file.

Open same file (hello10.txt).
Get the file content.
Hello world!
Second Line
Third Line
Fourth Line
Habe keine Phantasie
Close the file.

open binary file
write file
close file
Binary test done

Open root directory.
Directory listing...
   <dir>  System Volume Information
   <dir>  dean
      74  HELLO10.TXT
   16384  test00.bin

Done in 1181ms

-----------------------------------------
Press a key to test SDHC Drive...
Volume Label: 
Volume Serial Number: 2763163614


Create a new file (hello10.txt).
Open: Failed with rc=3.
 
Last edited:
@defragster - Sorry it has so long to respond. Doing a few doubles this week. I can't wait for retirement here in a few months. I will have more time to play.
Anyway, I have not ever had a problem with using uSDFS and SDHC (the builtin SD card slot).

I am not sure how to access TD 1.46b11 or if I can for testing. I am using TD 1.46 (Final).

I have installed the new TD 1.46 final and MSC is working with the Mass Storage devices I have available to me.
I also tried MSC with USBHost_t36-WIP2-Bluetooth with success.

The SSD drive is really interesting. No Volume Label and no serial number. But it is obvious that it is performing the disk inquiry function and disk capacity
function (communicating with the drive through MSC). Free space is zero and file open are failing indicating that the file system is either corrupt or non fat
as used by uSDFS. "rc = 13" is a FatFs code for "There is no valid FAT volume".

The ADATA 64 GB, I have no idea why it appears to stall unless it is really slow to come online. I had a PNY 64GB that took well over a minute to come online.
It did the same thing when I plugged it into my Linux machine.

The last 8GB drive is shown "rc = 3" on the SDHC card. This a FatFs error code for "The physical drive cannot work" or drive not ready. Again, a possible format
problem.

I have only used SanDisk SD cards. They seem to be the easiest to use and are very consistent.

The Flash, HD and SD cards are formated as FAT32 and the Boot Flag is set.

Thanks for testing your hardware with MSC. Will be doing a lot more with detecting and handling errors.
Also with hot plugging.
 
@WMXZ @defragster - I have gone through MSC again and found several bugs and omissions. I have and updated version of MSC. See the attachment below.

This is far more stable than the last version. I also added hot plugging. It recognizes disconnection and reconnection and reinitalizes the drive.
I really wish I had more hardware to test with. Mostly flash thumb drive. These to me seem more practical to me then hard drives for file transfer.

In MassStroageDriver.cpp I have made changes to msController::msDoCommand(msCommandBlockWrapper_t *CBW, void *buffer). The main problem there was
the lack of waiting for the in pipe transfer to complete. I have made several other changes to the library including diskio.c where I took out the
WaitMediaReady() call. It is not needed now and was causing problems.

I hope this helps. I am going to setup again using the latest TD1.47B2 and your uSDFS.
I of course can only test with T3.6.
 

Attachments

  • MSC_v2.zip
    25 KB · Views: 325
@wwatson - Sounds great, will try it. Will be interesting to see how to integrate this back in with the current stuff on uSDFS where some of your previous stuff was brought in... Don't need to copy your files any more...

Maybe we need to edit the diskio.c file on that project to logically add your new additionas, like WaitDriveReady()...

I am guessing that your stuff is not up on Github?

Thanks again
Kurt
 
I tried editing in some of the changes, but maybe made things worse...

I edited the uSDFS file sd_msc.cpp to change: int MSC_disk_status() {return 0;}
to:
Code:
	int MSC_disk_status() 
	{
			int	stat = 0;
			if(!deviceAvailable()) stat = STA_NODISK; // No USB Mass Storage Device Connected
			if(!deviceInitialized()) stat = STA_NOINIT;  // USB Mass Storage Device Un-Initialized
			return stat;
	}

I had a compiler generate an error on deiveAvailable not defined... Which it is MassStorage.h

However the definition in MassStorage.h also generated an error on the like: boolean deviceAvailable(void);

As boolean is not defined. I fixed it in my local copy, by having MassStorage.h include wiring.h which will define boolean.
 
@WMXZ @defragster - I have gone through MSC again and found several bugs and omissions. I have and updated version of MSC. See the attachment below.

This is far more stable than the last version. I also added hot plugging. It recognizes disconnection and reconnection and reinitalizes the drive.
...

Very cool wwatson! I updated p#1 this thread to link here for updated source. If you have it on Github I can update with a pointer there ...
 
Not sure if here or the T4 thread is the best place to discuss/debug...

I tried with the current updated library(libraries) and still having issues with the thumb drives...

@WMXZ and @wwatson - First probably need to figure out how/where the USB Host device should be declared. With the example app as part of "this" library you have it explicitly defined as part of the sketch, where as with the uSDFS code it is defined internal to the library... The issue comes up, for example I thought I would try the thumb drive connected to a HUB instead of directly and nothing runs at all as there is no HUB device defined in the uSDFS library. Can define in sketch but it wants reference (or pointer?) to the usb object... Although in practice I don't think it actually uses it...

But back to main thing. Tried with two different thumb drives and I don't think either gets beyond the mount command.

The old Cruzer 1GB one
Code:
Test uSDFS
2:/
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 20005000
periodictable = 20005000
port change: 10001803
    connect
  begin reset
port change: 18001205
  port enabled
  end recovery
new_Device: 480 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 00 02 09 00 01 40 E3 05 08 06 98 32 00 01 00 01 
    VendorID = 05E3, ProductID = 0608, Version = 3298
    Class/Subclass/Protocol = 9(Hub) / 0 / 1(Single-TT)
    Number of Configurations = 1
enumeration:
enumeration:
Product: USB2.0 Hub
enumeration:
Config data length = 25
enumeration:
Configuration Descriptor:
  09 02 19 00 01 01 00 E0 32 
    NumInterfaces = 1
    ConfigurationValue = 1
  09 04 00 00 01 09 00 00 00 
    Interface = 0
    Number of endpoints = 1
    Class/Subclass/Protocol = 9(Hub) / 0 / 0
  07 05 81 03 01 00 0C 
    Endpoint = 1 IN
    Type = Interrupt
    Max Size = 1
    Polling Interval = 12
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20004460
found possible interface, altsetting=0
number of interfaces found = 1
USBHub control callback
09 29 04 E0 00 32 64 00 FF 00 00 00 00 00 00 00 
Hub ports = 4
USBHub control callback
USBHub control callback
USBHub control callback
USBHub control callback
power turned on to all ports
device addr = 1
new_Pipe
allocate_interrupt_pipe_bandwidth
  ep interval = 12
  interval = 256
 best_bandwidth = 2, at offset = 0
pipe cap1 = F0012101
HUB Callback (member)
status = 8
getstatus, port = 3
USBHub control callback
01 01 01 00 
New Port Status
  status=10101  port=3
  state=0
  Device is present: 
  Has Power
USBHub control callback
Port Status Cleared, port=3
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 8
getstatus, port = 3
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=3
  state=2
  Device is present: 
  Has Power
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 8
getstatus, port = 3
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=3
  state=3
  Device is present: 
  Has Power
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 8
getstatus, port = 3
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=3
  state=4
  Device is present: 
  Has Power
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 8
getstatus, port = 3
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=3
  state=5
  Device is present: 
  Has Power
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 8
getstatus, port = 3
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=3
  state=6
  Device is present: 
  Has Power
sending reset
send_setreset
USBHub control callback
unhandled setup, message = 40323
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 0
HUB Callback (member)
status = 8
getstatus, port = 3
USBHub control callback
03 05 10 00 
New Port Status
  status=100503  port=3
  state=7
  Device is present: 
  Enabled, speed = 480 Mbit/sec
  Has Power
USBHub control callback
unhandled setup, message = 140123
timer event (24999 us): Hello, I'm resettimer, this = 20004460, timer = 20004794
port_doing_reset = 3
PORT_RECOVERY
new_Device: 480 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 00 02 00 00 00 40 81 07 06 54 00 02 01 02 03 01 
    VendorID = 0781, ProductID = 5406, Version = 0200
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: SanDisk
enumeration:
Product: U3 Cruzer Micro
enumeration:
Serial Number: 00007080C0732B8C
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 80 2F 
    NumInterfaces = 1
    ConfigurationValue = 1
  09 04 00 00 02 08 06 50 00 
    Interface = 0
    Number of endpoints = 2
    Class/Subclass/Protocol = 8(Mass Storage) / 6(SCSI) / 80(Bulk Only)
  07 05 81 02 00 02 00 
    Endpoint = 1 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  07 05 02 02 00 02 00 
    Endpoint = 2 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
enumeration:
msController claim this=20004840
Descriptor 4 = INTERFACE
msController claim this=20004840
09 04 00 00 02 08 06 50 00 07 05 81 02 00 02 00 07 05 02 02 00 02 00 
endpointType = 2
numendpoint=2
endpointIn=81
endpointOut=2
packet size in (msController) = 512
packet size out (msController) = 512
polling intervalIn = 0
polling intervalOut = 0
new_Pipe
new_Pipe
Descriptor 5 = ENDPOINT
Descriptor 5 = ENDPOINT
control CallbackIn (msController)
00 00 00 00 00 00 00 00 
control CallbackIn (msController)
01 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static)
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static)
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static)
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static)
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static)
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static)
msController CallbackOut (static)
transfer->qtd.token = 1
...
Gets into an endless cycle of transfers... Don't see anything like the next message to do CD...
The newer drive does not work either (I also just tried reformat on windows 10 Fat system... to see if that would change it). Again does not get to the CD... But instead of endless messages it just hangs...

Code:
Test uSDFS
2:/
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 20005000
periodictable = 20005000
port change: 10001803
    connect
  begin reset
port change: 18001205
  port enabled
  end recovery
new_Device: 480 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 00 02 09 00 01 40 E3 05 08 06 98 32 00 01 00 01 
    VendorID = 05E3, ProductID = 0608, Version = 3298
    Class/Subclass/Protocol = 9(Hub) / 0 / 1(Single-TT)
    Number of Configurations = 1
enumeration:
enumeration:
Product: USB2.0 Hub
enumeration:
Config data length = 25
enumeration:
Configuration Descriptor:
  09 02 19 00 01 01 00 E0 32 
    NumInterfaces = 1
    ConfigurationValue = 1
  09 04 00 00 01 09 00 00 00 
    Interface = 0
    Number of endpoints = 1
    Class/Subclass/Protocol = 9(Hub) / 0 / 0
  07 05 81 03 01 00 0C 
    Endpoint = 1 IN
    Type = Interrupt
    Max Size = 1
    Polling Interval = 12
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20004460
found possible interface, altsetting=0
number of interfaces found = 1
USBHub control callback
09 29 04 E0 00 32 64 00 FF 00 00 00 00 00 00 00 
Hub ports = 4
USBHub control callback
USBHub control callback
USBHub control callback
USBHub control callback
power turned on to all ports
device addr = 1
new_Pipe
allocate_interrupt_pipe_bandwidth
  ep interval = 12
  interval = 256
 best_bandwidth = 2, at offset = 0
pipe cap1 = F0012101
HUB Callback (member)
status = 4
getstatus, port = 2
USBHub control callback
01 01 01 00 
New Port Status
  status=10101  port=2
  state=0
  Device is present: 
  Has Power
USBHub control callback
Port Status Cleared, port=2
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 4
getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=2
  state=2
  Device is present: 
  Has Power
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 4
getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=2
  state=3
  Device is present: 
  Has Power
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 4
getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=2
  state=4
  Device is present: 
  Has Power
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 4
getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=2
  state=5
  Device is present: 
  Has Power
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 4
getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=2
  state=6
  Device is present: 
  Has Power
sending reset
send_setreset
USBHub control callback
unhandled setup, message = 40323
timer event (19999 us): Debounce Timer, this = 20004460, timer = 20004778
ports in use bitmask = 0
HUB Callback (member)
status = 4
getstatus, port = 2
USBHub control callback
03 05 10 00 
New Port Status
  status=100503  port=2
  state=7
  Device is present: 
  Enabled, speed = 480 Mbit/sec
  Has Power
USBHub control callback
unhandled setup, message = 140123
timer event (24999 us): Hello, I'm resettimer, this = 20004460, timer = 20004794
port_doing_reset = 2
PORT_RECOVERY
new_Device: 480 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 00 02 00 00 00 40 0C 09 00 10 00 11 01 02 00 01 
    VendorID = 090C, ProductID = 1000, Version = 1100
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: SMI Corporation
enumeration:
Product: USB DISK
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 80 FA 
    NumInterfaces = 1
    ConfigurationValue = 1
  09 04 00 00 02 08 06 50 00 
    Interface = 0
    Number of endpoints = 2
    Class/Subclass/Protocol = 8(Mass Storage) / 6(SCSI) / 80(Bulk Only)
  07 05 81 02 00 02 FF 
    Endpoint = 1 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 255
  07 05 02 02 00 02 FF 
    Endpoint = 2 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 255
enumeration:
msController claim this=20004840
Descriptor 4 = INTERFACE
msController claim this=20004840
09 04 00 00 02 08 06 50 00 07 05 81 02 00 02 FF 07 05 02 02 00 02 FF 
endpointType = 2
numendpoint=2
endpointIn=81
endpointOut=2
packet size in (msController) = 512
packet size out (msController) = 512
polling intervalIn = 255
polling intervalOut = 255
new_Pipe
new_Pipe
Descriptor 5 = ENDPOINT
Descriptor 5 = ENDPOINT
control CallbackIn (msController)
00 00 00 00 00 00 00 00 
control CallbackIn (msController)
00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static)
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static)
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static)

Edit: wondering if polling interval differences? The one says 0 the other is 255
 
@KurtE, @wwatson, @wmxz

Post over in the T4 thread and pretty much got the same results as @KurtE gets for a Memory Stick, with the exception that I will get a rc=13 at the end. Now, I just tried a SanDisk Cruzer Fit CZ33 32GB USB 2.0 Low-Profile Flash Drive- SDCZ33-032G-B35 circa 2012 and it ran with uSDFS DEMO test sketch, not sure what the differences would be, unless its acting more like a SD Card. Haven't been able to get @wwatsons sketch to compile and run, not sure what I am missing:
Code:
Test uSDFS
2:/

Change drive

Create a new subdirectories.

Create a new file /Ascii/HELLO12.TXT.
Write some text lines. (Hello world!)
Close the file.

Open same file /Ascii/HELLO12.TXT.
Get the file content.
Hello world!
Second Line
Third Line
Fourth Line
Habe keine Phantasie
Close the file.

open binary file
write file
close file
Binary test done

Open root directory.
Directory listing...
   <dir>  LOST.DIR
   <dir>  Ascii
   <dir>  Binary
   <dir>  New folder
   <dir>  Quest - Man's Journey Into Space
   <dir>  In the Shadow of the Moon
   <dir>  Moon Machines
   <dir>  The History of Gemini
   <dir>  Apollo Manned Moon Missions
   <dir>  Radio Broadcasts
   <dir>  From the Earth to the Moon
   <dir>  R Package Manuals
19760993  Saturn V Flight Manual.pdf
 4053730  SaturnVLaunchVehicleGuidanceEquations[1].pdf
 1067597  Saturn Guidance Navigation and Targetting[1].pdf
   <dir>  OlMailReader
   <dir>  Arduino Boks
   <dir>  Pitch Perfect
   <dir>  System Volume Information
   <dir>  Neural Networks
   <dir>  Threading

Test completed.
 
Ok - just reformatted my Cruzer 4gb Flash drive for Fat32 and it read the memory and it read it:
Code:
Test uSDFS
2:/

Change drive

Create a new subdirectories.

Create a new file /Ascii/HELLO12.TXT.
Write some text lines. (Hello world!)
Close the file.

Open same file /Ascii/HELLO12.TXT.
Get the file content.
Hello world!
Second Line
Third Line
Fourth Line
Habe keine Phantasie
Close the file.

open binary file
write file
close file
Binary test done

Open root directory.
Directory listing...
   <dir>  System Volume Information
   <dir>  Ascii
   <dir>  Binary

Test completed.

EDIT: Both devices I tested with are USB 2 devices. Don't have any new ones to test with. I did have to reformat the cruzer to be a fat32 will try extFat next

EDIT2: The Cruzer worked with exFAT format as well

EDIT3: I put in my really old micro center 1GB drive formatted to FAT32 but this time just hangs as described by @KurtE
 
Last edited:
Back
Top