You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • I think one of the simplest methods would be to use the extra page of flash as you say and to write a 'bootloader' in JavaScript.

    Something like:

    var addr = 0x08000000 + 384*1024;
    try {
      var code = E.memoryArea(addr+8, peek32(addr));
      var hash = 0;
      for (var i=0;i<code.length;i++) hash += String.charCodeAt(i);
      if (hash != peek32(addr+4)) throw "Bad hash";
    } catch (e) {
      // fallback if the code doesn't load for some reason?

    So the first word is the length, second is a very dodgy hash to try and check that the code is valid (it could/should probably be improved!), and then there's the data.

    This is done from memory though, so may have some bugs I'm afraid.

    You could then use the flash library to write the code when you received/validated it over GSM:

    var f = require("Flash");
    var addr = 0x08000000 + 384*1024;
    f.erasePage(addr); // remove everything
    connection.on('data', function(d) {
      f.write(d, addr);
      addr += d.length;

    Hope that helps!


Avatar for Gordon @Gordon started