USBHost_t36 USB Mass Storage Driver Experiments

Great. I am still distracted for maybe a couple of days, but will be fun to see how everything has progressed
 
@All

I finally was able to upload MSC to GitHub last night. No readme yet. I have to finish learning how to use it properly.

Here is the link:
https://github.com/wwatson4506/MSC

Got to go to work.

Suggest to rename the directory in MSC form MSC to src and to add the two library files (.jason and .properties) so one can it clone directly into Arduino/libraries (the examples directory goes one level up (equal to src)
 
Last edited:
Just made this MOD to get controlled shutdown:
Code:
  if (ifn > MXFN) { blink(500); return; }

// about line 83 : ..\uSDFS\examples\logger_RawWrite\logger_RawWrite.ino
// Stop test and unmount when 'q' seen on Serial read.
[B]  while (Serial.available() > 0) 
    { if ('q' == Serial.read() ) ifn = MXFN+1; }[/B]

Test got this far no problem overnight:
Code:
........................................ (105128996 - 9.350799 MB/s)
 (open: 1249990 us; close: 55000 us; write: min,max: 7916 43918 us)

B_00334.dat
stat FR_NO_FILE 2723fa
 opened FR_OK 0

That is a LONG open time { started closer to 200ms more than 1 second added } - maybe too many files in root? That used to be more constrained - maybe test in a subdirectory?

Did the COMPILE TIME get built in yet for T$ - would be nice to have realistic time/date stamps after upload or warm restart.

I'm going to scan this disk on PC and then power up my USB3 drive Dock to see if Teensy likes it in case it was just not liking the questionable drives I was feeding it.

Drive - no major errors - just the allocated space bitmap?:
Code:
The type of the file system is exFAT.
Volume Serial Number is 74FA-9536
Windows is verifying files and folders...
Volume label is 465GBsams.
Corruption was found while examining the volume bitmap.
File and folder verification is complete.

Windows has made corrections to the file system.
No further action is required.

 488265728 KB total disk space.
 328816128 KB in 441 files.
       512 KB in 4 indexes.
         0 KB in bad sectors.
       640 KB in use by the system.
 159448448 KB available on disk.

    131072 bytes in each allocation unit.
   3814576 total allocation units on disk.
   1245691 allocation units available on disk.

Partial directory:
Code:
K:\>dir *31*.dat
 Volume in drive K is 465GBsams
 Volume Serial Number is 74FA-9536

 Directory of K:\

01/01/2020  12:00 AM        98,304,000 A_00031.dat
01/01/2020  12:00 AM       983,040,000 B_00031.dat
01/01/2020  12:00 AM       983,040,000 B_00131.dat
01/01/2020  12:00 AM       983,040,000 B_00231.dat
01/01/2020  12:00 AM       983,040,000 B_00310.dat
01/01/2020  12:00 AM       983,040,000 B_00311.dat
01/01/2020  12:00 AM       983,040,000 B_00312.dat
01/01/2020  12:00 AM       983,040,000 B_00313.dat
01/01/2020  12:00 AM       983,040,000 B_00314.dat
01/01/2020  12:00 AM       983,040,000 B_00315.dat
01/01/2020  12:00 AM       983,040,000 B_00316.dat
01/01/2020  12:00 AM       983,040,000 B_00317.dat
01/01/2020  12:00 AM       983,040,000 B_00318.dat
01/01/2020  12:00 AM       983,040,000 B_00319.dat
01/01/2020  12:00 AM       983,040,000 B_00331.dat
              15 File(s) 13,860,864,000 bytes
               0 Dir(s)  163,275,210,752 bytes free

Odd output in a simple 'dir' - poorly formed file name probably from 'reset' - those file would have been open:
Code:
01/01/2020  12:00 AM       983,040,000 B_00333.dat
[B]The parameter is incorrect.[/B]
[B][COLOR="#FF0000"]01/01/20㼽   [/COLOR][/B]                0 B_00334.dat
             435 File(s) 336,199,680,058 bytes
               0 Dir(s)  163,275,210,752 bytes free

and:
Code:
The parameter is incorrect.
01/01/20㼽                   0 B_00001.dat
 
Last edited:
Drive looked healthy enough for all the starts and restarts - 96MB and 960MB files looked good. Deleted them and got the other Dock.

USB3 dock is labelled "EZDisk" - and it fails to start like the other minimal unit. Using the updated Merged USBHost_T36 debug shows this:
Code:
Test logger_RawWrite
BUFFSIZE :24576
Dev Type :2:/
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2001C000
periodictable = 2001C000
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 25 10 6C 08 00 02 01 02 03 01 
    VendorID = 1025, ProductID = 086C, Version = 0200
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: ezDISK
enumeration:
Product: EZ0330
enumeration:
Serial Number: 30303030303030303030303030303030
enumeration:
Config data length = 85
enumeration:
Configuration Descriptor:
  09 02 55 00 01 01 00 C0 01 
    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 8B 02 00 02 00 
    Endpoint = 11 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  07 05 0A 02 00 02 00 
    Endpoint = 10 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 08 02 00 02 00 
    Endpoint = 8 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  04 24 01 00 
  07 05 89 02 00 02 00 
    Endpoint = 9 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  04 24 02 00 
  07 05 0A 02 00 02 00 
    Endpoint = 10 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  04 24 04 00 
  07 05 8B 02 00 02 00 
    Endpoint = 11 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  04 24 03 00 
enumeration:
msController claim this=2001AF20
Descriptor 4 = INTERFACE
msController claim this=2001AF20
09 04 00 00 02 08 06 50 00 07 05 8B 02 00 02 00 07 05 0A 02 00 02 00 09 04 00 01 04 08 06 62 00 07 05 08 02 00 02 00 04 24 01 00 07 05 89 02 00 02 00 04 24 02 00 07 05 0A 02 00 02 00 04 24 04 00 07 05 8B 02 00 02 00 04 24 03 00 
numendpoint=2
endpointIn=8B
endpointOut=A
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
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 02 00 00 00 00 00 00 00 80 00 06 1B 01 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 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 03 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 03 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 04 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 04 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 05 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 05 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 06 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 06 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 07 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 07 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 08 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 08 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 09 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 09 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0A 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 0A 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0B 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 0B 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0C 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 0C 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0D 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 0D 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0E 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 0E 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 0F 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 0F 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 10 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 10 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 11 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 11 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 12 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 12 00 00 00 00 00 00 00 01 
** CSWSIGNATURE

// ..

Only gets this far on 'KingWin' - powered HUB and Cable it lights but doesn't seem to spin up:
Code:
Test logger_RawWrite
BUFFSIZE :24576
Dev Type :2:/
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2001C000
periodictable = 2001C000
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 11 28 70 90 01 02 00 01 
    VendorID = 2109, ProductID = 2811, Version = 9070
    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:
msController claim this=2001AF20
Descriptor 4 = INTERFACE
msController claim this=2001AF20
Descriptor 5 = ENDPOINT

It gets farther and then SPEW on cable direct to Teensy - but not spun up with this adapter:
Code:
Test logger_RawWrite
BUFFSIZE :24576
Dev Type :2:/
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2001C000
periodictable = 2001C000
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 11 28 70 90 01 02 00 01 
    VendorID = 2109, ProductID = 2811, Version = 9070
    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:
msController claim this=2001AF20
Descriptor 4 = INTERFACE
msController claim this=2001AF20
Descriptor 5 = ENDPOINT
port change: 1C00100A
    disconnect
disconnect_Device:
USBDriver (available_drivers) list: 2001AF20
USBDriver (dev->drivers) list: (empty
USBDriver (available_drivers) list: 2001AF20
delete_Pipe 2001C400
  shut down async schedule
  Free transfers
  Free transfers attached to QH
    * 536981984
* 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 00 02 00 00 00 40 E3 05 18 07 08 00 00 01 02 01 
    VendorID = 05E3, ProductID = 0718, Version = 0008
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Product: USB Storage
enumeration:
Serial Number: 000000000033
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 C0 30 
    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=2001AF20
Descriptor 4 = INTERFACE
msController claim this=2001AF20
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 
Test logger_RawWrite
BUFFSIZE :24576
Dev Type :2:/
USB2 PLL running
 reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2001C000
periodictable = 2001C000
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 00 00 00 40 E3 05 18 07 08 00 00 01 02 01 
    VendorID = 05E3, ProductID = 0718, Version = 0008
    Class/Subclass/Protocol = 0 / 0 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Product: USB Storage
enumeration:
Serial Number: 000000000033
enumeration:
Config data length = 32
enumeration:
Configuration Descriptor:
  09 02 20 00 01 01 00 C0 30 
    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=2001AF20
Descriptor 4 = INTERFACE
msController claim this=2001AF20
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 02 00 00 00 00 00 00 00 80 00 06 1B 01 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 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 03 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 03 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 04 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 04 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 05 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 05 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 06 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 06 00 00 00 00 00 00 00 01 
** CSWSIGNATURE
msController CallbackOut (static)
transfer->qtd.token = 0
msController dataOut (static)31
55 53 42 43 07 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 07 00 00 00 00 00 00 00 01 
** CSWSIGNATURE

// ...
 
@defragster - don’t have time at computer to look, at your EzDisk hang but looks like hang on one of my usb stick, where it hangs waiting for media ready...

You might see if the initial code is calling some call like get max lun... which was sort of busted, unless changed to wait for response. In the one case I have it returned 1, others 0...

I was hacking my versions of wait for media ready to in this case try 0 and 1...

It much look yet. There was another api to return list of luns,which I was going to try next to see if maybe they used a different value...
 
We can put a pin in it - I have one working unit. As noted I found that unit not usable on PC for drive copies the last time … again. If it follows USB stick usage we'll have to get that resolved.

I'm getting a new Fridge Thurs and a T4B2.1 Friday - some other things I need to do - my lawnmower brake pedal apparently lost a pin on a buried shaft … so no brake - which is only a major issue on the 'Start Interlock' - and the grass is growing.

I noticed the post #129 'q'- Quit only unmounts when file is closed - but always quits … so that is an incomplete fix for clean exit.

Paul pointed to USB detecting 'bootloader' trigger - doing disk I/O and logging makes me thing we should get a 'weak' void Teensy_Shutdown() implemented. Same for the T$ 5 second power off trigger - but I'm not sure where that is generated - asked on beta thread and no answer I saw.
 
Did the COMPILE TIME get built in yet for T$ - would be nice to have realistic time/date stamps after upload or warm restart.

The examples\ logger_RawWrite_FS has routines that allow rtc_sync with "__rtc_localtime" symbol that must be added to build command

PS: will be on the road for a couple of days
 
@defragster, @WMXZ, @wwatson, @KurtE

Just reformatted an old laptop drive for exFAT (ATA IDE) and used an uspeed 2.5/3.5 usb 3.0 esata docking station by anker (no longer on amazon so I cant provide a link) and it worked without an issue:
Code:
Test uSDFS
2:/

Change drive

Create a new subdirectories.

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

Open same file /Ascii/HELLO13.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.

Don't think I am going to be of much help debugging here since my everything I am using seems to work. Sorry.
 
@defragster, @WMXZ, @wwatson, @KurtE

Just reformatted an old laptop drive for exFAT (ATA IDE) and used an uspeed 2.5/3.5 usb 3.0 esata docking station by anker (no longer on amazon so I cant provide a link) and it worked without an issue:
...
Don't think I am going to be of much help debugging here since my everything I am using seems to work. Sorry.

I find this - but haven't looked around this code at all - ...\libraries\msc\MassStorageHost.cpp:
Code:
uint8_t mscInit(void) {
	uint8_t msResult = 0;

	while(!msDrive1.available());
	msDrive1.msReset();
	delay(1000);
	msResult = msDrive1.[B]msGetMaxLun[/B]();

Found two more used long ago drives in USB boxes ...
 
One external drive 'Zdisc280GB' failed with:
Code:
Test logger_RawWrite
BUFFSIZE :24576
Dev Type :2:/
[COLOR="#FF0000"]Mount: Failed with rc=FR_NO_FILESYSTEM.[/COLOR]

Odd it was just exFAT formatted in Windows as a 279 GB drive, and still good going back to Windows. Return to Teensy and it fails - must be something in the USB/SATA adapter - will set that aside for later.

The other external USB boxed drive 'EZext600' came up fine and ran the logger test. - this drive had the same partition wipe and add Simple Partition formatted exFat.

@WMXZ - Quick edit to the logger_RawWrite allows clean close/unmount exit:
Code:
  if (ifn > MXFN) { blink(500); return; }

[B]  while (Serial.available() > 0) { if ('q' == Serial.read() ) { [U]count=0;[/U] ifn = MXFN+1; } }
[/B]
  if (!count)

Here is the Apricorn EzBus 600GB drive - it runs 2 MB/s faster - and I issued a 'q' to quit and I see a valid partial file:
Code:
.................................................... (43652991 - 11.259709 MB/s)
 (open: 54996 us; close: 24000 us; write: min,max: 6916 26918 us)

A_00004.dat
stat FR_NO_FILE 3ea8
 opened FR_OK 0

................................................................
................................................................
................................................................
................................................................
....................... (24362991 - 20.174862 MB/s)
 (open: 44996 us; close: 27000 us; write: min,max: 6916 28908 us)

unmount FR_OK
 
@defragster

Sounds like you are having some success with different HDD's. Beginning to wonder if trying to get it to work with every drive and every type adapter is going to be an never ending process, especially for old hardware. Not saying that we shouldn't try though :)
 
@defragster

Sounds like you are having some success with different HDD's. Beginning to wonder if trying to get it to work with every drive and every type adapter is going to be an never ending process, especially for old hardware. Not saying that we shouldn't try though :)

Not sure how many more I have - these are old 'kits' with 3.5" drives - not sure there isn't another couple around - and some other adapters. They got abandoned when the packaged 2.5" drives came out - those are generally larger so shifting them to exFAT to test would be a waste - but these have been parked for 7 to 9 years.

I have some 2.5" carrier boxes - and at least 3 working HDD's somewhere - working but swapped to keep fresh HDD in laptop.

Indeed seeing two HDD working configurations is good for now for proof of concept - Nice that SD Card in USB adapters work - would be nice to see USB Sticks work better - I just plugged one in and it is running LOG - but very fitfully - some long pauses between dots!.
This is a 64GB aData USB 3.1 "UV150" - ended with a 'q' to preserve the file system:
Code:
Test logger_RawWrite
BUFFSIZE :24576
Dev Type :2:/
File System FS_EXFAT
Free Disk Size -1 clusters
Cluster Size 256 sectors
Sector Size 512 bytes

Change drive
A_00001.dat
stat FR_NO_FILE 0
 opened FR_OK 0

................................................................
.................................... (34747991 - 2.829056 MB/s)
 (open: 74999 us; close: 99000 us; write: min,max: 7916 5390918 us)

A_00002.dat
stat FR_NO_FILE 2ae2d
 opened FR_OK 0

................................................................
.................................... (21696990 - 4.530766 MB/s)
 (open: 76995 us; close: 16000 us; write: min,max: 7916 5323918 us)

A_00003.dat
stat FR_NO_FILE 38910
 opened FR_OK 0

............................... (6047990 - 16.253996 MB/s)
 (open: 76996 us; close: 17000 us; write: min,max: 7916 2424918 us)

unmount FR_OK

The HDD's ran dots uniformly and without pauses.

The 8GB Kingston Flash stick still fails to start and runs MCU temp to 109F with debug off and no activity. Seems to be 104 with the aData USBstick working. And letting it run on EzBus HDD is more like 106F.

How about Ethernet USB? USB 2.0 Fast Ethernet Adapter
Code:
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2001C000
periodictable = 2001C000
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 FF FF 00 40 95 0B 20 77 01 00 01 02 03 01 
    VendorID = 0B95, ProductID = 7720, Version = 0001
    Class/Subclass/Protocol = 255 / 255 / 0
    Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: ASIX Elec. Corp.
enumeration:
Product: AX88x72A
enumeration:
Serial Number: 58075F
enumeration:
Config data length = 39
enumeration:
Configuration Descriptor:
  09 02 27 00 01 01 04 A0 7D 
    NumInterfaces = 1
    ConfigurationValue = 1
  09 04 00 00 03 FF FF 00 07 
    Interface = 0
    Number of endpoints = 3
    Class/Subclass/Protocol = 255 / 255 / 0
  07 05 81 03 08 00 0B 
    Endpoint = 1 IN
    Type = Interrupt
    Max Size = 8
    Polling Interval = 11
  07 05 82 02 00 02 00 
    Endpoint = 2 IN
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
  07 05 03 02 00 02 00 
    Endpoint = 3 OUT
    Type = Bulk
    Max Size = 512
    Polling Interval = 0
enumeration:
msController claim this=2001AF20
Descriptor 4 = INTERFACE
msController claim this=2001AF20
09 04 00 00 03 FF FF 00 07 07 05 81 03 08 00 0B 07 05 82 02 00 02 00 07 05 03 02 00 02 00 
Descriptor 5 = ENDPOINT
Descriptor 5 = ENDPOINT
Descriptor 5 = ENDPOINT
 
Last edited:
@defragster

Indeed seeing two HDD working configurations is good for now for proof of concept - Nice that SD Card in USB adapters work - would be nice to see USB Sticks work better - I just plugged one in and it is running LOG - but very fitfully - some long pauses between dots!.
Yeah - I agree. But I think we managed to collect quite a collection of HDDs and SSDs to show it can work.

Think your pushing it with the ethernet USB adapter :)

