lua-users home
lua-l archive

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


Hi,

we have successfully compiled Lua 5.3 for an embedded ARM Cortex-M4F with the following hints:

Remove lua.c and luac.c (no need for interpreter and compiler) and just use the C-API (described in the later chapters of the book).

Your base entry-point is luaconf.h.
However, a few items can (should?) be modified directly in the source:

If you are not requiring all libraries - you just have to comment out the respective lines in (linit.c).
You can also remove / uncomment several functions not needed from specific libraries (just follow the variables from here).

For the unresolved symbols:
To use math, you have to link the math library ("-lm" with gcc).
Probably you encounter a missing symbol for _gettimeofday - which is weakly defined in time.h.
It is used by the os_lib and by "luai_makeseed" in (lstate.c).

Either you provide your own version of this function (see below) or you remove os_lib (which you usually don't need on embedded controllers).
We have a RTC so we just provide the current time to Lua:

int _gettimeofday(struct timeval *tv, struct timezone *tz) {
    tv->tv_sec = RTC_seconds();
    tv->tv_usec = RTC_us();
}

-Benjamin


-----Original Message-----
From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On Behalf Of Marc Scherer
Sent: Wednesday, April 12, 2017 12:01 PM
To: lua-l@lists.lua.org
Subject: lua without OS calls for embedded systems

Dear all,

I am trying to compile lua with the Renesas gcc 4.8.4 toolchain in e2Studio (eclipse) for RX600 controllers and it fails with optilib instead of newlib as standard library due to missing functions.

Also with newlib in debug mode I am getting linker errors about missing symbols.

I only need math functions to do some scriptable operations, where the script would be passed to lua as C-string.

My understanding is that for math scripting I would not need any operating system related functions.

Is there documentation describing the changes needed for lua to take away the OS calls, i.e. to make it independent from any operating system?

Or how to strip unused code parts/modules from lua in general?

Thanks,
Marc