delete data from flash in MDBT42?

Posted on
  • Hello ,
    as I understadn I can use about 40kb~ of memory in the MDBT42
    I have code that save into RAM and then move it to the flash

    require("Storage").write("test",JSON.str­ingify(ScanResault));
       GetData = JSON.parse(require("Storage").read("test­"));
       ScanResault.length=0;
       console.log("Clear Array finsih");
       console.log(    ScanResault.length);        
    

    I can see the RAM is clear without a problem
    then I send this information to another devcie and after a while I want to clear the flahs
    but I'm unable to do this
    this is the command I'm using :

    require("Storage").erase("test");
    

    but it doesn't work

    why?

  • Using require("Storage").erase("test"); sounds absolutely fine. When you say 'doesn't work' what do you mean? It just doesn't appear to get rid of the file, or it gives you an error?

    Are you using firmware 2v05?

  • doesn't get rid of the file

    just to be sure - wher do I see the version?

  • wher do I see the version?

    If you just type reset() on the left hand side of the IDE you should see it under the logo - or process.env will tell you too.

  • VERSION: "2v04", GIT_COMMIT: "3956264e", BOARD: "MDBT42Q",
    FLASH: 524288, RAM: 65536, SERIAL: "3700071-fa641234", CONSOLE:
    "Serial1", MODULES: "Flash,Storage,hea" ... "S,crypto,neopixel",
    EXPTR: 536882364 }

    var res=process.memory();
     console.log("Memory free - " + res.free);
     if(res.free<2000)
     {
       LED1.write(true);
       console.log(ScanResault);
       require("Storage").write("Test",JSON.str­ingify(ScanResault));
       console.log("write");
       GetData = JSON.parse(require("Storage").read("Test­"));
       console.log("JSON.parse");
       ScanResault.length=0;
       console.log("Clear Array finsih");
       console.log(ScanResault.length);
      }
    

    when I run the code
    I get error that

    Uncaught Error: Unable to find or create file
     at line 35 col 63
    ...JSON.stringify(ScanResault));
                                  ^
    in function called from system
    > 
    

    but when I run list I can see the file

    console.log(require("Storage").list());
    [
      "Test",
      ".varimg"
     ]
    =undefined
    

    maybe this is my problem?

    and how could it be ?

  • As a first step, please could you try installing up to date firmware? Looks like you're on 2v04 and there is 2v05 which has a fix for some storage related issues

  • I need to be neat the device fot this - I see
    I will do it latter and let you know
    thank you Gordon !

  • sorry, the firmware update has failed.

    The error was: TypeError: Failed to execute 'requestDevice' on
    'Bluetooth': required member filters is undefined.

    Please try again, or check out the Troubleshooting page for what to do
    next.

    I download the zip file - espruino_2v05_mdbt42q.zip
    in the IDE selected
    FLASHER
    Advanced Firmware Update
    selected the file
    did what the message said
    now the device red led is on
    but I still get the error
    what is wrong?

  • Are you on Mac OS? Please could you try uploading firmware using the instructions at http://www.espruino.com/MDBT42Q#firmware­-updates (so using the nRF Connect app on Android/iOS instead)

  • Using WIndows7
    don't have MAC or android device here

  • Windows 7 doesn't even support Web Bluetooth I'm afraid, so the firmware updater built into the IDE won't work.

    Do you have an iOS device available? Or do you have no smartphone/tablet that can be used at all?

  • yes I do
    tablet with android 7 - will this works?

    I have also have a computer with win10 - better?

  • tablet with android 7 - will this works?

    Yes, that'd be perfect. Just use that to do firmware updates.

    I have also have a computer with win10 - better?

    That would be better for doing development, as you could use the online IDE at https://www.espruino.com/ide/

    However for firmware updates the Android devices are actually faster

  • OK
    update the firmware to 2.05
    now how to continue?

    Thanks,

  • Try require("Storage").eraseAll() to clear Storage to a fresh state - then see if you still have the problem?

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

delete data from flash in MDBT42?

Posted by Avatar for David1234321 @David1234321

Actions