You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Mike Mogenson <mi...@gmail.com> on 2022/08/24 01:23:20 UTC

Lua on NuttX blog posts

Hello,

I’ve published two articles about using Lua on NuttX with libuv for asynchronous IO and networking:

https://medium.com/@michael.mogenson/using-lua-on-nuttx-bcc9a39b2814

https://medium.com/@michael.mogenson/using-lua-and-libuv-for-async-networking-on-nuttx-6e4635eeaedc

Re: Lua on NuttX blog posts

Posted by Xiang Xiao <xi...@gmail.com>.
On Sun, Aug 28, 2022 at 1:07 AM Fotis Panagiotopoulos <f....@gmail.com>
wrote:

> Hello Mike!
>
> I have also been using Lua on microcontrollers for many years, with great
> success.
> For The last couple of years I have been running Lua on NuttX, these two
> are great when combined!
>
> Quite recently I tried running the Lua tests suite (
> http://www.lua.org/tests)
> on NuttX, and to my surprise, I got multiple failures.
>
> Some of them are related to issue #6941, but I also got more.
> I even get corruption of the heap in some cases.
>
>
One workaround is to use the toolchain provided libm library before the
problems in builtin math library get fixed.


> Have you tried to run these tests?
> Do they succeed?
>
>
> On Wed, Aug 24, 2022 at 4:23 AM Mike Mogenson <mi...@gmail.com>
> wrote:
>
> > Hello,
> >
> > I’ve published two articles about using Lua on NuttX with libuv for
> > asynchronous IO and networking:
> >
> > https://medium.com/@michael.mogenson/using-lua-on-nuttx-bcc9a39b2814
> >
> >
> >
> https://medium.com/@michael.mogenson/using-lua-and-libuv-for-async-networking-on-nuttx-6e4635eeaedc
>

Re: Lua on NuttX blog posts

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
Oops, sorry I missed this email.

Coroutines is a standard Lua library, included in the official code.
More information here: http://www.lua.org/pil/9.1.html.

I haven't examined the internals of this library yet. It may indeed have
excessive memory requirements, or it may be that the tests are pretty
extreme and exhaustive.
I will have to test a real-life application on an actual MCU, to see what
is actually happening.

But till now, Lua was very polite on my stacks.

On Mon, Aug 29, 2022 at 12:57 AM Gregory Nutt <sp...@gmail.com> wrote:

> One thing that I found odd is the excessive stack usage of the coroutines
> > library.
> > On the simulator I had to set the stack to 1M.
> >
> > I am afraid that this specific library may not be usable on actual MCU
> > systems...
> >
>
> Is this a Linux library?
>
> I have seen this kind of stack usage a few time when code written for Linux
> is ported to NuttX.  Linux code sometimes allocates huge arrays on the
> stack.  This is harmless on Linux since the stack is virtualized and only
> backed by RAM if actually used.  But it can cause catastrophic memory usage
> in an embedded system with a flat address space.
>

Re: Lua on NuttX blog posts

Posted by Gregory Nutt <sp...@gmail.com>.
One thing that I found odd is the excessive stack usage of the coroutines
> library.
> On the simulator I had to set the stack to 1M.
>
> I am afraid that this specific library may not be usable on actual MCU
> systems...
>

Is this a Linux library?

I have seen this kind of stack usage a few time when code written for Linux
is ported to NuttX.  Linux code sometimes allocates huge arrays on the
stack.  This is harmless on Linux since the stack is virtualized and only
backed by RAM if actually used.  But it can cause catastrophic memory usage
in an embedded system with a flat address space.

Re: Lua on NuttX blog posts

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
I spent some time on the weekend hunting down all the issues.
Now all tests succeed.

The only real "bugs" were issues #6941 & #6945, which I hope to fix soon.
The rest were mostly configuration problems.

One thing that I found odd is the excessive stack usage of the coroutines
library.
On the simulator I had to set the stack to 1M.

I am afraid that this specific library may not be usable on actual MCU
systems...

On Sat, Aug 27, 2022 at 8:40 PM Xiang Xiao <xi...@gmail.com>
wrote:

> On Sun, Aug 28, 2022 at 1:07 AM Fotis Panagiotopoulos <f.j.panag@gmail.com
> >
> wrote:
>
> > Hello Mike!
> >
> > I have also been using Lua on microcontrollers for many years, with great
> > success.
> > For The last couple of years I have been running Lua on NuttX, these two
> > are great when combined!
> >
> > Quite recently I tried running the Lua tests suite (
> > http://www.lua.org/tests)
> > on NuttX, and to my surprise, I got multiple failures.
> >
> > Some of them are related to issue #6941, but I also got more.
> > I even get corruption of the heap in some cases.
> >
>
> For heap failure, I would suggest you:
>
>    1. Run the test on sim with CONFIG_SIM_ASAN and CONFIG_SIM_UBSAN
>    2. Run the test on real device with CONFIG_MM_KASAN, CONFIG_MM_UBSAN and
>    CONFIG_STACK_CANARIES
>
>   and fix the possible errors reported by these tools.
>
>
> > Have you tried to run these tests?
> > Do they succeed?
> >
> >
> > On Wed, Aug 24, 2022 at 4:23 AM Mike Mogenson <
> michael.mogenson@gmail.com>
> > wrote:
> >
> > > Hello,
> > >
> > > I’ve published two articles about using Lua on NuttX with libuv for
> > > asynchronous IO and networking:
> > >
> > > https://medium.com/@michael.mogenson/using-lua-on-nuttx-bcc9a39b2814
> > >
> > >
> > >
> >
> https://medium.com/@michael.mogenson/using-lua-and-libuv-for-async-networking-on-nuttx-6e4635eeaedc
> >
>

Re: Lua on NuttX blog posts

Posted by Xiang Xiao <xi...@gmail.com>.
On Sun, Aug 28, 2022 at 1:07 AM Fotis Panagiotopoulos <f....@gmail.com>
wrote:

> Hello Mike!
>
> I have also been using Lua on microcontrollers for many years, with great
> success.
> For The last couple of years I have been running Lua on NuttX, these two
> are great when combined!
>
> Quite recently I tried running the Lua tests suite (
> http://www.lua.org/tests)
> on NuttX, and to my surprise, I got multiple failures.
>
> Some of them are related to issue #6941, but I also got more.
> I even get corruption of the heap in some cases.
>

For heap failure, I would suggest you:

   1. Run the test on sim with CONFIG_SIM_ASAN and CONFIG_SIM_UBSAN
   2. Run the test on real device with CONFIG_MM_KASAN, CONFIG_MM_UBSAN and
   CONFIG_STACK_CANARIES

  and fix the possible errors reported by these tools.


> Have you tried to run these tests?
> Do they succeed?
>
>
> On Wed, Aug 24, 2022 at 4:23 AM Mike Mogenson <mi...@gmail.com>
> wrote:
>
> > Hello,
> >
> > I’ve published two articles about using Lua on NuttX with libuv for
> > asynchronous IO and networking:
> >
> > https://medium.com/@michael.mogenson/using-lua-on-nuttx-bcc9a39b2814
> >
> >
> >
> https://medium.com/@michael.mogenson/using-lua-and-libuv-for-async-networking-on-nuttx-6e4635eeaedc
>

Re: Lua on NuttX blog posts

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
Hello Mike!

I have also been using Lua on microcontrollers for many years, with great
success.
For The last couple of years I have been running Lua on NuttX, these two
are great when combined!

Quite recently I tried running the Lua tests suite (http://www.lua.org/tests)
on NuttX, and to my surprise, I got multiple failures.

Some of them are related to issue #6941, but I also got more.
I even get corruption of the heap in some cases.

Have you tried to run these tests?
Do they succeed?


On Wed, Aug 24, 2022 at 4:23 AM Mike Mogenson <mi...@gmail.com>
wrote:

> Hello,
>
> I’ve published two articles about using Lua on NuttX with libuv for
> asynchronous IO and networking:
>
> https://medium.com/@michael.mogenson/using-lua-on-nuttx-bcc9a39b2814
>
>
> https://medium.com/@michael.mogenson/using-lua-and-libuv-for-async-networking-on-nuttx-6e4635eeaedc