wwatson
Well-known member
Mass Storage Controller (MSC) library for use with Teensy 3.6
This is a project I have been working off and on for two years.
It is a very minimal working USB host mass storage driver for use with the Teensy 3.6 USB host port.
At this time there is very little error checking done. (Not completely processing error and sense codes yet).
Definitely work in progress.
The test program is a modified version of "uSDFS_test.ino" from WMXZ's uSDFS library which can be
found here
. That library also uses ELM-ChaN FatFs library.
Tested with Arduino version 1.8.9 and Teensyduino version 1.46b10.
I do not have or use Windows so MSC has not been tested with that operating system. It should work.
It is working with Linux Ubuntu 18.04 and Mate Desktop 1.12.1.
Libraries used:
* USBHost_t36 PJRC USB Host library.
* uSDFS WMXZ Teensy uSDFS library modified for use with msc.
* MSC Mass Storage Controller, USB Flash drives and USB Hard drives. (see below)
Installation:
Install MSC and uSDFS into "~/Arduino/libraries" folder.
No modifications to USBHost_t36 are needed at this time.
In the MSC folder you will find 4 files in the "MSC/uSDFS_Files_Copied_To_uSDFS" folder that
need to be copied to the "~/Arduino/libraries/uSDFS/src" folder.
They are:
diskio.h
diskio.c
ffconf.h
uSDconfig.h
I would back these files up before replacing them.
I modified uSDconfig.h to add Mass Storage drive "0:/". Drive "1:/" is now the native SDHC drive.
How to change the drive identifiers is also documented in this same file.
A drive activity LED is setup on pin 24 in diskio.c for both drives on my T36.
if needed change the define to use another pin.
Kingston, Sandisk and PNY flash drives that I have used all seem to work ok. The PNY flash drive is
really slow to come up. It takes a few seconds. Kind of like the hard drives do.
I have been using a IDE/SATA to USB adapter from StarTech.com to test the hard drives.
Tested several USB Hard Drives, Seagate, Hitachi, Western Digital, and others along with an older IDE drive.
They all take several seconds to come up but are faster than the flash drives.
Here is some output from the test program.
Hard Drive:
Drive "0:/" Mass Storage.
Flash Drive:
Drive "0:/" Mass Storage.
And drive "1:/"
I have seen talk of mass storage on Teensy recently on the forum.
I hope others with better programming skills than mine can use this code as a starting point
for development and testing.
I am also curious if and how other drives work with this driver and the T36.
Lot's left to do if people are interested.
References:
xxxajk's UHS30 - Great for understanding how to initialize, read and write to a Mass Storage device with error checking.
Dean Camera's LUFA - Also contains excellent info on Mass Storage.
SCSI https://www.seagate.com/files/staticfiles/support/docs/manual/Interface manuals/100293068j.pdf
http://www.t10.org/lists/2op.htm
USB Bulk Only Transport https://www.usb.org/sites/default/files/usbmassbulk_10.pdf
usb20.pdf
This is a project I have been working off and on for two years.
It is a very minimal working USB host mass storage driver for use with the Teensy 3.6 USB host port.
At this time there is very little error checking done. (Not completely processing error and sense codes yet).
Definitely work in progress.
The test program is a modified version of "uSDFS_test.ino" from WMXZ's uSDFS library which can be
found here
Code:
[url]https://github.com/WMXZ-EU/uSDFS[/url]
Tested with Arduino version 1.8.9 and Teensyduino version 1.46b10.
I do not have or use Windows so MSC has not been tested with that operating system. It should work.
It is working with Linux Ubuntu 18.04 and Mate Desktop 1.12.1.
Libraries used:
* USBHost_t36 PJRC USB Host library.
* uSDFS WMXZ Teensy uSDFS library modified for use with msc.
* MSC Mass Storage Controller, USB Flash drives and USB Hard drives. (see below)
Installation:
Install MSC and uSDFS into "~/Arduino/libraries" folder.
No modifications to USBHost_t36 are needed at this time.
In the MSC folder you will find 4 files in the "MSC/uSDFS_Files_Copied_To_uSDFS" folder that
need to be copied to the "~/Arduino/libraries/uSDFS/src" folder.
They are:
diskio.h
diskio.c
ffconf.h
uSDconfig.h
I would back these files up before replacing them.
I modified uSDconfig.h to add Mass Storage drive "0:/". Drive "1:/" is now the native SDHC drive.
How to change the drive identifiers is also documented in this same file.
A drive activity LED is setup on pin 24 in diskio.c for both drives on my T36.
if needed change the define to use another pin.
Kingston, Sandisk and PNY flash drives that I have used all seem to work ok. The PNY flash drive is
really slow to come up. It takes a few seconds. Kind of like the hard drives do.
I have been using a IDE/SATA to USB adapter from StarTech.com to test the hard drives.
Tested several USB Hard Drives, Seagate, Hitachi, Western Digital, and others along with an older IDE drive.
They all take several seconds to come up but are faster than the flash drives.
Here is some output from the test program.
Hard Drive:
Drive "0:/" Mass Storage.
Code:
Mass Storage Contoller with uSDFS
Mounting MSC Device 0:/
Mounting SDHC Device 1:/
-----------------------------------------
Note: USB HD and some flash drives
can take several seconds to
come online.
Please Wait...
Volume Label: TEENSY36HD
Volume Serial Number: 950818267
Removable Device: NO
VendorID: WDC WD25
ProductID: 00YS-01SHB1
RevisionID: 6C06
Sector Count: 490234751
Sector size: 512
Disk Capacity: 490234751 * 512 Bytes
Free Space: 245053952 Kilo Bytes
Create a new file (hello10.txt).
Write some text lines. (Hello world!)
Close the file.
Open same file (hello10.txt).
Get the file content.
Hello world!
Second Line
Third Line
Fourth Line
Habe keine Phantasie
Close the file.
open binary file
write file
close file
Binary test done
Open root directory.
Directory listing...
74 HELLO10.TXT
16384 test00.bin
Done in 160ms
-----------------------------------------
Press a key to test SDHC Drive...
Flash Drive:
Drive "0:/" Mass Storage.
Code:
Mass Storage Contoller with uSDFS
Mounting MSC Device 0:/
Mounting SDHC Device 1:/
-----------------------------------------
Note: USB HD and some flash drives
can take several seconds to
come online.
Please Wait...
Volume Label: TEENSYFLASH
Volume Serial Number: 893713543
Removable Device: YES
VendorID: Kingston
ProductID: DataTraveler 3.0
RevisionID:
Sector Count: 60437491
Sector size: 512
Disk Capacity: 60437491 * 512 Bytes
Free Space: 30202336 Kilo Bytes
Create a new file (hello10.txt).
Write some text lines. (Hello world!)
Close the file.
Open same file (hello10.txt).
Get the file content.
Hello world!
Second Line
Third Line
Fourth Line
Habe keine Phantasie
Close the file.
open binary file
write file
close file
Binary test done
Open root directory.
Directory listing...
74 HELLO10.TXT
16384 test00.bin
Done in 232ms
-----------------------------------------
Press a key to test SDHC Drive...
And drive "1:/"
Code:
Volume Label: TEENSYSDHC
Volume Serial Number: 869690263
Create a new file (hello10.txt).
Write some text lines. (Hello world!)
Close the file.
Open same file (hello10.txt).
Get the file content.
Hello world!
Second Line
Third Line
Fourth Line
Habe keine Phantasie
Close the file.
open binary file
write file
close file
Binary test done
Open root directory.
Directory listing...
74 HELLO10.TXT
16384 test00.bin
Done in 190ms
-----------------------------------------
Press a key to test Mass Storage Drive...
I have seen talk of mass storage on Teensy recently on the forum.
I hope others with better programming skills than mine can use this code as a starting point
for development and testing.
I am also curious if and how other drives work with this driver and the T36.
Lot's left to do if people are interested.
References:
xxxajk's UHS30 - Great for understanding how to initialize, read and write to a Mass Storage device with error checking.
Dean Camera's LUFA - Also contains excellent info on Mass Storage.
SCSI https://www.seagate.com/files/staticfiles/support/docs/manual/Interface manuals/100293068j.pdf
http://www.t10.org/lists/2op.htm
USB Bulk Only Transport https://www.usb.org/sites/default/files/usbmassbulk_10.pdf
usb20.pdf
Code:
[ATTACH]16623._xfImport[/ATTACH]
Last edited by a moderator: