USBHost_t36 USB Mass Storage Driver Experiments

I am sorry that I have been so slow at updating the MSC library. MSC is pretty much outdated and not functional with the latest versions of Teensyduino starting with version 1.53 and up. The MSC driver is now included with Teensyduino starting with version 1.53 and up. In an effort to standardize SD which was the original file system for Teensy and Arduino and create a level of abstraction for the various mass storage devices being used with the Teensy Paul at PJRC created FS.h which allowed using SdFat and LittleFS with the SD API. Both SD and SdFat API's can be mixed. I took that and created a library that is compatible with MSC, SD and SdFat.

Here:

https://github.com/wwatson4506/UsbMscFat

And @KurtE and @mjs513 developed it further adding a lot more functionality. The latest being:

https://github.com/wwatson4506/UsbMscFat/tree/UsbMscFat-FS_DATES

This added the time an date functionality. Some of the added ability is using Fat32 and EXFat partitions, partition labels, creating and formatting both Fat32 and EXFat partitions.

Check out the examples in the UsbMscFat library. It has a lot of examples in both versions of the library including copying files between USB thumb drives and SD cards.
I noticed that I do not have an example of copying a file from SD to MSC using non-SdFat methods and using file access abstraction. TODO:)

Actually will do:)

Thanks a lot for that.
I am trying to use the UsbMscFat library. I was trying the ReadWriteUSB example. It can initialize the USB but gets stuck writing:

Initializing USB MSC drive...initialization done.
Writing to test.txt..

I am using a Sandisk USB drive with 16gb storage size. Tried formatting to both Fat32 and ExFat. Same results for both format type.
 
@sharafat - What version of Arduino and Teensyduino are you using? I just tried it here and I get this:
Code:
Initializing USB MSC drive...initialization done.
Writing to test.txt...done.
test.txt:
testing 1, 2, 3.
done.
This is with Arduino 1.8.15 and Teensyduino 1.54.
Another issue we have had is USB hubs. Did you use a USB hub? If you did then try the sketch without the hub. I have not tried a Sandisk USB thumb drive yet.
As a last resort we can turn on debug in USBHost_t36.h. This is located in ~/arduino-1.8.15/hardware/teensy/avr/lbiraries/UABHoat_t36/USBHost_t36.h at about line 62.
Just un-comment that line and rerun the sketch. You should see a huge dump of info about your particular USB device.

Something like this:
Code:
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 20005000
periodictable = 20005000

Initializing USB MSC drive...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 10 02 00 00 00 40 51 09 66 16 01 00 01 02 03 01 
    VendorID = 0951, ProductID = 1666, Version = 0001
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: Kingston
enumeration:
Product: DataTraveler 3.0
enumeration:
Serial Number: 00E04C819241F2C188BE0F0D
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 80 96 
    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:
USBHub memory usage = 960
USBHub claim_device this=20002BA0
USBHub memory usage = 960
USBHub claim_device this=20002F60
USBHub memory usage = 960
USBHub claim_device this=20003320
USBHub memory usage = 960
USBHub claim_device this=200027E0
msController claim this=20001EE0
msController claim this=20003700
Descriptor 4 = INTERFACE
msController claim this=20001EE0
09 04 00 00 02 08 06 50 00 07 05 81 02 00 02 FF 07 05 02 02 00 02 FF 
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 = 0
msController dataOut (static)31
55 53 42 43 01 00 00 00 00 00 00 00 80 00 06 1B 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 01 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 02 00 00 00 00 00 00 00 80 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 02 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 03 00 00 00 24 00 00 00 80 00 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 36
00 80 06 02 F8 00 00 00 4B 69 6E 67 73 74 6F 6E 44 61 74 61 54 72 61 76 65 6C 65 72 20 33 2E 30 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 03 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 04 00 00 00 08 00 00 00 80 00 0A 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 8
03 9A 33 F3 00 00 02 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 04 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 05 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
FA B8 00 10 8E D0 BC 00 B0 B8 00 00 8E D8 8E C0 FB BE 00 7C BF 00 06 B9 00 02 F3 A4 EA 21 06 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 05 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 06 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 08 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
EB 58 90 6D 6B 66 73 2E 66 61 74 00 02 20 20 00 02 00 00 00 00 F8 00 00 20 00 40 00 00 08 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 06 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 07 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
FA B8 00 10 8E D0 BC 00 B0 B8 00 00 8E D8 8E C0 FB BE 00 7C BF 00 06 B9 00 02 F3 A4 EA 21 06 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 07 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 08 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 08 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
EB 58 90 6D 6B 66 73 2E 66 61 74 00 02 20 20 00 02 00 00 00 00 F8 00 00 20 00 40 00 00 08 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 08 00 00 00 00 00 00 00 00 
initialization done.
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 09 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 7B 60 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
33 32 47 46 41 54 33 32 20 20 20 08 00 00 79 94 CE 52 CE 52 00 00 79 94 CE 52 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 09 00 00 00 00 00 00 00 00 
Writing to test.txt...msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0A 00 00 00 00 02 00 00 80 00 0A 28 00 00 0C 7A 20 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 33 2E 0D 0A CE 52 00 00 79 94 CE 52 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0A 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0B 00 00 00 00 02 00 00 00 00 0A 2A 00 00 0C 7A 20 00 00 01 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)512
74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 33 2E 0D 0A 74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0B 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0C 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 7B 60 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
33 32 47 46 41 54 33 32 20 20 20 08 00 00 79 94 CE 52 CE 52 00 00 79 94 CE 52 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0C 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0D 00 00 00 00 02 00 00 00 00 0A 2A 00 00 00 7B 60 00 00 01 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)512
33 32 47 46 41 54 33 32 20 20 20 08 00 00 79 94 CE 52 CE 52 00 00 79 94 CE 52 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0D 00 00 00 00 00 00 00 00 
done.
test.txt:
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0E 00 00 00 00 02 00 00 80 00 0A 28 00 00 0C 7A 20 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 33 2E 0D 0A 74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0E 00 00 00 00 00 00 00 00 
testing 1, 2, 3.
testing 1, 2, 3.

Your results will probably be different. But may give a clue to what is going wrong.
 
Thanks. I was using an older Arduino version. Currently updates to 1.8.15 and 1.54. However, still stuck. Getting the following message with verbose:


Code:
sizeof Device = 36
sizeof Pipe = 96
sizeof Transfer = 64
power up USBHS PHY
 reset waited 4
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 1FFF4000
periodictable = 1FFF4000

Initializing USB MSC drive...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 10 02 00 00 00 40 81 07 99 55 00 01 01 02 03 01 
    VendorID = 0781, ProductID = 5599, Version = 0100
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: SanDisk
enumeration:
Product: Cruzer Dial
enumeration:
Serial Number: 4C530000190309122541
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 80 70 
    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=1FFF2020
msController claim this=1FFF2920
Descriptor 4 = INTERFACE
msController claim this=1FFF2020
09 04 00 00 02 08 06 50 00 07 05 81 02 00 02 00 07 05 02 02 00 02 00 
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)
00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 01 00 00 00 00 00 00 00 80 00 06 1B 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 01 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 02 00 00 00 00 00 00 00 80 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 02 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 03 00 00 00 24 00 00 00 80 00 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 36
00 80 06 12 43 00 00 00 53 61 6E 44 69 73 6B 00 43 72 75 7A 65 72 20 44 69 61 6C 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 03 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 04 00 00 00 08 00 00 00 80 00 0A 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 8
01 D2 FF FF 00 00 02 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 04 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 05 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 05 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 06 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 00 20 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
EB 58 90 4D 53 44 4F 53 35 2E 30 00 02 10 60 0B 02 00 00 00 00 F8 00 00 3F 00 FF 00 20 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 06 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 07 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 07 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 08 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 00 20 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
EB 58 90 4D 53 44 4F 53 35 2E 30 00 02 10 60 0B 02 00 00 00 00 F8 00 00 3F 00 FF 00 20 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 08 00 00 00 00 00 00 00 00 
initialization done.
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 09 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 80 20 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
42 20 00 49 00 6E 00 66 00 6F 00 0F 00 72 72 00 6D 00 61 00 74 00 69 00 6F 00 00 00 6E 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 09 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0A 00 00 00 00 02 00 00 00 00 0A 2A 00 00 00 80 20 00 00 01 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)512
42 20 00 49 00 6E 00 66 00 6F 00 0F 00 72 72 00 6D 00 61 00 74 00 69 00 6F 00 00 00 6E 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 64
msController dataIn (static): 0
ERROR Followup
CSW Tag Error: 253
CSW Tag Error: 253
Writing to test.txt...msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 64
msController dataOut (static)0
ERROR Followup
 
@sharafat - I think I might know what is happening here. At this point a guess. I had an 8GB Sandisk Cruzer and have a 16GB PNY thumb stick that magically write protected them selves. What I am seeing is about the time the sketch opens the file for a write operation it fails with code 253 which is a tag error. In other words every read and write to the drive is followed by a status read which gives info about the last OP. Success or failure. In this case a tag error #253 which means the status read did not return the same tag number that was sent with the last command. Several things can cause this and when the error occurs we need to read the sense codes and decode them to find out why the error happened.

A simple way to test this is to use your PC to copy a file to the thumb drive and see if it completes successfully. That will let me know if the integrity of the drive is good. Otherwise it might be magically write protected:)

If it is working properly with the PC then I need to write a sketch you can use to check the sense codes. Reading an decoding sense codes is available in UsbMscFat. It will probably be this weekend before I can pursue the further. If you have another thumb drive or SD card reader try that out as well. This is exactly what I was looking for testing MSC.

Edit: SSD's as well.
 
@defragster - All that is really needed is TD 1.54 and this version of UsbMscFat:

https://github.com/wwatson4506/UsbMscFat/tree/UsbMscFat-FS_DATES

This is the most up to date version that was worked on by @Kurte and @mjs513.

Plus I have a PR for timeouts in msc.h in the USBHOST_t36 library. They need to be longer timeouts for USB SD card readers and maybe other slower USB drives.

I want to be able to test retrieving sense codes upon failures of access to MSC drives. I have UsbMscFat setup to do that and decode the failures. I have not played with it for a while and this weekend with @sharafat's issue I am going to setup a sketch for testing this specifically. The framework is there but not utilized yet. As I stated above I had a PNY thumb stick that somehow write protected it's self and was able to decode that sense code.

EDIT: Hopefully this will isolate hardware failure from software problems.
 
Thanks - I got that - but no joy? Will double check github delivered the right branch.

I see MTP experimental in the boards.txt - but not MTP_Serial using the edited usb_desc.h? Any other changes?

