lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Sorry for being so insistive, but it would be really VERY interesting
> for me, if I could keep a main part of my loaded Lua code in ROM,
> without need to duplicate it into my "valuable RAM space".
>
> ... E. g. if I want to load a Lua file of ca. 200kB Code data and
> "thrifty data use" of e. g. 20kB Gobal data into Lua interpreter, I
> would be very happy if this works well in a single chip controller
> with 80kB available heap RAM and 300kB available ROM for Lua - this
> really would be super-great....
>
> Restriction to pre-compiled code in ROM is fine for me... .
>
> Any hints, where to start in the Lua source code to accomplish this/
> gain some appreciable amount of "saved heap RAM"?
>

Hi,

You can look into NodeMCU codebase and it's Lua Flash Store patches. They allowed
to run Lua code directly from Flash instead of loading it to RAM first. Those
patches were split into multiple commits so I cannot give you one .patch file
but I think documentation (https://nodemcu.readthedocs.io/en/release/lfs/ and
https://gist.github.com/TerryE/646407100785fb00c2cbddbb0e8a2b61) could be useful
to you.

Link to codebase:
https://github.com/nodemcu/nodemcu-firmware/tree/release/app/lua53

There was also merge request that made it possible to load code from RAM
to Flash directly on MCU, but his work was not finished:
https://github.com/nodemcu/nodemcu-firmware/pull/3272

BTW It's my first time using mailing list ever, sorry for any violation
of email etiquette.

--
Galion