I’m not sure how likely I am to find a solution to my problem(s), but I hope to shed some light for people heading in the same direction as me.
Long story short: Getting Lua running on FreeRTOS on PIC32 has been a huge battle. Here’s what doesn’t work:
A) Using the new C30 libc libraries doesn’t work even with stock Lua (no FreeRTOS). Random crashes.
B) Any floating point operations in the simulator from a FreeRTOS thread. If called before starting the scheduler, they work. After, they return garbage. So… don’t depend on the simulator.
C) Floating point (lua_Number defined to double) Lua from a thread. Even basic operations return garbage. (e.g. 5 * 7 gives 5.5623e-315). They work from main(), but not once the scheduler is started.
D) I should note that I read of another guy porting Lua who mentioned that the debug build broke Lua (w/o an RTOS). I haven’t experienced this, but be warned. Google: “ASKr PIC32 Lua”. He also confirms A)
Here’s what does work:
A) Stock Lua with no FreeRTOS (in simulator, and in debug and release on real hardware) using the legacy libc.
B) Integer Lua (lua_Number defined as long rather than double) from a thread, but only on real hardware.
I’ve tried all the obvious (huge stack, huge heap, etc, etc.), optimizations on the code and libc off, only one thread running throughout, …
-I REALLY don’t want to go with a stock Lua (without FreeRTOS) because of the power of the RTOS and the rich set of drivers I’ve written.
-I REALLY don’t want to go with an integer version of Lua either.
This really took Microchip down a couple pegs in my books. Combining 2 well-written, established pieces of code should not be such a battle, but random issues with Microchip software and libraries have made it so.
Anyone out there with any ideas? Anyone actually get something like this working?