• 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();
        clearInterval(intval);
        LED1.reset();
        Terminal.println("worked after: " + counter + " times");
      } catch (error) {
        
        counter += 1;
        
        if (counter%2 == 0){
          LED1.set();
        } else {
          LED1.reset();
          }
        
        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
About

Avatar for cozezien @cozezien started