• @Gordon thanks for this addition. I cloned the latest from Git, compiled it and am testing it out. This is what I see:

    Case 1.1
    A small change to case 1. Instead of DISK_ERR errors I'm getting NOT_READY errors

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v70 Copyright 2014 G.Williams
    
    >var f = require("fs").readFile("test.txt");
    ="hello\n\n"
    
    >E.unmountSD();
    =undefined
    
    // removed card
    
    >var f = require("fs").readFile("test.txt");
    ERROR: Unable to mount SD card : NOT_READY
    =undefined
    
    // re-inserted card
    
    >var f = require("fs").readFile("test.txt");
    ERROR: Unable to mount SD card : NOT_READY
    =undefined
    
    >reset();
    =undefined
    
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v70 Copyright 2014 G.Williams
    
    >var f = require("fs").readFile("test.txt");
    ERROR: Unable to mount SD card : NOT_READY
    =undefined
    

    Case 2.1
    A slight change to case 2. This time a NOT_READY error instead of a DISK_ERR error.

    // fresh restart
    
    >var f = require("fs").readFile("test.txt");
    ="hello\n\n"
    
    >E.unmountSD();
    =undefined
    
    //Removed card and re-inserted without file operation
    
    >var f = require("fs").readFile("test.txt");
    ERROR: Unable to mount SD card : NOT_READY
    =undefined
    

    Conclusion

    Just to check, I just tried 'Case 1' here on the Espruino Board and it works fine - so I'm pretty surprised that yours is different as it's using the same code.

    I guess it may be possible that you didn't do a make clean before building with the filesystem enabled, and that meant that somehow reset() didn't reinitialise the SD card?

    I did forget to do make clean last time but not this time. For me calling reset() still isn't working

    The problem is that jswrap_fs_kill is actually called from reset(), so if that doesn't solve the problem then there's something else...

    I think there has to be something else. Using the very latest Github version, calling E.unmountSD() has only managed to change DISK_ERR errors into NOT_READY errors.

About