Left here for archival purposes.

User avatar
By hamishcunningham
#7237 Hi,

gwizz and I have been hitting a hard limit on code size that triggers chip restart. The problem presents on a chunk of around 8KB.

Probably we're just sucking up all the heap, but I guess it might also be some limitation in how loadfile works -- is this configurable?

To duplicate the problem: https://github.com/hamishcunningham/fishy-wifi/tree/master/code-size-bug

(Copy two files defining a meaningless print function to the ESP; running the shorter one works, but the longer one triggers restart.)

We've verified this on two different modules...

Any ideas?

Cheers

Hamish
User avatar
By gwizz
#7239 I've narrowed the bug down to 137/138 lines for my new olimex dev board.

That's with
Code: Select all> =node.heap()
22968


After restart.

If I clear out my wifi settings then I get some more heap:
Code: Select all> =node.heap()
23400


And now I can get the bug between lines 169/170!

Interestingly, after this my heap is just a little over 8K:
Code: Select all> =node.heap()
8104
User avatar
By jaquinn
#9165 I have run into similar sounding issues. They can be really frustrating because a small code change can break what was working code for no obvious reason.

I am still working on this but did find two interesting behaviours:
1. Splitting the source and using DOFILE to load the "split" part helped a lot.
2. The wifi.sta.getap() function seems to consume about 2k of heap.

I have been trying to put together a basic framework in Lua that provides a setup page (with the ESP8266 running as an AP) to get the device attached to the target network and come other configuration specified and then the operational pages (with the ESP8266 running as a client to the target network).

I was not able to have this all in one lua source file without the restart problem but I am having good results with a main.lua (for the operational page), setup.lua (for the setup), common.lua (common functions shared by both and loaded using DOFILE).

Either setup.lua or main.lua are loaded from init.lua using DOFILE based on a GPIO read to check if the device is physically in "setup mode" which makes it more secure even if it is a hack to work around the memory limitation.
User avatar
By raz123
#9279
jaquinn wrote:I have been trying to put together a basic framework in Lua that provides a setup page (with the ESP8266 running as an AP) to get the device attached to the target network and come other configuration specified and then the operational pages (with the ESP8266 running as a client to the target network).


Seen this? https://github.com/hamishcunningham/fis ... ter/joinme