Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 18 of 18

Thread: T4 SDIO SD Card "initialization failed!"

  1. #1

    T4 SDIO SD Card "initialization failed!"

    I modified a SPI SD card adapter to work as SDIO, soldered to the back pins on the T4.

    I cut the connections between some of the pins of the SD adapter, so now each pad goes exclusively to each pin. This was many times checked with a multimeter. Then I soldered cables (CAT5) from the adapter to the Teensy, following the normal pinout.

    When I try example codes like CardInfo.ino I get the error "Initializing SD card...initialization failed!"

    Any idea what might be happening? I checked the connections and there are no shorts between the pads. Some of them have a difference of a few hundreds ohm, which I assume is normal. My mind is turning in circles right now, below a few pics of my setup.

    Click image for larger version. 

Name:	IMG_0230.jpg 
Views:	22 
Size:	119.0 KB 
ID:	27095
    Click image for larger version. 

Name:	IMG_0232.jpg 
Views:	22 
Size:	104.0 KB 
ID:	27096
    Click image for larger version. 

Name:	IMG_0231.jpg 
Views:	21 
Size:	107.5 KB 
ID:	27097

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,859
    Not sure of the total length based on the photo array? It is a fast device so length won't help.

    Also double check the wire association. Getting it all right took some revision for a PCB design linked below.

    See Here and confirm the names to the Teensy Card and T_4.0 silkscreen :: Teensy-4-0-Breakout-Kit

  3. #3
    This morning I made the cables shorter (ca. 2cm) but still not working. Is it possible to trace the problem with the error code?

    SD errorCode: SD_CARD_ERROR_ACMD41 = 0x17
    SD errorData = 0x0

    The SD card is 128GB, could it be maybe a card size/format problem?

    Click image for larger version. 

Name:	IMG_0233.jpg 
Views:	7 
Size:	123.5 KB 
ID:	27100

  4. #4
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    8,126
    Quote Originally Posted by domingo View Post
    This morning I made the cables shorter (ca. 2cm) but still not working. Is it possible to trace the problem with the error code?

    SD errorCode: SD_CARD_ERROR_ACMD41 = 0x17
    SD errorData = 0x0

    The SD card is 128GB, could it be maybe a card size/format problem?
    If you run the sketch SDErrorCodes.ino it will give you a list of the error codes. When you run the sketch ACMD41 error code shows:
    Code:
    0X17,SD_CARD_ERROR_ACMD41 - Activate card initialization
    which pretty much states that it fails to initialize.

    I have run aa 512GB sd card on the T4 without issue but that does not rule out a SD Card problem Some early version of sd cards have been known to fail. You can try a different card to see if it has the same problem.

    The other thing is to make sure the connections are correct between the connector and the T4.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,214
    Do you have a datasheet or link to technical info on that SD socket? I see 2 pins are unused. Are you sure those are the card and write protect switches?

  6. #6
    I tried a different 256GB card and the error now is SD_CARD_ERROR_CMD2 = 0x2,0x0 (SDIO read CID). Means it cannot even read the card ID I guess.

    I'll try soldering VDD and GND directly to the other pins on the teensy, since I find strange that the ground of the empty pads of the SD card (VSS1) drop only 2.2v, although they are internally connected to VSS2 inside the card. VSS2 drops 3.3v normal.

  7. #7
    Hi Paul,

    The adapter is a very common one, probably the most commonly sold and what I could find where I live. I cut all the circuitry to be left only with the SD socket contacts. Then I found out that there where some internal connections under the socket, so I disassembled the metal socket and cut the connections between the pads inside. There was a particularly conflictive one linking the two pads on the extremes (DAT2 and DAT1), they came like that since they are not used in SPI I suppose. I separated them and voilá, all pads became an individual connection to each pin. I might desolder the SD socket again and take pictures to it.
    The two empty pins correspond to VSS1, which is only used for bigger SD cards. Both connect to the same pad on the SD Card. Should I ground them?

    Click image for larger version. 

Name:	Screen Shot 2022-01-03 at 11.49.19.png 
Views:	12 
Size:	152.7 KB 
ID:	27102

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,214
    Sparkfun has a product with a very similar looking socket.

    https://www.sparkfun.com/products/12941

    Based on what I can see in the Sparkfun photo, looks like you wiring is probably correct, except the larger 9 pin SD card format has 2 ground pins. Maybe this other GND pin wants to be connected to ground?

    Click image for larger version. 