Although I just woke up and was wondering if a 5.5 drive would work or a FDD - argh talk about pushing it :)
 
@defragster

Yeah - I agree. But I think we managed to collect quite a collection of HDDs and SSDs to show it can work.

Think your pushing it with the ethernet USB adapter :)

Although I just woke up and was wondering if a 5.5 drive would work or a FDD - argh talk about pushing it :)

I saw an Iomega Zip drive on my desk - wasn't going to mention it or try it. What about CD/DVD drives :( Ethernet seemed like useful fun - except it probably has a boat load of code beyond 'connecting'.
 
I saw an Iomega Zip drive on my desk - wasn't going to mention it or try it. What about CD/DVD drives :( Ethernet seemed like useful fun - except it probably has a boat load of code beyond 'connecting'.

Yep probably lots of code, but hopefully most of can be derived from existing libraries

Back to this library:
Also note unless it has changed the libraries and example there is no hub object defined, so if dish plugged into hub won’t work

Ihacked my copy of test app to include one hub...
 
Yep probably lots of code, but hopefully most of can be derived from existing libraries

Back to this library:
Also note unless it has changed the libraries and example there is no hub object defined, so if dish plugged into hub won’t work

Ihacked my copy of test app to include one hub...

Having hub support is good. If you can derive a worthy example - especially incorporating other Host devices for parallel use? Second drive? or input device?