I have not been involved with MTP myself so I cannot answer that:(
 
Thanks. Nothing shows on PC?

64GB AData in on startup - removed then 128GB AData Flash on USB Host:
USB2 PLL running
reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 20005000
periodictable = 20005000

Initializing USB MSC drive...initialization failed!
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 10 02 00 00 00 40 5F 12 8A DB 75 10 01 02 03 01
VendorID = 125F, ProductID = DB8A, Version = 1075
Class/Subclass/Protocol = 0 / 0 / 0
Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: ADATA
enumeration:
Product: ADATA USB Flash Drive
enumeration:
Serial Number: 1510710162080035
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
09 02 20 00 01 01 00 80 64
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 02 02 00 02 00
Endpoint = 2 OUT
Type = Bulk
Max Size = 512
Polling Interval = 0
07 05 81 02 00 02 00
Endpoint = 1 IN
Type = Bulk
Max Size = 512
Polling Interval = 0
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20002BA0
USBHub memory usage = 960
USBHub claim_device this=20002F60
USBHub memory usage = 960
USBHub claim_device this=20003320
USBHub memory usage = 960
USBHub claim_device this=200027E0
msController claim this=20001EE0
msController claim this=20003700
Descriptor 4 = INTERFACE
msController claim this=20001EE0
09 04 00 00 02 08 06 50 00 07 05 02 02 00 02 00 07 05 81 02 00 02 00
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
port change: 1C00100A
disconnect
disconnect_Device:
USBDriver (available_drivers) list: 20002BA0 -> 20002F60 -> 20003320 -> 200027E0 -> 20003700
USBDriver (dev->drivers) list: 20001EE0
disconnect driver 20001EE0
Device Disconnected...
USBDriver (available_drivers) list: 20001EE0 -> 20002BA0 -> 20002F60 -> 20003320 -> 200027E0 -> 20003700
delete_Pipe 20003940
remove QH from async schedule
Free transfers
Free transfers attached to QH
* 536886048
* Delete Pipe completed
delete_Pipe 200038E0
remove QH from async schedule
Free transfers
Free transfers attached to QH
* 536892544
* Delete Pipe completed
delete_Pipe 20005400
shut down async schedule
Free transfers
Free transfers attached to QH
* 536892736
* Delete Pipe completed
removed Device_t from devlist
disable
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 10 02 00 00 00 40 5F 12 2B 31 00 11 01 02 03 01
VendorID = 125F, ProductID = 312B, Version = 1100
Class/Subclass/Protocol = 0 / 0 / 0
Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: ADATA
enumeration:
Product: ADATA USB Flash Drive
enumeration:
Serial Number: 2032803290010002
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
09 02 20 00 01 01 00 80 96
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 01 02 00 02 00
Endpoint = 1 OUT
Type = Bulk
Max Size = 512
Polling Interval = 0
07 05 82 02 00 02 00
Endpoint = 2 IN
Type = Bulk
Max Size = 512
Polling Interval = 0
enumeration:
msController claim this=20001EE0
USBHub memory usage = 960
USBHub claim_device this=20002BA0
USBHub memory usage = 960
USBHub claim_device this=20002F60
USBHub memory usage = 960
USBHub claim_device this=20003320
USBHub memory usage = 960
USBHub claim_device this=200027E0
msController claim this=20003700
Descriptor 4 = INTERFACE
msController claim this=20001EE0
09 04 00 00 02 08 06 50 00 07 05 01 02 00 02 00 07 05 82 02 00 02 00
numendpoint=2
endpointIn=82
endpointOut=1
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
 
@defragster - In your case the initallization failed at the software level. UsbFat could not find a formatted volume to mount. MSC is finding and initializing the drive at the hardware level ok.

In ReadWriteUSB.ino you can insert this:

Code:
  // Check Sense Codes
  MSC.mscfs.printMscError(&Serial);

To line #53.
This will return any hardware errors and sense codes if the problem is at the hardware level, otherwise it will suggest that the drive might not be formatted properly.

In my case with the PNY 64Gig drive I get this output:
Code:
Initializing USB MSC drive...initialization failed!
Check USB drive format.

Next in the MSCFormatter.ino sketch we can add this:
Code:
  // Check Sense Codes
  msc[drive_index].printMscError(&Serial);
To line #217.

After it it has loaded and shows the prompt:
Code:
done...
Enter command:

You can enter this on the command line:
Code:
R 0 1

This will try to format the USB drive to FAT32.
On my PNY drive I had this output:
Code:
Cards up to 2 GiB (GiB = 2^30 bytes) will be formated FAT16.
Cards larger than 2 GiB and up to 32 GiB will be formatted
FAT32. Cards larger than 32 GiB will be formatted exFAT.

Commands:
  f <partition> [16|32|ex] - to format
  v <partition> <label> - to change volume label
  d <partition> - to dump first sectors
  p <partition> - print Partition info
  l <partition> - to do ls command on that partition
  c -  toggle on/off format show changed data
  *** Danger Zone ***
  N <USB Device> start_addr <length> - Add a new partition to a disk
  R <USB Device> - Setup initial MBR and format disk *sledgehammer*
  X <partition> [d <usb device> - Delete a partition
Waiting up to 5 seconds for a USB drive 
Initialize USB drive...
[COLOR="#FF0000"]Check USB drive format.[/COLOR]
initialization drive 0 failed.
Read Capacity: status: 0 Blocks: 120922111 block Size: 512
From object: Blocks: 120922111 Size: 512

Initialize SDIO SD card...initialization failed.


Initialize SPI SD card...initialization failed.


***** Partition List *****
done...
Enter command:

 **** Try Sledgehammer on USB Drive 0 ****
sectorCount = 120922111, FatType: 10
TODO createPartition on ExFat

PFsFatFormatter::addPartitionToMbr: 2048 0 120922111
00 20 21 00 83 FE FF FF 00 08 00 00 00 18 35 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 :. !...........5.................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 :................................
    p 3: 0 0 0:  - empty slot
    p 2: 0 0 0:  - empty slot
    p 1: 0 0 0:  - empty slot
    p 0: 131 2048 120920064: - exited copy down
    Adjust sector count: 120920063 = 120922111 - 2048 CAP: 59043
    Return partion num: 1
After Add Partition
00 20 21 00 83 FE FF FF 00 08 00 00 00 18 35 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 :. !...........5.................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 :................................
    m_relativeSectors: 2048
    m_totalSectors: 120922111

VS: 27
sectorsPerClusterShift: 8,
 sectorsPerCluster: 256,
 fatLength 16384
fatOffset: 16384,
 partitionOffset: 2048
clusterHeapOffset: 32768,
 clusterCount: 472095,
 volumeLength 120922111
cluster 2 bitmap: 34816
Up case table: 35072
    m_relativeSectors:2048
    m_totalSectors:120922111
Format failed
[COLOR="#FF0000"]USB drive error: 0x1,0x0 --> Type: DATA_PROTECT Cause: WRITE PROTECTED[/COLOR]
Press any key to run again

The lines in red are output from printMSCerror() in UsbFat.h.

Very curious to see your results:)

@sharafat - Your problem is at the hardware level causing a tag error. Possibly A timing issue with MSC and your thumb drive. Still working on that.
 
Last edited:
@sharafat - An update. I now know why your particular device failed writing to it:
Code:
msController CallbackIn (static)
[COLOR="#FF0000"]transfer->qtd.token = 64[/COLOR]
msController dataIn (static): 0
ERROR Followup
CSW Tag Error: 253
CSW Tag Error: 253
Writing to test.txt...msReadBlocks()
msController CallbackOut (static)
[COLOR="#FF0000"]transfer->qtd.token = 64[/COLOR]
msController dataOut (static)0
ERROR Followup

The qtd.token = 64 indicates that the host device (your thumb drive) halted the pipe/endpoint. qtd.token bit 6 (64) indicates this error:

Code:
Halted. Set to a 1 by the Host Controller during status updates to indicate that
a serious error has occurred at the device/endpoint addressed by this qTD.
This can be caused by babble, the error counter counting down to zero, or
reception of the STALL handshake from the device during a transaction. Any
time that a transaction results in the Halted bit being set to a one, the Active bit
is also set to 0
Active bit is bit 7.

At this point I am not sure how to recover from this type of error. Possibly by resending the request.
If you have another USB thumb drive you might want to try that and see if the problem persists.
 
@defragster - In your case the initallization failed at the software level. UsbFat could not find a formatted volume to mount. MSC is finding and initializing the drive at the hardware level ok.

In ReadWriteUSB.ino you can insert this:

Code:
  // Check Sense Codes
  MSC.mscfs.printMscError(&Serial);

To line #53.
This will return any hardware errors and sense codes if the problem is at the hardware level, otherwise it will suggest that the drive might not be formatted properly.
...

DOH! - Both those flash drives were made MultiPartition in last testing.
Code:
initialization failed!
Check USB drive format.

Removed dual partitions and formated all 64GB Flash as ExFat.

Only made one edit in ReadWriteUSB.ino.
SerMon shows this - no device showing 'Teensy' in Windows?:
Code:
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2000B000
periodictable = 2000B000

Initializing USB MSC drive...initialization failed!
No USB drive detected, plugged in?
USB drive error: 0x28,0x0 --> Type: NO_SENSE Cause: NO ADDITIONAL SENSE INFORMATION
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 10 02 00 00 00 40 5F 12 8A DB 75 10 01 02 03 01 
    VendorID = 125F, ProductID = DB8A, Version = 1075
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: ADATA
enumeration:
Product: ADATA USB Flash Drive
enumeration:
Serial Number: 1510710162080035
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 80 64 
    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 02 02 00 02 00 
    Endpoint = 2 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  07 05 81 02 00 02 00 
    Endpoint = 1 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20009440
USBHub memory usage = 960
USBHub claim_device this=20009800
USBHub memory usage = 960
USBHub claim_device this=20009BC0
USBHub memory usage = 960
USBHub claim_device this=20009080
msController claim this=20008780
msController claim this=20009FA0
Descriptor 4 = INTERFACE
msController claim this=20008780
09 04 00 00 02 08 06 50 00 07 05 02 02 00 02 00 07 05 81 02 00 02 00 
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
 
DOH! - Both those flash drives were made MultiPartition in last testing.
Code:
initialization failed!
Check USB drive format.

Removed dual partitions and formated all 64GB Flash as ExFat.

Only made one edit in ReadWriteUSB.ino.
SerMon shows this - no device showing 'Teensy' in Windows?:
Code:
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2000B000
periodictable = 2000B000

Initializing USB MSC drive...initialization failed!
No USB drive detected, plugged in?
USB drive error: 0x28,0x0 --> Type: NO_SENSE Cause: NO ADDITIONAL SENSE INFORMATION
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 10 02 00 00 00 40 5F 12 8A DB 75 10 01 02 03 01 
    VendorID = 125F, ProductID = DB8A, Version = 1075
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: ADATA
enumeration:
Product: ADATA USB Flash Drive
enumeration:
Serial Number: 1510710162080035
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 80 64 
    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 02 02 00 02 00 
    Endpoint = 2 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  07 05 81 02 00 02 00 
    Endpoint = 1 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20009440
USBHub memory usage = 960
USBHub claim_device this=20009800
USBHub memory usage = 960
USBHub claim_device this=20009BC0
USBHub memory usage = 960
USBHub claim_device this=20009080
msController claim this=20008780
msController claim this=20009FA0
Descriptor 4 = INTERFACE
msController claim this=20008780
09 04 00 00 02 08 06 50 00 07 05 02 02 00 02 00 07 05 81 02 00 02 00 
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

In USBHost_t36/utility/msc.h there are two timeout settings to check. These start at line #73.

If they look like this:
Code:
// These two defines are timeouts for detecting a connected drive
// and waiting for it to be operational.
#define MEDIA_READY_TIMEOUT	3000
#define MSC_CONNECT_TIMEOUT       3000

Then increase them to this:
Code:
// These two defines are timeouts for detecting a connected drive
// and waiting for it to be operational.
#define MEDIA_READY_TIMEOUT	5000
#define MSC_CONNECT_TIMEOUT       5000
And try it.

I have a PR in for USBHost_t36 about these timeouts being to small for some USB drives. There have been a few issues with these timeouts. I have seen some drives take up to 30 seconds to become ready. That is what code 0x28 means. (MS_NO_MEDIA_ERR).
It seems strange that in post #561 that code 0x28 did not happen and after formatting to EXFAT it did. Anyway, try changing the timeouts.
 
In USBHost_t36/utility/msc.h there are two timeout settings to check. These start at line #73.

If they look like this:
Code:
// These two defines are timeouts for detecting a connected drive
// and waiting for it to be operational.
#define MEDIA_READY_TIMEOUT	3000
#define MSC_CONNECT_TIMEOUT       3000

Then increase them to this:
Code:
// These two defines are timeouts for detecting a connected drive
// and waiting for it to be operational.
#define MEDIA_READY_TIMEOUT	5000
#define MSC_CONNECT_TIMEOUT       5000
And try it.

I have a PR in for USBHost_t36 about these timeouts being to small for some USB drives. There have been a few issues with these timeouts. I have seen some drives take up to 30 seconds to become ready. That is what code 0x28 means. (MS_NO_MEDIA_ERR).
It seems strange that in post #561 that code 0x28 did not happen and after formatting to EXFAT it did. Anyway, try changing the timeouts.

again ... doh ... there was an April usbHost_t36 in my libraries.
Removed and went to TD1.54 in libs and edit what was 1000 and 4000 to 5000 for both:
Code:
Using library UsbMscFat at version 1.0.0 in folder: T:\tCode\libraries\UsbMscFat 
Using library USBHost_t36 at version 0.1 in folder: T:\arduino-1.8.15\hardware\teensy\avr\libraries\USBHost_t36 
Using library SdFat at version 2.0.5-beta.1 in folder: T:\arduino-1.8.15\hardware\teensy\avr\libraries\SdFat 
Using library SPI at version 1.0 in folder: T:\arduino-1.8.15\hardware\teensy\avr\libraries\SPI

Recopied the github UsbMscFat and got this with UsbHost debug on:
Code:
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2000B000
periodictable = 2000B000

[B]Initializing USB MSC drive...[/B]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 10 02 00 00 00 40 5F 12 8A DB 75 10 01 02 03 01 
    VendorID = 125F, ProductID = DB8A, Version = 1075
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: ADATA
enumeration:
Product: ADATA USB Flash Drive
enumeration:
Serial Number: 1510710162080035
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 80 64 
    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 02 02 00 02 00 
    Endpoint = 2 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  07 05 81 02 00 02 00 
    Endpoint = 1 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20009440
USBHub memory usage = 960
USBHub claim_device this=20009800
USBHub memory usage = 960
USBHub claim_device this=20009BC0
USBHub memory usage = 960
USBHub claim_device this=20009080
msController claim this=20008780
msController claim this=20009FA0
Descriptor 4 = INTERFACE
msController claim this=20008780
09 04 00 00 02 08 06 50 00 07 05 02 02 00 02 00 07 05 81 02 00 02 00 
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)
00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 01 00 00 00 00 00 00 00 80 00 06 1B 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 01 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 02 00 00 00 00 00 00 00 80 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 02 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 03 00 00 00 24 00 00 00 80 00 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 36
00 80 06 02 5B 00 00 00 41 44 41 54 41 20 20 20 55 53 42 20 46 6C 61 73 68 20 44 72 69 76 65 20 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 03 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 04 00 00 00 08 00 00 00 80 00 0A 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 8
07 39 FF FF 00 00 02 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 04 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 05 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
33 C0 8E D0 BC 00 7C 8E C0 8E D8 BE 00 7C BF 00 06 B9 00 02 FC F3 A4 50 68 1C 06 CB FB B9 04 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 05 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 06 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 08 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
EB 76 90 45 58 46 41 54 20 20 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 06 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 07 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 20 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
FF FF FF FF FF FF FF FF 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 07 00 00 00 00 00 00 00 00 
[B]initialization done.[/B]
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 08 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 22 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
83 04 41 00 44 00 36 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 08 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 09 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 22 01 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
C1 00 4C 00 49 00 43 00 45 00 4E 00 53 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 09 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 0A 00 00 00 00 02 00 00 00 00 0A 2A 00 00 00 22 01 00 00 01 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)512
C1 00 4C 00 49 00 43 00 45 00 4E 00 53 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0A 00 00 00 00 00 00 00 00 
Writing to test.txt...msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 0B 00 00 00 00 02 00 00 00 00 0A 2A 00 00 00 67 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)512
74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 33 2E 0D 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0B 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 0C 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 22 01 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
C1 00 4C 00 49 00 43 00 45 00 4E 00 53 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0C 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 0D 00 00 00 00 02 00 00 00 00 0A 2A 00 00 00 20 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)512
FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0D 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 0E 00 00 00 00 02 00 00 00 00 0A 2A 00 00 00 22 01 00 00 01 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)512
C1 00 4C 00 49 00 43 00 45 00 4E 00 53 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0E 00 00 00 00 00 00 00 00 
done.
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 0F 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 22 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
83 04 41 00 44 00 36 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0F 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 10 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 22 01 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
C1 00 4C 00 49 00 43 00 45 00 4E 00 53 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 10 00 00 00 00 00 00 00 00 
test.txt:
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 1
msController dataOut (static)31
55 53 42 43 11 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 67 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 33 2E 0D 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 11 00 00 00 00 00 00 00 00 
testing 1, 2, 3.

