[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: PANIC: unprotected error in call to Lua API (math)
- From: "Leinen, Rick" <RLeinen@...>
- Date: Fri, 9 May 2014 16:56:25 +0000
Phillipp,
I see what you mean with lua_pcall, I will try it. The elua patch is a great idea. Thanks for suggesting.
Rick
-----Original Message-----
From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On Behalf Of Philipp Janda
Sent: Thursday, May 08, 2014 11:15 PM
To: lua-l@lists.lua.org
Subject: Re: PANIC: unprotected error in call to Lua API (math)
Am 09.05.2014 02:50 schröbte Leinen, Rick:
> Greetings,
Hi!
>
> While I have some experience writing lua scripts, I am new to implementing lua on a hardware platform. I am trying to implement lua on a Freescale Tower with a Kinetis K65 microcontroller. It has 2 MB of flash and 256 KB of SRAM on board. I have successfully built a project using IAR's ARM IDE using one of the Tower's simple demo projects as a launching point.
>
>>From main(), the project successfully runs the following line of code:
>
> lua_State *L = luaL_newstate();
>
> Next, the code attempts to open the lua libraries with this line of code:
>
> luaL_openlibs(L);
>
> It makes as far as the math library when the following is sent out the serial port from lua:
>
> PANIC: unprotected error in call to Lua API (math)
>
> Anyone have any ideas to help resolve this?
>
As Rena said, probably a memory allocation issue (although 256K should be plenty). If you have a look at the source of `lua.c`, you will see that the first thing after `luaL_newstate` is a call to `lua_pcall` to avoid such unprotected errors in case of allocation failures. This should at least give you a more useful error message.
If this really is a memory problem, you might also want to have a look at elua[1] which includes a patch[2] to store module tables readonly in ROM instead of RAM to save memory. Elua has a port[3] for Kinetis which you could use as a starting point (Elua is Lua 5.1, though) ...
> Thanks,
>
> Rick
>
Philipp
[1]: http://www.eluaproject.net/
[2]: http://www.eluaproject.net/doc/v0.9/en_arch_ltr.html
[3]: http://wiki.eluaproject.net/Boards#ARM_Cortex-M4