I ordered a drive box for a 2.5" HDD that is a powered HUB with the drive to be placed inside. I picked that one because it came with a wall wart to make sure the drive would have full power not from Teensy Host port - and having 3 more powered ports seemed handy in a box not much bigger than a 2.5" HDD. So that drive will always be online - I just hope the USB<>SATA adapter is a good one that doesn't need debugged and the drive responds well. It is only 5400 RPM - but 500GB and has 128 MB cache should allow for good performance for $34. Won't have that together until mid next week.
 
Thanks - I did put the Amazon hub into the T$ and it works with the drives with the drives that worked before.

Flash drive speed looks similar - but the 11MB/s HDD is now showing 10.56 regularly. Indeed taking the HUB out and restarting direct connect is back to 11.3 MB/s

Looks like just adding this to the logger sketch:
Code:
#include <USBHost_t36.h>
extern USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);

Ready for the new fridge delivery in the next hour or so and long lunch soon …

Really have high hopes for the 128MB cached HDD - that should be good for writes, have not tested read speed/operation yet ...
 
re#144 :: There is more to using the myusb and .begin() - I didn't incorporate that …
Examples in USBHost lib show .being() and .Task() … but there must be more to getting the USBHost myusb so far unfound ...

I did include this T$_beta_thread rtc_init() and setup() call to start the RTC ticking - probably needs T_3.6 equiv #ifdef - it does not have a real value from compile or other - but at least minutes tick by on file create dates.
This is on the T_4 Msg#6 - but not yet included in cores:
Code:
void rtc_init() {
  CCM_CCGR2 |= CCM_CCGR2_IOMUXC_SNVS(CCM_CCGR_ON);
  SNVS_LPGPR = SNVS_DEFAULT_PGD_VALUE;
  SNVS_LPSR = SNVS_LPSR_PGD_MASK;
  if (!(SNVS_LPCR & 1)) {
    SNVS_LPCR |= 1;             // start RTC
    while (!(SNVS_LPCR & 1));
    Serial.print( " RTC Started!" );
  }
  else
  {
    Serial.print( " RTC already Running!" );
  }
}

It can be set with unix time seconds value like this:
void rtc_set_time() {
uint32_t secs = 1547051415;
SNVS_LPCR &= ~1; // stop RTC
while (SNVS_LPCR & 1);
SNVS_LPSRTCMR = (uint32_t)(secs >> 17U);
SNVS_LPSRTCLR = (uint32_t)(secs << 15U);
SNVS_LPCR |= 1; // start RTC
while (!(SNVS_LPCR & 1));
}
 
Looking to put the T4B0 on USB test duty needed to fix/add this for 1052:
Code:
T:\tCode\libraries\uSDFS\src\utility\sd_msc.cpp:
   29  #include "sd_config.h"
   30  
   31: #if defined __MK66FX1M0__ || defined __MK64FX512__ || defined __IMXRT1062__ [COLOR="#FF0000"]|| defined __IMXRT1052__[/COLOR]

Wow - found an olde schoole 2 GB flash drive … 0.45 MB/s - but it works.

Another old 4G Toshiba flash stalls.
 
Having hub support is good. If you can derive a worthy example - especially incorporating other Host devices for parallel use? Second drive? or input device?

I ordered a drive box for a 2.5" HDD that is a powered HUB with the drive to be placed inside. I picked that one because it came with a wall wart to make sure the drive would have full power not from Teensy Host port - and having 3 more powered ports seemed handy in a box not much bigger than a 2.5" HDD. So that drive will always be online - I just hope the USB<>SATA adapter is a good one that doesn't need debugged and the drive responds well. It is only 5400 RPM - but 500GB and has 128 MB cache should allow for good performance for $34. Won't have that together until mid next week.