Then I turned of the UsbHost DEBUG and got this before turning it back on and failing again?
Code:
[B][COLOR="#FF0000"]Initializing USB MSC drive...initialization failed![/COLOR][/B]
No USB drive detected, plugged in?
USB drive error: 0x28,0x0 --> Type: NO_SENSE Cause: NO ADDITIONAL SENSE INFORMATION

Initializing USB MSC drive...initialization failed!
No USB drive detected, plugged in?
USB drive error: 0x28,0x0 --> Type: NO_SENSE Cause: NO ADDITIONAL SENSE INFORMATION
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2000B000
periodictable = 2000B000

[B][COLOR="#FF0000"]Initializing USB MSC drive...initialization failed!
No USB drive detected, plugged in?[/COLOR][/B]
USB drive error: 0x28,0x0 --> Type: NO_SENSE Cause: NO ADDITIONAL SENSE INFORMATION
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 10 02 00 00 00 40 5F 12 8A DB 75 10 01 02 03 01 
    VendorID = 125F, ProductID = DB8A, Version = 1075
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: ADATA
enumeration:
Product: ADATA USB Flash Drive
enumeration:
Serial Number: 1510710162080035
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 80 64 
    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 02 02 00 02 00 
    Endpoint = 2 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  07 05 81 02 00 02 00 
    Endpoint = 1 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20009440
USBHub memory usage = 960
USBHub claim_device this=20009800
USBHub memory usage = 960
USBHub claim_device this=20009BC0
USBHub memory usage = 960
USBHub claim_device this=20009080
msController claim this=20008780
msController claim this=20009FA0
Descriptor 4 = INTERFACE
msController claim this=20008780
09 04 00 00 02 08 06 50 00 07 05 02 02 00 02 00 07 05 81 02 00 02 00 
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

Did a CLEAN build with debug on and it worked again - then DEBUG off and clean build fails ...
 
Looks like we are getting somewhere now:)

I appreciate you testing this. As a radical move try increasing the timeouts to 10000 or even 30000. After that try powering down and then powering up without uploading the sketch. I have seen this as a problem before. Not sure why.

Have to sign off for tonight. Gotta feed the family:)
 
Looks like we are getting somewhere now:)

I appreciate you testing this. As a radical move try increasing the timeouts to 10000 or even 30000. After that try powering down and then powering up without uploading the sketch. I have seen this as a problem before. Not sure why.

Have to sign off for tonight. Gotta feed the family:)

Plugged 64GB flash into powered Hub with 30K and 30K - power off and on to Button bootloader:
Code:
Initializing USB MSC drive...initialization done.
Writing to test.txt...done.
test.txt:
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.