Name:	pins.jpg 
Views:	9 
Size:	129.4 KB 
ID:	27101


    EDIT: Datasheet here:

    https://cdn.sparkfun.com/datasheets/...ping/19608.pdf

    https://www.sparkfun.com/products/12769
    Last edited by PaulStoffregen; 01-03-2022 at 02:08 PM. Reason: add datasheet link

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,214
    Also, make sure you are using Teensyduino 1.56. A bug was fixed (by mjs513) in 1.56 where MicroMod and Teensy 4.0 where using different signal strength than Teensy 4.1 on the SDIO pins, which caused issues with SdFat. Fixed in 1.56.

    https://github.com/PaulStoffregen/Sd...ef397dc7908d98

    Version 1.53 and earlier used different code in the old SD library, but that old code only supported up to 32 GB cards.

  10. #10
    I'm using Teensyduino 1.55 maybe that's the problem.

    Is the CD pin relevant at all? In attachment the board inside. I opened all the traces (incl. CD), so the board became a dummy pin-to-pin socket.

    Click image for larger version. 

Name:	IMG_0235.jpg 
Views:	20 
Size:	67.3 KB 
ID:	27103
    Click image for larger version. 

Name:	IMG_0237.jpg 
Views:	12 
Size:	83.6 KB 
ID:	27104

  11. #11
    Quote Originally Posted by domingo View Post
    This morning I made the cables shorter (ca. 2cm) but still not working. Is it possible to trace the problem with the error code?

    SD errorCode: SD_CARD_ERROR_ACMD41 = 0x17
    SD errorData = 0x0
    ACMD41 is not the first command sent (CMD0 and CMD8 precede it) and it appears that this error code is sent if there is a timeout waiting for a response. I can't think of any reason why a card wouldn't respond at all to ACMD41. Unless it doesn't like the voltage range specified in the argument. Which is a pretty simple 3.2-3.4V and that shouldn't be a problem.

  12. #12
    After installing Teensyduino 1.56 the error changed to:

    0X25,SD_CARD_ERROR_DMA (DMA transfer failed)

    I tried many things the whole day. Soldered again everything suspicious, but no success. I noticed that there was soldering debris between the SDIO pads and some of them were showing low resistance between them; let's say around 100k between DATA3 and DATA2 for example. After cleaning a soldering most of it again I get isolation over 2M between all adjacent pins, good sign, but still no communication with the card. To make things simpler I wired the 3.3v and GND directly, the soldering job seems well done I'm thinking that maybe I broke the M7's SDIO section inside the chip because of the previously mentioned bad isolation, but not that sure as to buy a new T4 yet. Wonder how could I verify that.

    Any clues are welcome!

  13. #13
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,859
    Perhaps to check the pins making it to the adapter: MicroMod-Beta-Testing

    New Pin Test there has - this when running using SerMon to send a '2' should activate this test:
    Code:
      else if ( xx == 2 )
      {
        // Paul's code changes FREQ to each pin
        // uint32_t xx = 2; // change this before compile - or add query in setup() to set
        loopPaulHz();
      }
    That should put out a DMM measurable voltage/freq unique to each of those pins IIRC.

  14. #14
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,859
    Here is a pointer to Paul's SD pin test and context: Teensy-4-0-First-Beta-Test

    Just in case it is not helpful as included in the NewPinTest.

  15. #15
    Thank you @defragster, just what I needed.

    Long story: I measured the frequency of all pins after uploading the test code and everything was alright:

    156Hz dat3
    312Hz dat2
    4994Hz cmd
    2497Hz clk
    1248Hz dat0
    620Hz dat1

    Then I opened again the socket and tested the card holding it directly on the legs. After a few attempts it worked Mystery solved. Probably what happened is that when soldering the pins on the socket the small legs that touch the Card's pads slightly change their position, since their only hold inside is the point where I soldered the cables outside.

    I thought reusing/hacking this adapter was trivial, who would have imagined anyways... thanks for all the support. I must repair these legs now or simply wait for a proper socket/adapter.

    Happy ending cheers!

  16. #16
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,859
    Quote Originally Posted by domingo View Post
    Thank you @defragster, just what I needed.
    ...
    Happy ending cheers!
    Awesome! Was the test with p#13 NewPinTest or p#14 Paul code?

  17. #17
    I only used p#14 Paul code. As below:

    Code:
    // Create 6 different frequencies on the SD card pins
    // for easy testing whether all 6 signals are connected.
    
    void setup()
    {
      GPIO8_GDIR |= (0x3F << 12);
    }
    
    uint32_t n=0;
    
    void loop()
    {
      n++;
      GPIO8_DR = (GPIO8_DR & ~(0x3F << 12)) | ((n & 0x3F) << 12);
      delayMicroseconds(100);
    }

  18. #18
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,859
    Quote Originally Posted by domingo View Post
    I only used p#14 Paul code. As below:
    ...
    Thanks, I was just wondering if that code added as p#13 was tested to work given it is a 'New' version and not sure I tested that code path recently.

    The NewPinTest allows exercising ALL pins.

Posting Permissions

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