• Hi all,
    I made this small WebIDE plug-in to use the plenty of flash pages of the ESP8266 and upload then execute easily modules there, and have more memory free for other use. I use it every day, as my programs always need more memory and getting bigger than the default space of 10kb. You can minify and transfer modules into pages, in one click, and then link them to be executed from flash, in another. As extra you can also load/unload modules direct to memory, etc. It mainly allows to use tve FlashString.js, without the hassle of manual commands and minification (mentioned in http://forum.espruino.com/conversations/­290975/). Be careful, the execution from flash and use of E.memoryArea is restricted to the first mb, so you can use it only on the 44kb(11 pages) under 1mb. I use Wilberforce FlashStore module for the 3mb left (http://forum.espruino.com/conversations/­283045/).

    My code is based on the Project plug-in, here is it (messily programmed I am afraid but works well).
    https://github.com/popok75/Espruinuity/b­lob/master/Espruino-WebIDE/js/plugins/fl­ashView.js

    It uses a modified version of tve FlashString.js . Here is this version : https://github.com/popok75/Espruinuity/b­lob/master/EspCode/project/modules/Flash­String.js
    also you may want the stand-alone loader : https://github.com/popok75/Espruinuity/b­lob/master/EspCode/project/modules/Flash­StringLoader.js
    You want FlashString.js to be in modules directory when you start, so that you can transfer it to memory and start using your flash.

    For installation, you can get my version of WebIDE from the github (fetched 2 month ago) or you just need the source of WebIDE, add the source of espruino-tools in the right directory, flashview.js in plugin directory, and insert the following statements at the right place (not sure they are all needed) : https://github.com/popok75/Espruinuity/s­earch?utf8=%E2%9C%93&q=flashview&type=

    Here is how I load them in the final program :

    function loadFlashModules(mods,loader) { // load module and show mem usage
    	var sm=0;
    	for(var i=0;i<mods.length;i++){var mod=mods[i];
    	if(Modules.getCached().indexOf(mod)>-1) Modules.removeCached(mod);
    	var m=require(loader).load(mod+".js");
    	if(!m)  {print("Module not found in flash : "+mod);return false;}
    	else {
    		var s;
    		s=process.memory().usage;	
    		Modules.addCached(mod,m);
    		sm+=(process.memory().usage-s);print("Mo­dule in flash loaded: "+mod+" : "+(process.memory().usage-s)+" block mem usage");}
    	}
    	print("All Modules : "+sm+" block mem usage");
    	return true;
    }
    
    
    function init(){
    	l=loadFlashModules(["WifiSync","DHT22non­","FlashStore","IOPlug","IOLog","IOData"­,"IOServer"],"FlashStringLoader");
    }
    

    I hope you'll try it and tell me what you think.


    1 Attachment

    • flashview.jpg
About

Avatar for Polypod @Polypod started