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";
eval(code)
} 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;
});
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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:
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:
Hope that helps!