You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Fotis Panagiotopoulos <f....@gmail.com> on 2021/06/09 18:10:37 UTC

Undefined reference to longjmp/setjmp

Hi everyone!

I just started adding Lua to my NuttX-based project, but I have some
problems with it.
I am getting undefined references to longjmp/setjmp.

I am using an STM32F4 and GCC:
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major)
9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]

As I see, this combination of arch and compiler should work for
setjmp/longjmp, so I believe that something is misconfigured on my side.

Is there any special Kconfig option that I am not aware of? Do I need any
special compiler flags?

Re: Undefined reference to longjmp/setjmp

Posted by Gregory Nutt <sp...@gmail.com>.
There is also a configuration option that must be set to use the setjmp 
in NuttX.  It is in the top-level Kconfig as I recall.

You don't get a compilation error so you are probably including the 
toolchain's setjmp.h.  So most likely you have -nostdlib or something 
like that on the command line so that you do not bring in the 
toolchain's C library version of setjmp/longjmp.

On 6/9/2021 12:51 PM, David S. Alessio wrote:
> Hello, Foti,
>
> I wrote setjmp/longjmp for armv7-m some time ago.  The code should be 
> in file:
> arch/arm/src/armv7-m/gnu/up_setjmp.S
>
> If not, it’s attached here.
>
> Cheers,
> -david
>
>
>
>
>
>
>
>
>
>> On Jun 9, 2021, at 11:10 AM, Fotis Panagiotopoulos 
>> <f.j.panag@gmail.com <ma...@gmail.com>> wrote:
>>
>> Hi everyone!
>>
>> I just started adding Lua to my NuttX-based project, but I have some
>> problems with it.
>> I am getting undefined references to longjmp/setjmp.
>>
>> I am using an STM32F4 and GCC:
>> arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major)
>> 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
>>
>> As I see, this combination of arch and compiler should work for
>> setjmp/longjmp, so I believe that something is misconfigured on my side.
>>
>> Is there any special Kconfig option that I am not aware of? Do I need any
>> special compiler flags?
>

Re: Undefined reference to longjmp/setjmp

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
> Hmm, I don't think this is true. You just need to enable `system()` in
configuration

Well... Yes and no...

system() requires NSH, which is part of the apps package.
So, technically, the NuttX kernel does not support it directly.

In my case, there is no NSH, so os.execute had to be removed.
But of course if someone needs this, it is very possible to have it.


Στις Πέμ, 10 Ιουν 2021 στις 10:38 μ.μ., ο/η Maciej Wójcik <w8...@gmail.com>
έγραψε:

