... save some low-level modules that are stable to make more space for my own code
The issue is that if you save Modules.addCached("...","...") using setBootCode then it's a string, so any functions defined in it can't be kept in flash. You could do something like this:
In reality you want a little more fudging, as for some modules you need the global variable 'module'.
I guess it might make sense for the Web IDE to automatically do that instead. Even without saving to flash it's actually more efficient, as the module code can be loaded straight from the input string (so needs less memory and time during the upload).
To be honest I'm not sure why it didn't do that from the beginning.
And when I now upload my_project.js the module registry gets cleared anyway, right?
Yes, Modules.removeAllCached() get called (this could probably just not be sent now, as reset() is usually called before anyway). Nothing stops you from doing Modules.removeAllCached=function(){}; to disable it though.
have you thought about how a target like the esp8266 could use a different bigger flash area for the setBootCode?
Could you not just change the location used for saved code to one that was bigger? That would be by far the easiest way.
I mean, sure, you could add some kind of filesystem, but it's probably not worth the effort.
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.
The issue is that if you save
Modules.addCached("...","...")
using setBootCode then it's a string, so any functions defined in it can't be kept in flash. You could do something like this:In reality you want a little more fudging, as for some modules you need the global variable 'module'.
I guess it might make sense for the Web IDE to automatically do that instead. Even without saving to flash it's actually more efficient, as the module code can be loaded straight from the input string (so needs less memory and time during the upload).
To be honest I'm not sure why it didn't do that from the beginning.
Yes,
Modules.removeAllCached()
get called (this could probably just not be sent now, asreset()
is usually called before anyway). Nothing stops you from doingModules.removeAllCached=function(){};
to disable it though.Could you not just change the location used for saved code to one that was bigger? That would be by far the easiest way.
I mean, sure, you could add some kind of filesystem, but it's probably not worth the effort.