NRF51822 - anyone still using it?

Posted on
  • there is the microbit v1 and there is some thread about NRF51TAG here http://forum.espruino.com/conversations/­320879/ also some fitness tracker attempts here http://forum.espruino.com/conversations/­342982/

    Is anyone still using it?

    Just made a fresh 2.10 build for bare nrf51 module with 16K RAM and found it somehow broken. Also the number of variables in Microbit V1 board file proved to be quite unrealistic, I had to go far below 300 to let webide connect and read board info as the board JSON would not print due to low stack.

    I tried some additional trimming to enable some other features (like native code via inline C or arrow functions to enable button to view storage files in WebIDE - It calls require('Storage').list().forEach(x=>pri­nt(JSON.stringify(x))); ). Again with that complex expression I had to reduce variables even more to 250 to allow even more stack so the JSON.stringify(x) inside that forEach would still produce some data instead of " ... "

    Then with various builds I triggered unaligned jsVars array so it would crash completely at startup with new compact variables code. And when I got it somehow into shape and tried some bluetooth scanning code (NRF.findDevices, NRF.setScan) it again crashed/freezed/disconnected randomly so I noticed that nrf51 code path disables interrupts completely when working with JS variables which the SoftDevice doesn't like. After fixing that, NRF.findDevices would still not work correctly. It triggers low memory condition making console unusable with flood of "interrupted" messages even with simple NRF.findDevices((x)=>print(x),1000) with ~15 devices around. So looked into .data and .bss segment size usage and managed to reduce some usage to go up with variable to current 286 and 8 flash pages for Storage.

    Now pasting simple code like

    E.setFlags({pretokenise:1});
    
    function findDevices(cb){
      var devs = {};
      var nonew=0;
      function add(x){
        if (!devs) return;
        if (x.id in devs) {
          if (++nonew>30) {NRF.setScan(undefined);setTimeout(()=>{­cb(devs);devs=undefined;},0);}
        } else {devs[x.id]=x.name;nonew=0;}
      }
      NRF.setScan(add,{active:true});
    }
    
    findDevices((x)=>print(x));
    

    does not crash or produce console errors and finds all my devices around even when the function is in RAM. But adding any more code pushes it over the edge (like enabling watchdog and kicking it from setInterval). Moving the code to flash would certainly make it better, however not sure whether with ~290 variables I could e.g. draw to small OLED display while also having some bluetooth code there (=51822 fitness tracker usage).

    Anyway, wanted to ask, is anyone still trying to use microbit v1 or any other 51822 device with Espruino? If yes, what use cases still work for you? Maybe some old Espruino versions are better?

    I found there are some cheap 51822 boards on aliexpress claiming to have the QFAC 32K RAM variant so ordered few to test how usable that would be. However the 16K version module I have seems barely usable for any a bit more advanced code.

    EDIT: boards from aliexpress arrived, they have QFAA with 16kB despite description and images claiming QFAC/32kB :-(
    item link removed

  • I think some folks are (or were) using micro:bit firmwares. It did work better in the past, at least for simple stuff using setAdvertising. I think setScan was always a bit flakey though.

    It'd be great to get it back working properly though, if only because I've got a friend with a bunch of micro:bits who wants to build a big display out of them - and it'd be so easy with Espruino if setScan worked ok - but I think you may have fixed that already :)

  • With recent merges nrf51 should have more free ram +488 bytes for recent MICROBIT1 build ~= 40 variables or more room in stack. Also some flash was saved during the process so even stock MICROBIT1 build can have 5 flash pages for storage now.

    I don't have any microbit 1 so can't test but now also the hardware i2c can be removed from the build so current microbit sensor code could use software i2c possibly saving some further tiny bits of ram and flash (and even power?).

    As for my build for generic nrf51 module I am back to using 300 variables and listing and viewing files in storage in WebIDE works :) Also I have 6 pages of storage with some extra features enabled like arrow functions, Inline C, watchdog

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

NRF51822 - anyone still using it?

Posted by Avatar for fanoush @fanoush

Actions