Optimal microSD pins on the Teensy 4.0?

Status
Not open for further replies.

sid8580

Well-known member
I've read that the latest version of Bill Greiman's SdFat library (version 2 Beta) is now compatible with the Teensy 4.0:
https://forum.pjrc.com/threads/57669-SdFat-SDIO-for-Teensy-4-0

So...
I've wired up all of the T4.0 pins between 34 and 39 directly to their corresponding pads on a generic SD-to-microSD-adapter, to minimize the tiny and difficult soldering work at this early testing stage. The microSD card goes in the adapter and voila, poor man's microSD slot... or at least that's the idea I've been getting from various other sources online. I have some actual/physical microSD slots on hand which I will use later on - they don't appear to have any active components in them so I don't see why this wouldn't work.

The pins are connected 1-to-1 per this diagram:
https://components101.com/misc/microsd-card-pinout-datasheet

This matches and is even in the same order as the pins on the underside of the Teensy. But I've tried several of the example sketches within the SdFat-Beta library and although they compile fine, I get errors when I run them (SD fails to init).

I have read that there is a mux issue impacting those pins I'm using, and I see "Teensy 4.0 - use first SPI port" commented in the TeensySdioDemo example.

Is that the fastest configuration possible? Per Bill's post linked above he uses pin 26, MOSI1, and pin 27, SCK1, on the Teensy 4.0 Back Side - and pin 0 for CS1 and pin 1 for MISO1. I'm finding myself confused by the differences between hardware SPI, uSDHC and SDIO, and how to wire them.

Is there a way to utilize the row of pins that would more naturally connect to a microSD card slot underneath?

Thanks :)
 
Last edited:
Thanks for the response. Tried a cap between VDD and VSS (3.3v and GND) on the card holder and no go. Looks like that's where it should be according to that breakout schematic.

Looks like I can use those pins just as they are, in that order (34-39). Verified I'm using the correct library (I can see the files when I compile). But when I run TeensySdioDemo without any modifications, I get:
FIFO or DMA SDIO - SD_CARD_ERROR_ACMD41, ErrorData: 0X1
SPI dedicated or shared - SD_CARD_ERROR_CMD0, ErrorData: 0XFF

I will keep playing with it. Just not sure why this isn't working, by all accounts now I'm thinking it should...again thanks for the reply.
 
This is how I wired a SD to uSD adapter to the Teensy4 SDIO pins.
As you can see it is not 1 to 1.
SD2uSD4T4.jpg
 
Hi neurofun, thanks for the info, wish I could say that worked.

I could use some help sanity checking this if one of you guys wouldn't mind - running out of ideas. Here are some pics.

Here is the wiring connected to the T4.0. After testing for continuity, these wires are now underneath a glob of hot glue meant to keep them battened down, next step is probably going to be tearing that off and checking the connections once again...
IMG_6127.jpg


Here is the SD card to uSD adapter, soldered w/ a 0.1uF cap (hard to see but it's there, 0805 SMD). Before this, I'd tried it the same way but without the cap.

IMG-6227B.jpg


Last is with the wires redone per neruofun's example.

IMG-6228.jpg


I have been using the SdFat-Beta library's examples, as-is without modification. Sketches like TeensySdioDemo, Sdinfo, Bench. None will make it past initialization in any mode (in sketches where I've got a choice of communication type, like TeensySdioDemo, I've chosen them all).

I guess if nothing else works, I will go order blackketter's SD breakout from OSHpark. Not sure why that would work when this doesn't though.

Thanks for your time and patience.
 
Last edited:
According to your first & third picture, your wiring looks ok.
I used the examples->SD->CardInfo.ino sketch to test the SD card's functionality.
You will need to change
Code:
const int chipSelect = 4;
to
Code:
const int chipSelect = BUILTIN_SDCARD;
to make it work.
 
According to your first & third picture, your wiring looks ok.
I used the examples->SD->CardInfo.ino sketch to test the SD card's functionality.
You will need to change
Code:
const int chipSelect = 4;
to
Code:
const int chipSelect = BUILTIN_SDCARD;
to make it work.

I'm assuming you're using the original SD library (v1.2.2), instead of SdFat-Beta? I tried CardInfo.ino from the builtin examples as you did, with the same code change and the same wiring, it still won't initialize. When I compile CardInfo I'm using v1.2.2 of the SDfat library which I believe would be required for this example without changing a lot more of the code.

Maybe I need to reinstall the entire Arduino/Teensyduino environment, or rip the hot glue off the bottom of the Teensy and recheck the connections there.

I'm stuck, 12+ hours on this one problem over the last 2 days and I'm starting to crack, better I work on something else for the time being.
 
Can anyone else confirm how they have their SD cards connected to the T4, and which libraries/sketches they are using successfully (and with what changes made, if any) - in the same manner neurofun did (very clear and assumes nothing)?

There are at least 4 different ways of doing this I've seen so far, but usually when I see someone write about it, they don't include all of the details, probably thinking it's obvious ;-)
 
Hmm. Looks like I need to reverse the pin order, from what I'm seeing in that second thread. Crossing fingers this is the answer :)

Yes - good to double/double check :) Top/Bottom views not always apparent. I should have recalled and linked that in above post #2 …

Note: Even after that the board on the thread had a rev 0 that was wrong before shipping beta … and the shipped beta Rev 1 still ended up with some error and unusable SDIO :(
 
I flipped the pins, both mirroring both the original 1-to-1 layout I had originally, and then I tried it again but staggering the last couple of pins per neurofun's example. Then I put it back and added the capacitor. Still not working with the TeensySdioDemo sketch, just will not initialize. I had used this microSD card daily with the previous build (with a T3.6), so I don't think it's the problem; when I remove the microSD from the adapter the error messages are the same anyway.

There's probably something wrong at a lower level here that I can't see. I think neurofun's wiring may not apply to SDIO; from everything I'm seeing the 9th pin on the SD-to-microSD card adapter isn't connected (the bottom one in my photos, the one that's further back from the edge than the rest - it's unnecessary in terms of data or power, it's just for card detection if desired). I can't see how that would work for this, but I believe it works for him (with the older library somehow).

