Well, at the moment your code is executed from flash, but 'executing' here is means that the function declaration is being executed from flash (but then the execution of the declaration loads it into RAM).
While Espruino could store the code in flash directly, if you then did fl.erasePage(...) the whole thing would just stop working - it seemed like a bit of a scary thing to do automatically, especially as E.memoryArea could easily also point to RAM. I guess it could be enabled by default, I'd just be worried about it.
var base = 0x40200000+487424;
var s = E.memoryArea(base, 72);
eval(s);
for (var i in global) {
if (typeof global[i] == "function") {
var f = global[i];
if ("\xFFcod" in f && s.indexOf(f["\xFFcod"])>=0) {
var c = f["\xFFcod"];
f["\xFFcod"] = E.memoryArea(base+s.indexOf(c), c.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.
Well, at the moment your code is executed from flash, but 'executing' here is means that the function declaration is being executed from flash (but then the execution of the declaration loads it into RAM).
While Espruino could store the code in flash directly, if you then did
fl.erasePage(...)
the whole thing would just stop working - it seemed like a bit of a scary thing to do automatically, especially asE.memoryArea
could easily also point to RAM. I guess it could be enabled by default, I'd just be worried about it.So what you could do is:
Or actually you could do some fixup code like:
Not tested, but something like that should work.