SD card read via usb on Teensy 4.1

MMESSITER

Well-known member
Hello
Using a Teensy 4.1 with sd card, is it possible to read and write files on the sd card via the usb connector? If yes, how?!
 
Hello
Using a Teensy 4.1 with sd card, is it possible to read and write files on the sd card via the usb connector? If yes, how?!
If you are talking about the USBHost connector then the answer is yes. You will need a USB SD card reader. Then in Teensyduino 1.59 try the driveinfo.ino sketch found in "USBHost_t36/examples/storage" folder. There are a couple other sketches as well...
 
In Arduino IDE, first make sure Teensy is selected in Tools > Board. The menus update based on which board you're using. Then click File > Examples > USBHost_t36 > Storage to find those examples. Hopefully those can help get you to a good start.
 
I meant the built in SD card, and the usb connector we use to upload the firmware. Sorry if wasn’t clear.

If, after uploading code and testing, I could look at the SD card contents without taking out the card and without moving any connectors that’d save lots of development time.
 
In Arduino IDE, first make sure Teensy is selected in Tools > Board. The menus update based on which board you're using. Then click File > Examples > USBHost_t36 > Storage to find those examples. Hopefully those can help get you to a good start.
Thanks Paul! I will try what you suggest. Will it let me see the built in sd card via the usb port I use to upload firmware?
 
I meant the built in SD card, and the usb connector we use to upload the firmware. Sorry if wasn’t clear.

For the Teensy 4.1 built in SD card, you need the examples from File > Examples > SD. Those examples default to the regular SPI port, which would be used with the audio shield or other hardware you'd connect to the SPI pins. To use the built in SD card, you need to edit the code. See the comments in those examples for instructions.

For the main USB device port you connect to your PC, you probably want MTP protocol. It's still considered experimental. You need to select it in the Tools > USB Type menu. You also need Kurt's MTP library. Like with the SD library, the examples require some editing to configure which media gets shown to your PC.

If using MacOS, you'll need the Android File Transfer program. MTP is native with Windows and Linux, so no special software needed. The drives you publish with the MTP library should appear automatically.

It might be simpler to just physically put the SD card into a regular SD card reader connected to your PC.
 
For the Teensy 4.1 built in SD card, you need the examples from File > Examples > SD. Those examples default to the regular SPI port, which would be used with the audio shield or other hardware you'd connect to the SPI pins. To use the built in SD card, you need to edit the code. See the comments in those examples for instructions.

For the main USB device port you connect to your PC, you probably want MTP protocol. It's still considered experimental. You need to select it in the Tools > USB Type menu. You also need Kurt's MTP library. Like with the SD library, the examples require some editing to configure which media gets shown to your PC.

If using MacOS, you'll need the Android File Transfer program. MTP is native with Windows and Linux, so no special software needed. The drives you publish with the MTP library should appear automatically.

It might be simpler to just physically put the SD card into a regular SD card reader connected to your PC.
Indeed it’s far simpler to just remove the card of course. But, so far, I’m working on three projects where repeatedly removing the card to examine its contents is needed and this is costing us extra time - especially when the card and the Teensy 4.1 are inside a closed case.
If my spending an hour or two making the SD card appear on the MacBook Pro desktop just like any other removable drive, that would speed future development enormously as well as reducing physical wear and tear. I think you suggest it’s possible!! Hooray! But it might be a bit beyond my current abilities, so I wonder if some very clever chap has done it already and might share the code?! It’s a facility that I imagine many would love to have!!
 
Back
Top