@defragster
That USB/Sata box looks cool - ordered one yesterday from amazon along with a 1TB drive (same one as the 500GB with the 138MB cache). Couldn't resist.
 
I did include this T$_beta_thread rtc_init() and setup() call to start the RTC ticking - probably needs T_3.6 equiv #ifdef - it does not have a real value from compile or other - but at least minutes tick by on file create dates.
This is on the T_4 Msg#6 - but not yet included in cores:
Code:
void rtc_init() {
  CCM_CCGR2 |= CCM_CCGR2_IOMUXC_SNVS(CCM_CCGR_ON);
  SNVS_LPGPR = SNVS_DEFAULT_PGD_VALUE;
  SNVS_LPSR = SNVS_LPSR_PGD_MASK;
  if (!(SNVS_LPCR & 1)) {
    SNVS_LPCR |= 1;             // start RTC
    while (!(SNVS_LPCR & 1));
    Serial.print( " RTC Started!" );
  }
  else
  {
    Serial.print( " RTC already Running!" );
  }
}

It can be set with unix time seconds value like this:
void rtc_set_time() {
uint32_t secs = 1547051415;
SNVS_LPCR &= ~1; // stop RTC
while (SNVS_LPCR & 1);
SNVS_LPSRTCMR = (uint32_t)(secs >> 17U);
SNVS_LPSRTCLR = (uint32_t)(secs << 15U);
SNVS_LPCR |= 1; // start RTC
while (!(SNVS_LPCR & 1));
}

For completeness, see also my post https://forum.pjrc.com/threads/5582...er-Experiments?p=205971&viewfull=1#post205971 for syncing T$ with PC
 
Quick update: I am still distracted and currently can not do much.

But: this morning I synced up to the latest libraries, both uSDFS and MFC and tried running the sdfs test on the 1gb cruzer disk and it worked? So things are progressing.

But then the other SDCard that was working is not now... Will debug later...

Created a branch to getMaxLun... Created PR so you can take a look and integrate if it makes sense.

now back to diversion.
 
@mjs513 - I was at newegg and bought there - bugs me when I get stuff from amazon instead of newegg that has been there as needed for years - so I didn't look this time. Ships faster 'FREE Delivery Tomorrow' versus newegg 'free 3 business days' - Friday/Saturday versus Tuesday in this case :( - but no trouble
> I don't see the same 'ORICO 2.5 inch Hard Drive Enclosure with 3 Ports USB3.0 HUB' with HUB at amazon? - hopefully you got the same so we can make it work for sure.
> AMAZING 15mm high 2.5" FIVE TERRABYTE for $155!
> I went with 500GB to minimize waste as clusters already 256KB - though (this and 1TB) could be partitioned it seems into multiple exFAT


I saw a something - but not from the linked? Here: ...\libraries\uSDFS\src\utility\ff_utils.c - has that same code there [under : #if defined(__IMXRT1052__) || defined(__IMXRT1062__) ] - I had pulled from t4_beta thread::
Code:
    void rtc_init() 
    { CCM_CCGR2 |= CCM_CCGR2_IOMUXC_SNVS(CCM_CCGR_ON);
// …
    while (!(SNVS_LPCR & 1));
    }

    extern void *__rtc_localtime; 
    void rtc_set_time(uint32_t secs) 
    { //uint32_t secs = 1547051415;
    SNVS_LPCR &= ~1;   // stop RTC
// …
    while (!(SNVS_LPCR & 1));
    }

Super distracted here too … and T4B2m1 to be here with today's mail …

@KurtE - Good to see you looking after things … building code and the diversion …

Found another 2TB NTFS external 3.5" Sabrent USB3 drive - oddly on DELL front panel it killed USB - then replug okay, but failed to come up okay - then on HUB it came up and showed the drive.

FYI?:: - some of the small adapter USB<>SATA are apparently only stated as 2.5" drive capable? I was trying my 'KINGWIN' on a 3.5" drive.
 
Last edited:
Back
Top