> > as NuttX does not support the function system()
>
> Hmm, I don't think this is true. You just need to enable `system()` in
> configuration
>
> http://nuttx-config.nxtlabs.pl/#/?current=SYSTEM_SYSTEM
>
>
> Am Do., 10. Juni 2021 um 17:52 Uhr schrieb Fotis Panagiotopoulos <
> f.j.panag@gmail.com>:
>
> > Regarding Lua.
> >
> > I have been using Lua in MCU environment for many years now.
> > This is the first time to use it along with NuttX.
> >
> > I am using Lua 5.2.4, for which I have ported the LTR patch, as described
> > here:
> > http://www.eluaproject.net/doc/v0.9/en_arch_ltr.html
> >
> > The way I am using it, is to enable the end user to provide their own
> logic
> > to the system.
> > Essentially they provide the end application that runs on my hardware.
> > Custom Lua libraries allow the Lua scripts to interface the board.
> >
> > "Porting" Lua to NuttX was a piece of cake*.
> > I just downloaded the source code, configured luaconf.h and built it.
> > The only modification that I did to the source code was to comment out
> the
> > os.execute function, as NuttX does not support the function system().
> > I am not sure if this can be easily fixed in NuttX or Lua, or whether
> this
> > functionality is generally required in an MCU environment.
> >
> > (*Note however that this is a WIP for me, so it is not properly tested
> yet.
> > Issues may arise, but for the moment I don't see any reason for .)
> >
> > Στις Πέμ, 10 Ιουν 2021 στις 2:57 μ.μ., ο/η Xiang Xiao <
> > xiaoxiang781216@gmail.com> έγραψε:
> >
> > > It would be great to put NuttX special build files to apps/interpreters
> > > folder after you finish the port, so other people can benefit from your
> > > work and improve it in the future. For the code change, I would
> > > suggest that:
> > > 1. If the api called by 3rd party is very common in other Unix variants
> > but
> > > NuttX is not implemented or the implementation is wrong, it's better to
> > > improve NuttX instead of hacking the 3rd party code.
> > > 2. If the api is hard to implement in NuttX(e.g. fork), but there is a
> > more
> > > portable way to write the same functionality(e.g.
> > > posix_spawn/pthread_create), it's better to make a common change not
> > > specific to NuttX.(e.g.
> > > https://gitlab.com/libssh/libssh-mirror/-/merge_requests/174).
> > > 3.The last resort is to add __NuttX__ around the broken code.
> > > Last, it's better to upstream your change to NuttX and 3rd party
> > community,
> > > so both sides can maintain and improve your change in the long term.
> > >
> > > On Thu, Jun 10, 2021 at 5:58 PM Flavio Castro Alves Filho <
> > > flavio.alves@gmail.com> wrote:
> > >
> > > > >
> > > > > We really ought to talk to the Lua team and see if we can upstream
> > the
> > > > > changes.  Unsupported ports in NuttX don't have good shelf life.
> > > > >
> > > >
> > > > I believe that one of the reasons is that Lua's major use case is to
> > > > be embedded inside applications, isn't it?
> > > >
> > > > I don't know if Lua is used so much as a replacement for bash, perl
> or
> > > > python ..
> > > >
> > > > In this case, maybe a document explaining how to add on a project
> > > > could be enough :-|
> > > >
> > > > Best regards,
> > > >
> > > > Flavio
> > > >
> > >
> >
>

Re: Undefined reference to longjmp/setjmp

Posted by Maciej Wójcik <w8...@gmail.com>.
> as NuttX does not support the function system()

Hmm, I don't think this is true. You just need to enable `system()` in
configuration

http://nuttx-config.nxtlabs.pl/#/?current=SYSTEM_SYSTEM


Am Do., 10. Juni 2021 um 17:52 Uhr schrieb Fotis Panagiotopoulos <
f.j.panag@gmail.com>:

> Regarding Lua.
>
> I have been using Lua in MCU environment for many years now.
> This is the first time to use it along with NuttX.
>
> I am using Lua 5.2.4, for which I have ported the LTR patch, as described
> here:
> http://www.eluaproject.net/doc/v0.9/en_arch_ltr.html
>
> The way I am using it, is to enable the end user to provide their own logic
> to the system.
> Essentially they provide the end application that runs on my hardware.
> Custom Lua libraries allow the Lua scripts to interface the board.
>
> "Porting" Lua to NuttX was a piece of cake*.
> I just downloaded the source code, configured luaconf.h and built it.
> The only modification that I did to the source code was to comment out the
> os.execute function, as NuttX does not support the function system().
> I am not sure if this can be easily fixed in NuttX or Lua, or whether this
> functionality is generally required in an MCU environment.
>
> (*Note however that this is a WIP for me, so it is not properly tested yet.
> Issues may arise, but for the moment I don't see any reason for .)
>
> Στις Πέμ, 10 Ιουν 2021 στις 2:57 μ.μ., ο/η Xiang Xiao <
> xiaoxiang781216@gmail.com> έγραψε:
>
> > It would be great to put NuttX special build files to apps/interpreters
> > folder after you finish the port, so other people can benefit from your
> > work and improve it in the future. For the code change, I would
> > suggest that:
> > 1. If the api called by 3rd party is very common in other Unix variants
> but
> > NuttX is not implemented or the implementation is wrong, it's better to
> > improve NuttX instead of hacking the 3rd party code.
> > 2. If the api is hard to implement in NuttX(e.g. fork), but there is a
> more
> > portable way to write the same functionality(e.g.
> > posix_spawn/pthread_create), it's better to make a common change not
> > specific to NuttX.(e.g.
> > https://gitlab.com/libssh/libssh-mirror/-/merge_requests/174).
> > 3.The last resort is to add __NuttX__ around the broken code.
> > Last, it's better to upstream your change to NuttX and 3rd party
> community,
> > so both sides can maintain and improve your change in the long term.
> >
> > On Thu, Jun 10, 2021 at 5:58 PM Flavio Castro Alves Filho <
> > flavio.alves@gmail.com> wrote:
> >
> > > >
> > > > We really ought to talk to the Lua team and see if we can upstream
> the
> > > > changes.  Unsupported ports in NuttX don't have good shelf life.
> > > >
> > >
> > > I believe that one of the reasons is that Lua's major use case is to
> > > be embedded inside applications, isn't it?
> > >
> > > I don't know if Lua is used so much as a replacement for bash, perl or
> > > python ..
> > >
> > > In this case, maybe a document explaining how to add on a project
> > > could be enough :-|
> > >
> > > Best regards,
> > >
> > > Flavio
> > >
> >
>

Re: Undefined reference to longjmp/setjmp

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
Regarding Lua.

I have been using Lua in MCU environment for many years now.
This is the first time to use it along with NuttX.

I am using Lua 5.2.4, for which I have ported the LTR patch, as described
here:
http://www.eluaproject.net/doc/v0.9/en_arch_ltr.html

The way I am using it, is to enable the end user to provide their own logic
to the system.
Essentially they provide the end application that runs on my hardware.
Custom Lua libraries allow the Lua scripts to interface the board.

"Porting" Lua to NuttX was a piece of cake*.
I just downloaded the source code, configured luaconf.h and built it.
The only modification that I did to the source code was to comment out the
os.execute function, as NuttX does not support the function system().
I am not sure if this can be easily fixed in NuttX or Lua, or whether this
functionality is generally required in an MCU environment.

(*Note however that this is a WIP for me, so it is not properly tested yet.
Issues may arise, but for the moment I don't see any reason for .)

Στις Πέμ, 10 Ιουν 2021 στις 2:57 μ.μ., ο/η Xiang Xiao <
xiaoxiang781216@gmail.com> έγραψε:

> It would be great to put NuttX special build files to apps/interpreters
> folder after you finish the port, so other people can benefit from your
> work and improve it in the future. For the code change, I would
> suggest that:
> 1. If the api called by 3rd party is very common in other Unix variants but
> NuttX is not implemented or the implementation is wrong, it's better to
> improve NuttX instead of hacking the 3rd party code.
> 2. If the api is hard to implement in NuttX(e.g. fork), but there is a more
> portable way to write the same functionality(e.g.
> posix_spawn/pthread_create), it's better to make a common change not
> specific to NuttX.(e.g.
> https://gitlab.com/libssh/libssh-mirror/-/merge_requests/174).
> 3.The last resort is to add __NuttX__ around the broken code.
> Last, it's better to upstream your change to NuttX and 3rd party community,
> so both sides can maintain and improve your change in the long term.
>
> On Thu, Jun 10, 2021 at 5:58 PM Flavio Castro Alves Filho <
> flavio.alves@gmail.com> wrote:
>
> > >
> > > We really ought to talk to the Lua team and see if we can upstream the
> > > changes.  Unsupported ports in NuttX don't have good shelf life.
> > >
> >
> > I believe that one of the reasons is that Lua's major use case is to
> > be embedded inside applications, isn't it?
> >
> > I don't know if Lua is used so much as a replacement for bash, perl or
> > python ..
> >
> > In this case, maybe a document explaining how to add on a project
> > could be enough :-|
> >
> > Best regards,
> >
> > Flavio
> >
>

Re: Undefined reference to longjmp/setjmp

Posted by Xiang Xiao <xi...@gmail.com>.
It would be great to put NuttX special build files to apps/interpreters
folder after you finish the port, so other people can benefit from your
work and improve it in the future. For the code change, I would
suggest that:
1. If the api called by 3rd party is very common in other Unix variants but
NuttX is not implemented or the implementation is wrong, it's better to
improve NuttX instead of hacking the 3rd party code.
2. If the api is hard to implement in NuttX(e.g. fork), but there is a more
portable way to write the same functionality(e.g.
posix_spawn/pthread_create), it's better to make a common change not
specific to NuttX.(e.g.
https://gitlab.com/libssh/libssh-mirror/-/merge_requests/174).
3.The last resort is to add __NuttX__ around the broken code.
Last, it's better to upstream your change to NuttX and 3rd party community,
so both sides can maintain and improve your change in the long term.

On Thu, Jun 10, 2021 at 5:58 PM Flavio Castro Alves Filho <
flavio.alves@gmail.com> wrote:

> >
> > We really ought to talk to the Lua team and see if we can upstream the
> > changes.  Unsupported ports in NuttX don't have good shelf life.
> >
>
> I believe that one of the reasons is that Lua's major use case is to
> be embedded inside applications, isn't it?
>
> I don't know if Lua is used so much as a replacement for bash, perl or
> python ..
>
> In this case, maybe a document explaining how to add on a project
> could be enough :-|
>
> Best regards,
>
> Flavio
>

Re: Undefined reference to longjmp/setjmp

Posted by Flavio Castro Alves Filho <fl...@gmail.com>.
>
> We really ought to talk to the Lua team and see if we can upstream the
> changes.  Unsupported ports in NuttX don't have good shelf life.
>

I believe that one of the reasons is that Lua's major use case is to
be embedded inside applications, isn't it?

I don't know if Lua is used so much as a replacement for bash, perl or python ..

In this case, maybe a document explaining how to add on a project
could be enough :-|

Best regards,

Flavio

Re: Undefined reference to longjmp/setjmp

Posted by Gregory Nutt <sp...@gmail.com>.
Lua has been ported to NuttX several times.   If you Google for 
"lua+NuttX" you find lots of hits, many from 
https://nuttx.yahoogroups.narkive.com.

This is from 2018:  https://github.com/tokoro10g/lua-nuttx

We really ought to talk to the Lua team and see if we can upstream the 
changes.  Unsupported ports in NuttX don't have good shelf life.

On 6/9/2021 1:08 PM, David S. Alessio wrote:
> Also, if you need/want help with getting Lua to run on NuttX, let me know.  I had Lua 5.1.4 on NuttX (5 maybe it was) a long time ago.  I believe I submitted a patch to add it, but I can’t find it now.  The addition of Lua to NuttX was in the form of a subdirectory in apps containing only a Makefile and a few patches.  The Makefile would fetched the Lua tarball, applied the patches, and built it.  We can recreate this if interested…
>
> Cheers,
> -david
>
>> On Jun 9, 2021, at 11:51 AM, David S. Alessio <da...@gmail.com> wrote:
>>
>> Hello, Foti,
>>
>> I wrote setjmp/longjmp for armv7-m some time ago.  The code should be in file:
>> 	arch/arm/src/armv7-m/gnu/up_setjmp.S
>>
>> If not, it’s attached here.
>>
>> Cheers,
>> -david
>>
>>
>>
>>
>>
>> <up_setjmp.S.gz>
>>
>>
>>
>>> On Jun 9, 2021, at 11:10 AM, Fotis Panagiotopoulos <f.j.panag@gmail.com <ma...@gmail.com>> wrote:
>>>
>>> Hi everyone!
>>>
>>> I just started adding Lua to my NuttX-based project, but I have some
>>> problems with it.
>>> I am getting undefined references to longjmp/setjmp.
>>>
>>> I am using an STM32F4 and GCC:
>>> arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major)
>>> 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
>>>
>>> As I see, this combination of arch and compiler should work for
>>> setjmp/longjmp, so I believe that something is misconfigured on my side.
>>>
>>> Is there any special Kconfig option that I am not aware of? Do I need any
>>> special compiler flags?
>

Re: Undefined reference to longjmp/setjmp

Posted by "David S. Alessio" <da...@gmail.com>.
Also, if you need/want help with getting Lua to run on NuttX, let me know.  I had Lua 5.1.4 on NuttX (5 maybe it was) a long time ago.  I believe I submitted a patch to add it, but I can’t find it now.  The addition of Lua to NuttX was in the form of a subdirectory in apps containing only a Makefile and a few patches.  The Makefile would fetched the Lua tarball, applied the patches, and built it.  We can recreate this if interested…

Cheers,
-david

> On Jun 9, 2021, at 11:51 AM, David S. Alessio <da...@gmail.com> wrote:
> 
> Hello, Foti,
> 
> I wrote setjmp/longjmp for armv7-m some time ago.  The code should be in file:
> 	arch/arm/src/armv7-m/gnu/up_setjmp.S
> 
> If not, it’s attached here.
> 
> Cheers,
> -david
> 
> 
> 
> 
> 
> <up_setjmp.S.gz>
> 
> 
> 
>> On Jun 9, 2021, at 11:10 AM, Fotis Panagiotopoulos <f.j.panag@gmail.com <ma...@gmail.com>> wrote:
>> 
>> Hi everyone!
>> 
>> I just started adding Lua to my NuttX-based project, but I have some
>> problems with it.
>> I am getting undefined references to longjmp/setjmp.
>> 
>> I am using an STM32F4 and GCC:
>> arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major)
>> 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
>> 
>> As I see, this combination of arch and compiler should work for
>> setjmp/longjmp, so I believe that something is misconfigured on my side.
>> 
>> Is there any special Kconfig option that I am not aware of? Do I need any
>> special compiler flags?
> 


Re: Undefined reference to longjmp/setjmp

Posted by Xiang Xiao <xi...@gmail.com>.
Since setjmp and longjmp need be called from userspace, the location is
moved to:
libs/libc/machine/arch
Here is the related issue and PR:
https://github.com/apache/incubator-nuttx/issues/2478
https://github.com/apache/incubator-nuttx/pull/3315


On Thu, Jun 10, 2021 at 2:51 AM David S. Alessio <da...@gmail.com>
wrote:

> Hello, Foti,
>
> I wrote setjmp/longjmp for armv7-m some time ago.  The code should be in
> file:
> arch/arm/src/armv7-m/gnu/up_setjmp.S
>
> If not, it’s attached here.
>
> Cheers,
> -david
>
>
>
>
>
>
>
>
> On Jun 9, 2021, at 11:10 AM, Fotis Panagiotopoulos <f....@gmail.com>
> wrote:
>
> Hi everyone!
>
> I just started adding Lua to my NuttX-based project, but I have some
> problems with it.
> I am getting undefined references to longjmp/setjmp.
>
> I am using an STM32F4 and GCC:
> arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major)
> 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
>
> As I see, this combination of arch and compiler should work for
> setjmp/longjmp, so I believe that something is misconfigured on my side.
>
> Is there any special Kconfig option that I am not aware of? Do I need any
> special compiler flags?
>
>
>

Re: Undefined reference to longjmp/setjmp

Posted by "David S. Alessio" <da...@gmail.com>.
Hello, Foti,

I wrote setjmp/longjmp for armv7-m some time ago.  The code should be in file:
	arch/arm/src/armv7-m/gnu/up_setjmp.S

If not, it’s attached here.

Cheers,
-david









> On Jun 9, 2021, at 11:10 AM, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> 
> Hi everyone!
> 
> I just started adding Lua to my NuttX-based project, but I have some
> problems with it.
> I am getting undefined references to longjmp/setjmp.
> 
> I am using an STM32F4 and GCC:
> arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major)
> 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
> 
> As I see, this combination of arch and compiler should work for
> setjmp/longjmp, so I believe that something is misconfigured on my side.
> 
> Is there any special Kconfig option that I am not aware of? Do I need any
> special compiler flags?