Save function not working on BBC micro:bit

Posted on
  • Hi Gordon,

    Calling the save() function seems to crash my microbit. Is that function going to be supported soon?
    (I'm using espruino_1v85.30_microbit.hex)

    Thanks
    David

  • Does it work on the normal 1v85 version? It should be supported, in fact I used it on a build myself yesterday.

  • Nope it crashes my mb on that version too. Note: I'm sending commands over bluetooth and dump() and reset() work fine.

    Sorry I put this post in the wrong category (News). Feel free to delete it.

  • I'll move the post... Can you see if it works fine when you type save() when connected over USB? It could be related to the bluetooth connection

  • I've not managed to get a connection over USB so far. How do you do it?

    (The device never shows up when I click on the connect icon but normal Espruinos work fine)

  • How did you get a hold of a micro:bit?

  • I got them from the BBC. I'm the creator of DroidScript and a STEM ambassador, so I managed to get a couple early :) DroidScript has a free plugin for the micro:bit which can be used right now.

    See here for instructions:- microbit-js.org

    Microbits are going out to a million school kids starting this week, so the UK will be flooded with them soon. You will also be able officially to buy them at some point too.

  • What OS are you using? Windows? It looks like you need to install mbed's drivers - I should update the readme to include that.

  • Yep, Windows. Thanks, those drivers did the trick :)

  • OK, save() works over USB but not over BLE for me. Perhaps it is something to do with the save() function needing to wait for idle or something?

  • I'll take a look - what actually happens?

    It could just be that when it resets, it moves the console back to Serial. What if you disconnect from BLE and reconnect - can you then access it again?

  • Just checked, and that seems to be the issue - I'll get a fix in for that now...

  • To check - are you using one of the 'latest' builds? Not 1v85?

    It's looking like this might be related to the recent 'boot code' additions - even without BLE, saving twice seems to cause issues.

  • I just fixed some problems in the latest build, but there still seems to some big problem with writing to flash while BLE is connected...

    So even E.setBootCode('console.log("Hello")') (which doesn't involve a restart) will fail when there is a BLE connection, even if done via the serial console :( Not sure what's up...

    edit: in fact it appears to be something related to the chip - merely erasing a page of flash memory (which works fine when BLE is not connected) causes the device to reset when it is. I've contacted Nordic and hopefully I'll be able to find out what's happening soon.

  • OK, thanks for looking into this Gordon. This is pretty important for our plans with DroidScript.

  • A pretty big hack for now would be:

    setTimeout("save()",1000);
    // disconnect immediately
    // wait 3 sec
    // reconnect
    
  • Hi Gordon, actually that is one of the first things I tried, does that work for you on 1v85, because I could not get that working when I tried it.

  • It's fixed in the latest builds now (it might take a few minutes to update).

    Turned out to be a bit of a nightmare - it was the Nordic code complaining, as it wants to make sure it doesn't turn the radio on while using flash memory - I guess because it draws too much power.

  • Great, thanks Gordon :)

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

Save function not working on BBC micro:bit

Posted by Avatar for user63222 @user63222

Actions