Flash module missing?

Posted on
  • Hi All,

    I updated my Puck to v1.94 today and was reloading the software when I got a warning message "Module Flash not found".

    I'm using the FlashEEPROM module to persist some data to flash, but FlashEEPROM has require("Flash") which doesn't exist at the URL the Web IDE looks for modules. (https://www.espruino.com/modules)

    Has the Flash module been deprecated/removed? If so, is there something new for persisting small amounts of data across battery changes?

    Cheers
    Dave

  • I think most likely it would have just been some slight communications issue (either Bluetooth, or Internet) when the Web IDE connected to Puck.js.

    Basically when the IDE connects it asks the device what it is - then it can look online and find out what modules are built in to that device, so it knows what it needs to load in and what it doesn't.

    If there's some issue with that then the IDE won't know, and will try to load modules that are actually built in. The code will all still work - it's just that you get the yellow warning in the IDE.

    To fix it, all you'd need to do is disconnect and reconnect so the IDE can figure out it's talking to a Puck.js. The next upload after that should be fine.

  • Thanks Gordon,
    That got rid of the warning but the variable I create from FlashEEPROM module is now undefined so it crashes at runtime.

    Uncaught TypeError: Expecting a number or something iterable, got undefined
     at line 226 col 31
    var str = E.toString(f.read(0));
                                  ^
    in function "readBeacon" called from line 577 col 14
      readBeacon();
                 ^
    in function called from system
    

    f is created by

    var f = new (require("FlashEEPROM"))();
    

    Is the Flash module supposed to be built into the firmware? Should I try reflashing.

    Cheers
    David

  • Please can you try just uploading:

    var f = new (require("FlashEEPROM"))();
    print("EEPROM",f.read(0));
    

    Which would help to see if it's something in your code, or something else?

    Also, maybe check if somehow Reset before Send got unchecked in the IDE's communication settings page?

  • Oh - actually forget that. It's not a problem at all.

    Basically if you have nothing in FlashEEPROM at that location, f.read will return undefined.

    So f.read(0) returns undefined, and E.toString complains because it's given undefined.

    Try:

    var eepromcontents = f.read(0);
    if (eepromcontents!==undefined) {
      var str = E.toString(eepromcontents);
      ...
    }
    

    Or make sure you do f.write(0,"Hello") first to put something in there - but personally it'd be good practice to check anyway.

  • Thanks Gordon, you were correct as usual: the firmware upgrade had done away with the previous data. I added a check for undefined as you suggested and all is well again.
    Thanks very much for your help.

    Cheers
    Dave

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

Flash module missing?

Posted by Avatar for dave @dave

Actions