• I've been able to get an SD card to work on my pixl, but I'm having trouble to get the initialization process to be consistent. Sometimes the card will start to work within a few seconds (rare) and other times I've left it for about 30 minutes (or overnight) and it still doesn't initialize properly. Once initialized as long as I don't turn the pixl off/on it will work and I can read/write OK.

    I'm using a Sandisk 16GB microsd and I've soldered connectors for a microsd->SD card adapter as per https://www.espruino.com/File+IO

    the error I get when trying to reddir is:

    Uncaught Error: Unable to mount media : NOT_READY
    at line 1 col 27

    things I've tried:

    1. trying different microsd cards
    2. Pull-up resistors on the CS pin (1k,2.7k, 3.7k, 4.7k,16k,50K, 76K) - I haven't noticed any difference / improvement from using the pull up resistors
    3. manually running the initialization/reddir function in the left side of the interface when connected to the card

    I've come up with a simple oninit function that will iterate through trying to get the card to work:

    function onInit() {
    SPI1.setup({miso:A0,sck:A1,  mosi:A2, baud: 1000000 });
    E.connectSDCard(SPI1,A5 /*CS*/);            
    counter = 0;
      intval = setInterval( function () {
      try {
        let directories = require("fs").readdirSync();
        Terminal.println("worked after: " + counter + " times");
      } catch (error) {
        counter += 1;
        if (counter%2 == 0){
        } else {
        if (counter%15==0){
          Terminal.println("tried: " + counter + " times");
      }, 1000);
    Terminal.println("Initializing SD card");

    I've attached a few pictures to show my setup (3 resistors with ~75K ohm). Perhaps I've wired something up wrong?

    Any other suggestions on how I could troubleshoot this? Sadly I don't have an oscilliscope or that sort of thing for analyzing data lines etc

    2 Attachments

    • PIXL_connector.jpg
    • Pull-up resistors.jpg
  • So it's something to do with the MISO connector. No resistor seems to be needed either. Will need to investigate more

  • I'll go with some electro mechanical issue... It could easily be that the soldering of wires onto the card contacts may have caused it. Could a partially dead solder point be the culprit?

  • I was considering that, but after much experimentation with the pins I've been able to get it to work better. In the images (and code) you'll see I'm using the A* header for connections. I found that the MISO pin seems to have an issue in the A* header. If I nudge the pin while it's in the A* header the card will initialize immediately (the nudge might temporarily disconnect it?).

    If I move the MISO pin in the D* headers it will not need any nudge etc for it to work on the first/second try

    Is there something special about the A* headers as compared to the D* header? I'm not sure why it would behave differently.

  • Is there something special about the A* headers as compared to the D* header?

    Not really. The A* are analog capable pins, but they should have just the same drive currents and tolerances as other pins.

    But if the pin needs a nudge then it does just sound like an electromechanical issue

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Trouble getting SD card to initialize consistently

Posted by Avatar for cozezien @cozezien