Edited setup to show current millis() and did upload ( forgot to remove 'ln' from print ):
Code:
Initializing USB MSC drive...13622
 ms >> initialization done.
Writing to test.txt...done.
test.txt:
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
 
Again with Flash on Hub - then flash moved to direct connect:
Code:
Initializing USB MSC drive...14015 ms >> initialization done.  [B]// ON HUB[/B]
Writing to test.txt...done.
test.txt:
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.

Initializing USB MSC drive...5477 ms >> initialization done.  [B]// Direct connect - No HUB[/B]
Writing to test.txt...done.
test.txt:
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.

Immediate fail on 128GB Flash with two partitions:
Code:
Initializing USB MSC drive...initialization failed!
Check USB drive format.
 
Awesome:) It's a sketchy world with these USB devices. Something that @Paul talked about was these USB devices do not always work the same. Possibly need to to have a data base of device PID's and VID's with known parameters that can be used for initializing, reading and writing to that particular device. But that is a major undertaking and probably not something that is going to happen any time soon:)
 
Last edited:
Post #569 - ReadWrite.ino does not work with with multiple partitions. Only SdFat and USbFat at this time:( FS.h is not setup for that. I am working on that right now but am not finished yet:)
 
Post #569 - ReadWrite.ino does not work with with multiple partitions. Only SdFat and USbFat at this time:( FS.h is not setup for that. I am working on that right now but am not finished yet:)

Good it works - odd it takes long time. And longer with Hub - hoped that might have the drive ready sooner.

Dual Partitions .... Not a problem - just leftover form last testing with 'others' months back.

Here's the start of setup() to the millis() print:
Code:
void setup()
{

 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect.
  }

  // Start USBHost_t36, HUB(s) and USB devices.
  myusb.begin();

  Serial.print("\nInitializing USB MSC drive...");

  if (!MSC.begin(&msDrive1)) {
    Serial.println("initialization failed!");
    // Check Sense Codes
    MSC.mscfs.printMscError(&Serial);
    return;
  }
  Serial.print( millis() );
  Serial.println(" ms >> initialization done.");
  
  // open the file. 
  myFile = MSC.open("test.txt", FILE_WRITE);

...
 
@wwatson: I have a powered hub with internal HDD.

Plugged it in and restarted - and a couple resets all working.
> Also have the same 64GB Flash plugged into the HUB it is found ...
In the spew you'll find the same :: 1951 ms >> initialization done.
Code:
Initializing USB MSC drive...1853 ms >> initialization done.
Writing to test.txt...done.
test.txt:
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.

For added info turned on UsbHost DEBUG - recompiled and it worked again!
Code:
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2000B000
periodictable = 2000B000

[B]Initializing USB MSC drive.[/B]..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 10 02 09 00 01 40 09 21 13 28 01 90 01 02 00 01 
    VendorID = 2109, ProductID = 2813, Version = 9001
    Class/Subclass/Protocol = 9(Hub) / 0 / 1(Single-TT)
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: VIA Labs, Inc.         
enumeration:
Product: USB2.0 Hub             
enumeration:
Config data length = 25
enumeration:
Configuration Descriptor:
  09 02 19 00 01 01 00 E0 00 
    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=20009440
found possible interface, altsetting=0
number of interfaces found = 1
USBHub control callback
09 29 04 E9 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 = 6
getstatus, port = 1
deferred getstatus, port = 2
USBHub control callback
01 01 01 00 
New Port Status
  status=10101  port=1
  state=0
  Device is present: 
  Has Power
USBHub control callback
Port Status Cleared, port=1
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 (19998 us): Debounce Timer, this = 20009440, timer = 20009758
ports in use bitmask = 6
getstatus, port = 1
deferred getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=1
  state=2
  Device is present: 
  Has Power
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 (19998 us): Debounce Timer, this = 20009440, timer = 20009758
ports in use bitmask = 6
getstatus, port = 1
deferred getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=1
  state=3
  Device is present: 
  Has Power
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 (19998 us): Debounce Timer, this = 20009440, timer = 20009758
ports in use bitmask = 6
getstatus, port = 1
deferred getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=1
  state=4
  Device is present: 
  Has Power
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 (19998 us): Debounce Timer, this = 20009440, timer = 20009758
ports in use bitmask = 6
getstatus, port = 1
deferred getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=1
  state=5
  Device is present: 
  Has Power
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 (19998 us): Debounce Timer, this = 20009440, timer = 20009758
ports in use bitmask = 6
getstatus, port = 1
deferred getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=1
  state=6
  Device is present: 
  Has Power
sending reset
send_setreset
USBHub control callback
unhandled setup, message = 40323
getstatus, port = 2
USBHub control callback
01 01 00 00 
New Port Status
  status=101  port=2
  state=6
  Device is present: 
  Has Power
timer event (19998 us): Debounce Timer, this = 20009440, timer = 20009758
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
HUB Callback (member)
status = 2
getstatus, port = 1
USBHub control callback
03 05 10 00 
New Port Status
  status=100503  port=1
  state=7
  Device is present: 
  Enabled, speed = 480 Mbit/sec
  Has Power
USBHub control callback
unhandled setup, message = 140123
timer event (19998 us): Debounce Timer, this = 20009440, timer = 20009758
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
timer event (24998 us): Hello, I'm resettimer, this = 20009440, timer = 20009778
port_doing_reset = 1
PORT_RECOVERY
new_Device: 480 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 10 02 00 00 00 40 80 00 01 A0 03 02 01 02 03 01 
    VendorID = 0080, ProductID = A001, Version = 0203
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
[B]Manufacturer: TOSHIBA
enumeration:
Product: External USB 3.0[/B]
enumeration:
Serial Number: 201503310007F
enumeration:
Config data length = 85
enumeration:
Configuration Descriptor:
  09 02 55 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 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
  09 04 00 01 04 08 06 62 00 
    Interface = 0
    Number of endpoints = 4
    Class/Subclass/Protocol = 8(Mass Storage) / 6(SCSI) / 98(UAS)
  07 05 01 02 00 02 00 
    Endpoint = 1 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  04 24 01 00 
  07 05 82 02 00 02 00 
    Endpoint = 2 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  04 24 02 00 
  07 05 83 02 00 02 00 
    Endpoint = 3 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  04 24 03 00 
  07 05 04 02 00 02 00 
    Endpoint = 4 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  04 24 04 00 
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20009800
USBHub memory usage = 960
USBHub claim_device this=20009BC0
USBHub memory usage = 960
USBHub claim_device this=20009080
msController claim this=20008780
msController claim this=20009FA0
Descriptor 4 = INTERFACE
msController claim this=20008780
09 04 00 00 02 08 06 50 00 07 05 81 02 00 02 00 07 05 02 02 00 02 00 09 04 00 01 04 08 06 62 00 07 05 01 02 00 02 00 04 24 01 00 07 05 82 02 00 02 00 04 24 02 00 07 05 83 02 00 02 00 04 24 03 00 07 05 04 02 00 02 00 04 24 04 00 
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
Descriptor 4 = INTERFACE
msController claim this=20009FA0
09 04 00 01 04 08 06 62 00 07 05 01 02 00 02 00 04 24 01 00 07 05 82 02 00 02 00 04 24 02 00 07 05 83 02 00 02 00 04 24 03 00 07 05 04 02 00 02 00 04 24 04 00 
Descriptor 5 = ENDPOINT
Descriptor 36 =  ???
Descriptor 5 = ENDPOINT
Descriptor 36 =  ???
Descriptor 5 = ENDPOINT
Descriptor 36 =  ???
Descriptor 5 = ENDPOINT
Descriptor 36 =  ???
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 = 0
msController dataOut (static)31
55 53 42 43 01 00 00 00 00 00 00 00 80 00 06 1B 01 00 00 01 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 01 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 02 00 00 00 00 00 00 00 80 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 02 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 03 00 00 00 24 00 00 00 80 00 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 36
00 00 06 12 5B 00 00 00 54 4F 20 45 78 74 65 72 6E 61 6C 20 55 53 42 20 33 2E 30 20 20 20 20 20 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 03 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 04 00 00 00 08 00 00 00 80 00 0A 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 8
0D F9 4B AF 00 00 02 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 04 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 05 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 
timer event (19998 us): Debounce Timer, this = 20009440, timer = 20009758
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 (19998 us): Debounce Timer, this = 20009440, timer = 20009758
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 (24998 us): Hello, I'm resettimer, this = 20009440, timer = 20009778
port_doing_reset = 2
PORT_RECOVERY
new_Device: 480 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
  12 01 10 02 00 00 00 40 5F 12 8A DB 75 10 01 02 03 01 
    VendorID = 125F, ProductID = DB8A, Version = 1075
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
[B]Manufacturer: ADATA
enumeration:
Product: ADATA USB Flash Drive[/B]
enumeration:
Serial Number: 1510710162080035
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 80 64 
    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 02 02 00 02 00 
    Endpoint = 2 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  07 05 81 02 00 02 00 
    Endpoint = 1 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20009800
USBHub memory usage = 960
USBHub claim_device this=20009BC0
USBHub memory usage = 960
USBHub claim_device this=20009080
msController claim this=20009FA0
Descriptor 4 = INTERFACE
msController claim this=20009FA0
09 04 00 00 02 08 06 50 00 07 05 02 02 00 02 00 07 05 81 02 00 02 00 
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
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
33 C0 8E D0 BC 00 7C 8E C0 8E D8 BE 00 7C BF 00 06 B9 00 02 FC F3 A4 50 68 1C 06 CB FB B9 04 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 05 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 06 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 08 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
EB 76 90 45 58 46 41 54 20 20 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 06 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 07 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 30 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 07 00 00 00 00 00 00 00 00 
[B][COLOR="#FF0000"]1951 ms >> initialization done.[/COLOR][/B]
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 08 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 32 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
83 09 31 00 32 00 30 00 47 00 42 00 5F 00 45 00 78 00 74 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 08 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 09 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 32 01 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
85 02 64 70 20 00 00 00 86 88 37 50 88 88 37 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 09 00 00 00 00 00 00 00 00 
Writing to test.txt...msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0A 00 00 00 00 02 00 00 80 00 0A 28 00 00 06 12 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 33 2E 0D 0A 74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0A 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0B 00 00 00 00 02 00 00 00 00 0A 2A 00 00 06 12 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)512
74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 33 2E 0D 0A 74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0B 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0C 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 32 01 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
85 02 64 70 20 00 00 00 86 88 37 50 88 88 37 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0C 00 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0D 00 00 00 00 02 00 00 00 00 0A 2A 00 00 00 32 01 00 00 01 00 00 00 00 00 00 00 
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)512
85 02 64 70 20 00 00 00 86 88 37 50 88 88 37 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0D 00 00 00 00 00 00 00 00 
done.
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0E 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 32 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
83 09 31 00 32 00 30 00 47 00 42 00 5F 00 45 00 78 00 74 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0E 00 00 00 00 00 00 00 00 
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0F 00 00 00 00 02 00 00 80 00 0A 28 00 00 00 32 01 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
85 02 64 70 20 00 00 00 86 88 37 50 88 88 37 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 0F 00 00 00 00 00 00 00 00 
test.txt:
msReadBlocks()
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 10 00 00 00 00 02 00 00 80 00 0A 28 00 00 06 12 00 00 00 01 00 00 00 00 00 00 00 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 512
74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 33 2E 0D 0A 74 65 73 74 69 6E 67 20 31 2C 20 32 2C 20 
msController CallbackIn (static)
transfer->qtd.token = 0
msController dataIn (static): 13
55 53 42 53 10 00 00 00 00 00 00 00 00 
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.

And running : ...\libraries\UsbMscFat\examples\SdInfoUSB\SdInfoUSB.ino
Code:
MSC Fat version: 1.0.0

type any character to start
init time: 2703 ms

Drive type: USB Drive.
msc1 Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
1,0X0,0X20,0X21,0X0,0X7,0XFE,0XFF,0XFF,2048,234436608
2,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
3,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
4,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0

Scanning FAT, please wait.

Volume is exFAT
sectorsPerCluster: 256
clusterCount:      915728
freeClusterCount:  914221
fatStartSector:    4096
dataStartSector:   12288

type any character to start
 
Using the T_4.1 USB Host to External HDD enclosure with Powered Hub - and three USB 3 ports, where one has the 64GB Flash from above:

Did a DUPE of code for msDrive1 to msDrive2
>> Using file test2.txt, and put ' 2 ' then ' TWO ::' in the test write
Both drives are online and usable - in GOOD TIME too!:
Code:
Initializing USB MSC drive...[U]2089 ms >> initialization done.[/U]
Writing to test.txt...done.
test.txt:
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
testing 1, 2, 3.
[U]2156 ms >> initialization done.[/U]
[B]Writing to test2.txt...done.
test2.txt:
testing 2 1, 2, 3.
testing TWO :: 1, 2, 3.
[/B]
 
@defragster - Glad everything is working as it should be:) Something else that needs to be fixed in MassStorageDriver.cpp is a stray println("msReadBlocks()") at line #510. I guess I missed that one when I was cleaning it up. It can be deleted and that helps a little bit with the spew. I have used a non-powered 4 port Hub with 3 USB drives connected without issue. I was not brave enough to push it past that.

I am hoping to finish up my current testing project today or tomorrow and post it on the forum for further testing as an example of unifying disk IO. I know this is something that was talked about here:
https://forum.pjrc.com/threads/67588-Teensyduino-1-54-Beta-11/page3

It will just be one example of doing this:)
 
Back
Top