Issue with Micro:bit saving code

Posted on
  • Hi, If I send code to the device's RAM (2v07.14) then enter save(); I get an error message stating that my code is too big to save to flash.
    The error message doesn't appear when using 2v06.

    The code is simple and is....

    var on = true;
    function setP()
    {
      if (on)
      {
        digitalWrite(D4,1);
        on = false;
       show("1   1\n"+
         "  1  \n"+
         "  1  \n"+
         "1   1\n"+
         " 111 \n");  }
      else
      {
         digitalWrite(D4,0);
         on = true;
        show(0);
      }
    }
    
    setWatch(function() {
      setP();
    }, BTN1, {repeat:true, debounce:20, edge:"falling"});
    

    Details of 2v07.14

     2v07.14 (c) 2019 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    >
    >save();
    =undefined
    Compacting Flash...
    Calculating Size...
    ERROR: Too big to save to flash (2358 vs 2048 bytes)
    Deleting command history and trying again...
    Code is too big to save to Flash.
    

    I've worked out that the code isn't minified on the device.

    Is the ~2k flash for both firmware and code?

    Thanks
    Steve

  • This might help: http://www.espruino.com/Saving

    An image of what's currently in RAM is compressed and written to flash. It looks like right now it's not getting compressed enough to fit in to the 2k reserved for saved code (there's more flash used outside of this for the Espruino firmware).

    Best bet for the moment is to use the IDE's 'save to flash' method, which writes a textual version if your code into flash (rather than trying to image RAM)

  • Thanks @Gordon interesting reading.

    I've tried the 'save to flash' method but get

    >Uncaught Error: Module Storage not found
     at line 1 col 18
    require("Storage").write(".bootcde","var on = true;\nfunctio...
    

    Bizarrely enough the same code that was failing this morning to save() once sent to RAM isn't now erroring.

    Thanks

  • As I mentioned in my reply to your news post http://forum.espruino.com/conversations/354079/#15551980

    I fixed it for you this morning. You just have to download it from http://www.espruino.com/binaries/travis/master/ and copy it on, and then it should work.

  • Hi @Gordon, sorry, bear with me I'm trying to get my head around a number of things.
    I hadn't appreciated that the earlier post was a new version.

    That's done the trick. Flashing now succeeds.
    Steve

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

Issue with Micro:bit saving code

Posted by Avatar for saj42 @saj42

Actions