There's got to be a disconnected wire somewhere. Maybe one of my solder joints under the hot glue broke loose. I need to start again from ground zero.
 
@sid8580
How do I check which version of SD lib i'm using? CardInfo.ino was compiled with Arduino1.8.10 & TD1.48.
Code:
Initializing SD card...Wiring is correct and a card is present.

Card type: SDHC

Volume type is FAT32

Volume size (Kbytes): 15196160
Volume size (Mbytes): 14840

Files found on the card (name, date and size in bytes): 
~1.TRA        2017-08-26 18:01:18 4096

I might be wrong but doesn't the use of "BUILTIN_SDCARD" imply SDIO instead of SPI?

Again your first & third picture is the correct wiring. And your observation(assumption?) on pin 9 is wrong.

Look carefully at the following pictures, those are the ones I used to make it work.

sd-card-pinout.png
20140119-1059-1773.jpg
IMG_20170102_220430679_HDR-624x383.jpg
 
With IDE ' Ctrl ,' properties verbose compile it should show the name and location of libraries used to build

Yes, BUILTIN uses T_3.6/3.5 and T_4 4 data bit SDIO
 
@defragster
Thanks.

@sid8580
Yes, CardInfo.ino was compiled using SD lib v1.2.2.

Just installed Bill Greiman's SdFat library (version 2.0.0-beta.5) and ran his SdInfo sketch.
Code:
SdFat version: 2.0.0
Assuming an SDIO interface.

type any character to start
init time: 7 ms

Card type: SDHC

Manufacturer ID: 0X41
OEM ID: 42
Product: SD16G
Version: 3.0
Serial number: 0XDCB62B00
Manufacturing date: 4/2011

cardSize: 15569.26 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true

OCR: 0XC0FF8000

SD Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
1,0X0,0X82,0X3,0X0,0XC,0XFE,0XFF,0XFF,8192,30400512
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 FAT32
sectorsPerCluster: 64
clusterCount:      474880
freeClusterCount:  260673
fatStartSector:    8962
dataStartSector:   16384
 
Just soldered a fresh T4 to a new microSD adapter just to be sure I didn't make a stupid mistake in my previous posts, and I did not.
Tested and confirmed to work with SD lib v1.2.2 & SdFat lib v2.0.0-beta.5.
SD_to_microSD_teensy4_2.jpg
SD_to_microSD_teensy4_3.jpg
SD_to_microSD_teensy4_4.jpg
 
neurofun - those are some black and white facts, thank you (and defragster) for removing all ambiguity.
I'm working on it now, will report back once it's working.
 
While checking my wiring on the Teensy end, I had to remove the hot glue which resulted in then needing to resolder several of the SDIO pads. In the process I tore off the GND pad completely. Figured if I was going to lose one, that's the luckiest since it's easy to reroute GND. I also had to get in there with an X-acto to separate pads as solder had connected a couple of them just barely during the rework.

Then it still wouldn't work, so I tested PWM output of each of those pins (34-39). They all worked but one, pin 35. Looks like the trace was broken off of that one too and I didn't realize it because there was still part of it there (not connected to the trace) that the wire could solder to.

So now I'm trying to figure out how to reach another physical connection to pin 35, somewhere on the board.
 
Now the computer won't see the Teensy and something's (DMG2305UX mosfet) gets too hot to be functioning normally... I guess it's time to order a new one and start over :mad:

Thanks again for the help. All that extra information made it possible for me to get this far, and to know with confidence where I've made a mistake, for next time.
 
Last edited:
It's all part of the learning process.
Count yourself lucky, I already destroyed 2 teensy4's on the same project and i still haven't a clue why or how.
 
It's all part of the learning process.
Count yourself lucky, I already destroyed 2 teensy4's on the same project and i still haven't a clue why or how.

Ouch, sorry to hear that and hope you are back on track!

I've been working on the same project for ~2 years now... setbacks like these (i.e. 20 hours of work trying to fix a problem that ended with a smoked component) are harder to take than they used to be, heheh...
 
Removing hot glue from PCBs

Ouch, sorry to hear that and hope you are back on track!

I've been working on the same project for ~2 years now... setbacks like these (i.e. 20 hours of work trying to fix a problem that ended with a smoked component) are harder to take than they used to be, heheh...

I have also been trying to chase down the same problem, and got myself into a terrible mess, swapping SDFat versions back and forth - I posted here because misery loves company :)

There are two tried and tested techniques for removing hot glue with minimal effort, depending mostly on the surface it's adhering to ( I learn this building foam board model R/C planes):

* Hold a can of compressed air upside down and direct some of the propellant over the glue - within a few seconds it will harden to the point of being very brittle, and can be broken off in shards. Of course, you have to take care that the delicate wires are not torn off. The second method below is a bit safer.

* Soak the hot glue with a few drops of rubbing alcohol and wait a minute or so, applying more to ease the bond - this works well as the alcohol finds it's way between the surfaces.

Good luck!
 
Thanks neurofun! That low budget µSD card adapter worked out of the box when I tried it with a T4 and FrankBs MP3 library! Nice idea and realization :)

Thanks for providing the pictures in post #18, without them I would not have dared to do this, soldering tiny wires to the SD solder pads is not as difficult as I expected.
 
Status
Not open for further replies.
Back
Top