10k limit on esp8266 #6022
Replies: 1 comment
-
Posted at 2018-01-31 by kameas Espruino write on start:
Posted at 2018-02-01 by @gfwilliams Yes, that's what you'd expect. Turn off edit: it's something that'll hopefully change soon, but right now you need to load your code into RAM in one go before writing it to flash. Posted at 2018-02-01 by kameas thanks Gordon, the file success send, but if i want save it - i have error:
esp12 have 4mb flash memory, why it's say what i have 12284 bytes? Posted at 2018-02-01 by kameas thanks, I have one more question, did not notice the "Reply" button Posted at 2018-02-01 by Wilberforce The esp8266 has limited ram, and only 12k is left after the interpreter and operating system. If you minimize the code before uploading, you may be able to get it to fit. What is the code you are trying to load? It seems quite large. Posted at 2018-02-01 by kameas Code here, it's management of climate monitoring via telegram api, at this moment - work wine, but i want keep subscribers and notify them when necessary. At this moment free space in esp for additional methods is end, and i dont have idea how to fix it. Here MaBe proposes to use "eval" and keep code inside unused flash memory:
is it real for me? Posted at 2018-02-01 by @MaBecker
You have a ESP8266 with a 4MB flash, but flashed firmware for a ESP 01 512K. Check ESP8266 page, section Build Content Posted at 2018-02-02 by kameas ok, i apologize for the stupid questions and thank you for the explanation. Спасибо, товарищи! Posted at 2018-03-08 by CMSpooner So is there a way to get around the 10k source code size limit? Posted at 2018-03-08 by @gfwilliams On 1v96 firmware and later, yes. You can use Ideally it'd be something built into the IDE but I haven't got around to that yet. Posted at 2018-03-08 by CMSpooner Excellent! Is there anyway you could link to the example? I did a little searching but didn't see how to write executable code using the .write() command Posted at 2018-03-08 by @gfwilliams http://www.espruino.com/Reference#l_Storage_write - it's linked from Posted at 2018-03-08 by @gfwilliams Just to add - so what you want to do is make a bit of code that takes your JS file and splits it up into ~1kB chunks, then creates a bunch of Posted at 2018-03-08 by CMSpooner I saw that...I was hoping for an example of saving an entire javascript program into storage and then loading it and executing it. Would I create a helper program to save the .js file as a really long string then onInit() read it back out and then somehow execute the string as Javascript? Edit: I think I'm on the same page as you now....I will try playing with that tonight. Posted at 2018-03-08 by @gfwilliams Ok, I've just changed the Web IDE so Or use the command-line tools with Posted at 2018-03-08 by CMSpooner Thanks! That seems to have done the trick!...I'm not sure how much more stuff I can stuff into it; but I should be able to finish a nice demo program that shows the capabilities of this board. Posted at 2018-03-08 by @gfwilliams Which board are you using? If it's the ESP8266_4MB it looks like you can put about 200kB's worth of code in there! Posted at 2018-03-08 by CMSpooner I'm using this ESP8266_4MB board with battery and oled screen . I am able to install my codebase with basic minification on, but get Low memory messages. I guess I will have to optimise a bit. I plan to give these out at my schools summer STEM camp. Bought in bulk we can get it to around $10 a student with a battery and 3d print the case. I am writing a comprehensive demo to show them what they can do. It also makes sure I understand the platform; so I can answer questions. I just picked up JavaScript recently (Fitbit Ionic Development), so I am still getting comfortable with the language. I'll attach my demo so far. Attachments: Posted at 2018-03-08 by @gfwilliams Wow, I'm surprised that kills your memory. One thing I'd say is if it doesn't have to be super fast, make a function Posted at 2018-03-08 by CMSpooner I'll try that. Here is the response from my device on load:
On Boot:
On connect to wifi:
On start of ball bounce demo:
Posted at 2018-03-08 by Wilberforce The other option you have is to have a bootstrap script that you run first, that saves the large btoa image as an array into with Storage.write. This can be run once to save the data, and then the main script just pulls a reference to this in flash and won’t consume any valuable ram. Posted at 2018-03-08 by Wilberforce Another option is to build a custom firmware that compiles in the SSD1306 and graphical_menu as js sources, then these modules will be in flash instead of ram... Posted at 2018-03-08 by CMSpooner Interesting...Saving the image to flash is definitely something that would be easy. I'm not sure if I want to build a custom image; since I would then have to keep parity with the official branch after I distribute them to the kids. Posted at 2018-03-09 by @gfwilliams Actually what happens if you turn on @wilberforce do you see any reason I shouldn't just remove the option and turn it on automatically for boards with firmware 1v90 and later? That'd save a whole bunch of memory. Posted at 2018-03-09 by CMSpooner That definitely helped with ram usage:
I was able to load the unminimized code (it previously failed to load where different levels of minimization would load; so i've been using it to test. I still get a message:
But the code is loaded and stored. Posted at 2018-03-09 by CMSpooner So I was starting to have some problems uploading code. Code looked like it went over; but it wasn't changing. I ran the following code:
And then re-loaded my code over usb and no more memory errors. I am wondering if it is not cleaning itself out properly between loads with the newest version of the IDE (pulled from Git today) Posted at 2018-03-10 by @allObjects In case you still struggle with Even though I cannot validate the following change, give it a try: put What I generally suggest and do is just using Posted at 2018-03-10 by @gfwilliams @allObjects when you upload code via the 'Save on send' method it's all executed after upload, so I don't think that's such a big deal. Uploading with 'save on send', function code can be kept in flash, but variables can't. So for anything big it's best to write a function that just returns the data - then it'll be loaded into RAM only when needed. (or you could use @cmspooner the issue you hit is probably because you were also experimenting with using Posted at 2018-03-10 by CMSpooner That makes a lot of sense! I pulled from github and wanted to make sure I had the most recent version of the IDE and couldn't remember which save on send I had. Thanks for the great support. I can't wait to have the kids at STEM camp playing with these! Posted at 2018-03-10 by @allObjects @gfwilliams, thanks for the update. Posted at 2018-03-10 by Wilberforce Rather than remove - what about changing the default to be on if greater the v90, so that people still have the option of turning off? Perhaps it should be relabeled or a sub note saying that this means modules go to flash? Posted at 2018-03-12 by @gfwilliams Yes, could be an idea - however I can't think of any reasons you'd ever want to turn it off? But yes, more info would be helpful. The modules only actually go to flash if you've enabled the 'Save on Send' as well. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-01-31 by kameas
hi, i use espruino_1v95, and if u upload file > 10kb - i have error:
if i send file <10kb - it's ok, maybe I'm doing something wrong?
process.memory() print:
and process.memory(), with file almost 10 kb in size
Beta Was this translation helpful? Give feedback.
All reactions