Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 27

Thread: Optimal microSD pins on the Teensy 4.0?

  1. #1

    Optimal microSD pins on the Teensy 4.0?

    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...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/micro...nout-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 by sid8580; 10-23-2019 at 07:55 AM. Reason: Forgot to mention uSDHC

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,093
    If you look at this breakout board there is a cap onboard: github.com/blackketter/teensy4_sd_breakout

    That started here in this thread - without a CAP : pjrc.com/threads/57672-Another-Teensy-4-0-Breakout-Board

    Having all the lines in the right order is critical - but that cap was added for function :: Added decoupling cap C1, 0.1uF

  3. #3
    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.

  4. #4
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    164
    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.
    Click image for larger version. 

Name:	SD2uSD4T4.jpg 
Views:	14 
Size:	81.2 KB 
ID:	17988

  5. #5
    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...
    Click image for larger version. 

Name:	IMG_6127.jpg 
Views:	12 
Size:	180.2 KB 
ID:	17989


    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.

    Click image for larger version. 

Name:	IMG-6227B.jpg 
Views:	9 
Size:	124.4 KB 
ID:	17990


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

    Click image for larger version. 

Name:	IMG-6228.jpg 
Views:	6 
Size:	112.2 KB 
ID:	17991


    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 by sid8580; 10-23-2019 at 07:06 PM. Reason: Resized images for direct upload

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,093
    images on the forum are limited to 1 MB - maybe that was the catch?

  7. #7
    Quote Originally Posted by defragster View Post
    images on the forum are limited to 1 MB - maybe that was the catch?
    You're right, the files are huge. Even the .PNG's, wow. Fixing now.

  8. #8
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    164
    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.

  9. #9
    Quote Originally Posted by neurofun View Post
    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.

  10. #10
    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 ;-)

  11. #11
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,093
    Paul's OSH posted Beta Breakout works - not sure if you can get a view from that - downloaded files?? :: oshpark.com/shared_projects/eowWCxeK

    Also this thread has some info this post and a pic on the one following … https://forum.pjrc.com/threads/57122...l=1#post216296

  12. #12
    Quote Originally Posted by defragster View Post
    Paul's OSH posted Beta Breakout works - not sure if you can get a view from that - downloaded files?? :: oshpark.com/shared_projects/eowWCxeK

    Also this thread has some info this post and a pic on the one following … https://forum.pjrc.com/threads/57122...l=1#post216296
    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 :-)

  13. #13
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,093
    Quote Originally Posted by sid8580 View Post
    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

  14. #14
    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.

  15. #15
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    164
    @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.

    Click image for larger version. 

Name:	sd-card-pinout.png 
Views:	13 
Size:	58.5 KB 
ID:	17992
    Click image for larger version. 

Name:	20140119-1059-1773.jpg 
Views:	7 
Size:	282.5 KB 
ID:	17993
    Click image for larger version. 

Name:	IMG_20170102_220430679_HDR-624x383.jpg 
Views:	7 
Size:	48.5 KB 
ID:	17994

  16. #16
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,093
    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

  17. #17
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    164
    @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

  18. #18
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    164
    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.
    Click image for larger version. 

Name:	SD_to_microSD_teensy4_2.jpg 
Views:	24 
Size:	67.2 KB 
ID:	18000
    Click image for larger version. 

Name:	SD_to_microSD_teensy4_3.jpg 
Views:	29 
Size:	68.7 KB 
ID:	18001
    Click image for larger version. 

Name:	SD_to_microSD_teensy4_4.jpg 
Views:	15 
Size:	72.9 KB 
ID:	18002

  19. #19
    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.

  20. #20
    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.

  21. #21
    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

    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 by sid8580; 10-25-2019 at 02:46 AM.

  22. #22
    Senior Member
    Join Date
    Nov 2017
    Location
    Belgium
    Posts
    164
    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.

  23. #23
    Quote Originally Posted by neurofun View Post
    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...

  24. #24
    Junior Member
    Join Date
    Jan 2018
    Location
    U.S.A.
    Posts
    1

    Removing hot glue from PCBs

    Quote Originally Posted by sid8580 View Post
    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!

  25. #25
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    507
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •