Re: Link error building c++ app with master branch

2023-09-18 Thread Alan C. Assis
AFAIK gdb/JTAG using openocd works fine.

ESP32S3 has internal USB_SERIAL_JTAG, so you don't need external hardware!

BR,

Alan

On 9/18/23, Mike Moretti  wrote:
> Hi,
>
> Thanks.  That worked.
>
> Sorry, I got as far as grepping for pthread_key_create, saw that it
> existed in the code, and then just figured it would be easier to ask
> here again, as after a month of this kind of thing, I'm pretty tired of
> fighting with configuration/building/crashes in NuttX.
>
> After months of trying, we actually finally got this app working, a
> little over a week ago, on the esp32-devkit NuttX 12.2.1 release.
> However, unfortunately, the app, without any modifications other than
> the change in NuttX board/configuration, doesn't seem to work at all on
> the ESP32S3 with either 12.2.1 or master.  (The app is a sort of
> specialized communications router that uses udp and uart, etc; it's very
> linuxy/posixy and uses epoll and a bunch of other linux/posix apis).
> I'm not really sure what I'm going to do now. Debugging apps running
> under NuttX is way more difficult than I thought it would be, as I don't
> see any easy way to do JTAG/gdb as you can with other MCU RTOSes, and
> there are just so many layers and configurations.
>
> -m
>
> On 9/18/2023 4:19 PM, Alan C. Assis wrote:
>> Hi Mike,
>>
>> Let me explain the mental process I follow to fix this kind of error!
>>
>> The error message in this case is very "clear"
>>
>> undefined reference to `pthread_key_create'
>>
>> So let see where it is defined:
>>
>> $ cd nuttxspace/nuttx
>>
>> $ git grep pthread_key_create
>> ...
>> libs/libc/pthread/pthread_keycreate.c:int pthread_key_create(FAR
>> pthread_key_t *key,
>> ...
>>
>> Ok, just open libs/libc/pthread/Make.defs and see what symbol we need
>> to enable to get pthread_keycreate.c compiled:
>>
>> ifneq ($(CONFIG_TLS_NELEM),0)
>> CSRCS += pthread_keycreate.c pthread_setspecific.c pthread_getspecific.c
>> CSRCS += pthread_keydelete.c
>> endif
>>
>> Hmm, basically it is testing if CONFIG_TLS_NELEM != 0
>>
>> So, open menuconfig:
>>
>> $ make menuconfig
>>
>> And search for CONFIG_TLS_NELEM (press "/" inside menuconfig and type
>> TLS_NELEM and press ENTER)
>>
>> Bingo:
>> Symbol: TLS_NELEM [=0]
>>
>> You will need to increase it.
>>
>> BR,
>>
>> Alan
>>
>> On 9/18/23, Mike Moretti  wrote:
>>> Unfortunately, using master seems to come with yet other problems. I'm
>>> getting a link error:
>>>
>>> xtensa-esp32s3-elf-ld:
>>> nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal._ZN10__cxxabiv112_GLOBAL__N_110construct_Ev+0xc):
>>>
>>> undefined reference to `pthread_key_create'
>>> xtensa-esp32s3-elf-ld:
>>> nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal._ZN10__cxxabiv112_GLOBAL__N_19destruct_EPv+0x4):
>>>
>>> undefined reference to `pthread_setspecific'
>>> xtensa-esp32s3-elf-ld:
>>> nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal.__cxa_get_globals_fast+0xc):
>>>
>>> undefined reference to `pthread_getspecific'
>>> xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
>>> in function `std::__1::__libcpp_tls_create(int*, void (*)(void*))':
>>> nuttx/include/libcxx/__threading_support:551: undefined reference to
>>> `pthread_key_create'
>>> xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
>>> in function `std::__1::__libcpp_tls_set(int, void*)':
>>> nuttx/include/libcxx/__threading_support:561: undefined reference to
>>> `pthread_setspecific'
>>> xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
>>> in function `std::__1::__libcpp_tls_get(int)':
>>> nuttx/include/libcxx/__threading_support:556: undefined reference to
>>> `pthread_getspecific'
>>> xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
>>> in function `std::__1::__libcpp_tls_set(int, void*)':
>>> nuttx/include/libcxx/__threading_support:561: undefined reference to
>>> `pthread_setspecific'
>>>
>>>
>>> Our custom app uses C++ and these specific config options (because
>>> they're necessary for the app to compile):
>>>
>>> CONFIG_LIBC_LOCALE=y
>>> CONFIG_HAVE_CXX=y
>>> CONFIG_HAVE_CXXINITIALIZE=y
>>> CONFIG_LIBCXX=y
>>> CONFIG_LIBCXXABI=y
>>> CONFIG_CXX_STANDARD="gnu++17"
>>> CONFIG_CXX_EXCEPTION=y
>>> CONFIG_CXX_RTTI=y
>>>
>>> -m
>>>
>>> On 9/18/2023 3:19 PM, Petro Karashchenko wrote:
 Using a released version is usually better, but since EPS32S3 has
 active
 feature development using master can give you better features support.
 That
 is obviously a tradeoff you need to make.
 I'm trying to fix all the issues I meet with ESP32S3 as I'm trying to
 build
 a product on top of it, but there are still many features that I hope
 gona
 be added soon (like USB host support for example), so I'm staying on
 master
 currently.

 Best regards,
 Petro

 пн, 18 вер. 2023 р. о 22:15 Mike Moretti 
 пише:

> Hi,
>
> I'm using 12.2.1, the latest release.  The more I work with this chip

Re: Link error building c++ app with master branch

2023-09-18 Thread Mike Moretti

Hi,

Thanks.  That worked.

Sorry, I got as far as grepping for pthread_key_create, saw that it 
existed in the code, and then just figured it would be easier to ask 
here again, as after a month of this kind of thing, I'm pretty tired of 
fighting with configuration/building/crashes in NuttX.


After months of trying, we actually finally got this app working, a 
little over a week ago, on the esp32-devkit NuttX 12.2.1 release. 
However, unfortunately, the app, without any modifications other than 
the change in NuttX board/configuration, doesn't seem to work at all on 
the ESP32S3 with either 12.2.1 or master.  (The app is a sort of 
specialized communications router that uses udp and uart, etc; it's very 
linuxy/posixy and uses epoll and a bunch of other linux/posix apis).  
I'm not really sure what I'm going to do now. Debugging apps running 
under NuttX is way more difficult than I thought it would be, as I don't 
see any easy way to do JTAG/gdb as you can with other MCU RTOSes, and 
there are just so many layers and configurations.


-m

On 9/18/2023 4:19 PM, Alan C. Assis wrote:

Hi Mike,

Let me explain the mental process I follow to fix this kind of error!

The error message in this case is very "clear"

undefined reference to `pthread_key_create'

So let see where it is defined:

$ cd nuttxspace/nuttx

$ git grep pthread_key_create
...
libs/libc/pthread/pthread_keycreate.c:int pthread_key_create(FAR
pthread_key_t *key,
...

Ok, just open libs/libc/pthread/Make.defs and see what symbol we need
to enable to get pthread_keycreate.c compiled:

ifneq ($(CONFIG_TLS_NELEM),0)
CSRCS += pthread_keycreate.c pthread_setspecific.c pthread_getspecific.c
CSRCS += pthread_keydelete.c
endif

Hmm, basically it is testing if CONFIG_TLS_NELEM != 0

So, open menuconfig:

$ make menuconfig

And search for CONFIG_TLS_NELEM (press "/" inside menuconfig and type
TLS_NELEM and press ENTER)

Bingo:
Symbol: TLS_NELEM [=0]

You will need to increase it.

BR,

Alan

On 9/18/23, Mike Moretti  wrote:

Unfortunately, using master seems to come with yet other problems. I'm
getting a link error:

xtensa-esp32s3-elf-ld:
nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal._ZN10__cxxabiv112_GLOBAL__N_110construct_Ev+0xc):

undefined reference to `pthread_key_create'
xtensa-esp32s3-elf-ld:
nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal._ZN10__cxxabiv112_GLOBAL__N_19destruct_EPv+0x4):

undefined reference to `pthread_setspecific'
xtensa-esp32s3-elf-ld:
nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal.__cxa_get_globals_fast+0xc):

undefined reference to `pthread_getspecific'
xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
in function `std::__1::__libcpp_tls_create(int*, void (*)(void*))':
nuttx/include/libcxx/__threading_support:551: undefined reference to
`pthread_key_create'
xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
in function `std::__1::__libcpp_tls_set(int, void*)':
nuttx/include/libcxx/__threading_support:561: undefined reference to
`pthread_setspecific'
xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
in function `std::__1::__libcpp_tls_get(int)':
nuttx/include/libcxx/__threading_support:556: undefined reference to
`pthread_getspecific'
xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
in function `std::__1::__libcpp_tls_set(int, void*)':
nuttx/include/libcxx/__threading_support:561: undefined reference to
`pthread_setspecific'


Our custom app uses C++ and these specific config options (because
they're necessary for the app to compile):

CONFIG_LIBC_LOCALE=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_LIBCXX=y
CONFIG_LIBCXXABI=y
CONFIG_CXX_STANDARD="gnu++17"
CONFIG_CXX_EXCEPTION=y
CONFIG_CXX_RTTI=y

-m

On 9/18/2023 3:19 PM, Petro Karashchenko wrote:

Using a released version is usually better, but since EPS32S3 has active
feature development using master can give you better features support.
That
is obviously a tradeoff you need to make.
I'm trying to fix all the issues I meet with ESP32S3 as I'm trying to
build
a product on top of it, but there are still many features that I hope
gona
be added soon (like USB host support for example), so I'm staying on
master
currently.

Best regards,
Petro

пн, 18 вер. 2023 р. о 22:15 Mike Moretti 
пише:


Hi,

I'm using 12.2.1, the latest release.  The more I work with this chip
the more I'm wondering if I'm going to have to move to using master.
I've been trying to avoid not using an actual release version of NuttX.

-m

On 9/18/2023 3:08 PM, Petro Karashchenko wrote:

Hello Mike,

Which version of nuttx code are you using? Recently I was dealing with
UART1/2 on ESP32S3 and managed those to be working in
https://github.com/apache/nuttx/pull/10467
There were few issues including some clocking configuration problem as

well

as wrong pin functions used for UART1.

At the end I was able to even run RS485 with EPS32S3 and make a kind of
a
loopback test connecting UART1

Re: Link error building c++ app with master branch

2023-09-18 Thread Alan C. Assis
Hi Mike,

Let me explain the mental process I follow to fix this kind of error!

The error message in this case is very "clear"

undefined reference to `pthread_key_create'

So let see where it is defined:

$ cd nuttxspace/nuttx

$ git grep pthread_key_create
...
libs/libc/pthread/pthread_keycreate.c:int pthread_key_create(FAR
pthread_key_t *key,
...

Ok, just open libs/libc/pthread/Make.defs and see what symbol we need
to enable to get pthread_keycreate.c compiled:

ifneq ($(CONFIG_TLS_NELEM),0)
CSRCS += pthread_keycreate.c pthread_setspecific.c pthread_getspecific.c
CSRCS += pthread_keydelete.c
endif

Hmm, basically it is testing if CONFIG_TLS_NELEM != 0

So, open menuconfig:

$ make menuconfig

And search for CONFIG_TLS_NELEM (press "/" inside menuconfig and type
TLS_NELEM and press ENTER)

Bingo:
Symbol: TLS_NELEM [=0]

You will need to increase it.

BR,

Alan

On 9/18/23, Mike Moretti  wrote:
> Unfortunately, using master seems to come with yet other problems. I'm
> getting a link error:
>
> xtensa-esp32s3-elf-ld:
> nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal._ZN10__cxxabiv112_GLOBAL__N_110construct_Ev+0xc):
>
> undefined reference to `pthread_key_create'
> xtensa-esp32s3-elf-ld:
> nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal._ZN10__cxxabiv112_GLOBAL__N_19destruct_EPv+0x4):
>
> undefined reference to `pthread_setspecific'
> xtensa-esp32s3-elf-ld:
> nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal.__cxa_get_globals_fast+0xc):
>
> undefined reference to `pthread_getspecific'
> xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
> in function `std::__1::__libcpp_tls_create(int*, void (*)(void*))':
> nuttx/include/libcxx/__threading_support:551: undefined reference to
> `pthread_key_create'
> xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
> in function `std::__1::__libcpp_tls_set(int, void*)':
> nuttx/include/libcxx/__threading_support:561: undefined reference to
> `pthread_setspecific'
> xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
> in function `std::__1::__libcpp_tls_get(int)':
> nuttx/include/libcxx/__threading_support:556: undefined reference to
> `pthread_getspecific'
> xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o):
> in function `std::__1::__libcpp_tls_set(int, void*)':
> nuttx/include/libcxx/__threading_support:561: undefined reference to
> `pthread_setspecific'
>
>
> Our custom app uses C++ and these specific config options (because
> they're necessary for the app to compile):
>
> CONFIG_LIBC_LOCALE=y
> CONFIG_HAVE_CXX=y
> CONFIG_HAVE_CXXINITIALIZE=y
> CONFIG_LIBCXX=y
> CONFIG_LIBCXXABI=y
> CONFIG_CXX_STANDARD="gnu++17"
> CONFIG_CXX_EXCEPTION=y
> CONFIG_CXX_RTTI=y
>
> -m
>
> On 9/18/2023 3:19 PM, Petro Karashchenko wrote:
>> Using a released version is usually better, but since EPS32S3 has active
>> feature development using master can give you better features support.
>> That
>> is obviously a tradeoff you need to make.
>> I'm trying to fix all the issues I meet with ESP32S3 as I'm trying to
>> build
>> a product on top of it, but there are still many features that I hope
>> gona
>> be added soon (like USB host support for example), so I'm staying on
>> master
>> currently.
>>
>> Best regards,
>> Petro
>>
>> пн, 18 вер. 2023 р. о 22:15 Mike Moretti 
>> пише:
>>
>>> Hi,
>>>
>>> I'm using 12.2.1, the latest release.  The more I work with this chip
>>> the more I'm wondering if I'm going to have to move to using master.
>>> I've been trying to avoid not using an actual release version of NuttX.
>>>
>>> -m
>>>
>>> On 9/18/2023 3:08 PM, Petro Karashchenko wrote:
 Hello Mike,

 Which version of nuttx code are you using? Recently I was dealing with
 UART1/2 on ESP32S3 and managed those to be working in
 https://github.com/apache/nuttx/pull/10467
 There were few issues including some clocking configuration problem as
>>> well
 as wrong pin functions used for UART1.

 At the end I was able to even run RS485 with EPS32S3 and make a kind of
 a
 loopback test connecting UART1-RS485 <-> UART2-RS485 on the same device
>>> and
 exchange data between those UARTs.

 Please check if your code base contains my fixes.

 Looking forward to hearing from you,
 Petro

 пн, 18 вер. 2023 р. о 21:59 Mike Moretti 
>>> пише:
> Hi,
>
> I'm having trouble with NuttX on the ESP32S3 trying to get UART1
> (configured on the default pins) working via /dev/ttyS1.  The driver
> code for esp32s3_serial.c seems to configure uart1 as /dev/ttys1 when
> you enable it in the configs, however, testing via
> serialblaster/serialrx (and our own custom app) doesn't seem to send
> or
> receive anything on uart1.  I've tried swapping my connections to the
> pins, testing every pin on the devkit board with serialblaster and
> nothing ever comes out.  I don't have this problem on an esp32 devkit
> (w

Link error building c++ app with master branch

2023-09-18 Thread Mike Moretti
Unfortunately, using master seems to come with yet other problems. I'm 
getting a link error:


xtensa-esp32s3-elf-ld: 
nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal._ZN10__cxxabiv112_GLOBAL__N_110construct_Ev+0xc): 
undefined reference to `pthread_key_create'
xtensa-esp32s3-elf-ld: 
nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal._ZN10__cxxabiv112_GLOBAL__N_19destruct_EPv+0x4): 
undefined reference to `pthread_setspecific'
xtensa-esp32s3-elf-ld: 
nuttx/staging/libxx.a(cxa_exception_storage.o):(.literal.__cxa_get_globals_fast+0xc): 
undefined reference to `pthread_getspecific'
xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o): 
in function `std::__1::__libcpp_tls_create(int*, void (*)(void*))':
nuttx/include/libcxx/__threading_support:551: undefined reference to 
`pthread_key_create'
xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o): 
in function `std::__1::__libcpp_tls_set(int, void*)':
nuttx/include/libcxx/__threading_support:561: undefined reference to 
`pthread_setspecific'
xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o): 
in function `std::__1::__libcpp_tls_get(int)':
nuttx/include/libcxx/__threading_support:556: undefined reference to 
`pthread_getspecific'
xtensa-esp32s3-elf-ld: nuttx/staging/libxx.a(cxa_exception_storage.o): 
in function `std::__1::__libcpp_tls_set(int, void*)':
nuttx/include/libcxx/__threading_support:561: undefined reference to 
`pthread_setspecific'



Our custom app uses C++ and these specific config options (because 
they're necessary for the app to compile):


CONFIG_LIBC_LOCALE=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_LIBCXX=y
CONFIG_LIBCXXABI=y
CONFIG_CXX_STANDARD="gnu++17"
CONFIG_CXX_EXCEPTION=y
CONFIG_CXX_RTTI=y

-m

On 9/18/2023 3:19 PM, Petro Karashchenko wrote:

Using a released version is usually better, but since EPS32S3 has active
feature development using master can give you better features support. That
is obviously a tradeoff you need to make.
I'm trying to fix all the issues I meet with ESP32S3 as I'm trying to build
a product on top of it, but there are still many features that I hope gona
be added soon (like USB host support for example), so I'm staying on master
currently.

Best regards,
Petro

пн, 18 вер. 2023 р. о 22:15 Mike Moretti  пише:


Hi,

I'm using 12.2.1, the latest release.  The more I work with this chip
the more I'm wondering if I'm going to have to move to using master.
I've been trying to avoid not using an actual release version of NuttX.

-m

On 9/18/2023 3:08 PM, Petro Karashchenko wrote:

Hello Mike,

Which version of nuttx code are you using? Recently I was dealing with
UART1/2 on ESP32S3 and managed those to be working in
https://github.com/apache/nuttx/pull/10467
There were few issues including some clocking configuration problem as

well

as wrong pin functions used for UART1.

At the end I was able to even run RS485 with EPS32S3 and make a kind of a
loopback test connecting UART1-RS485 <-> UART2-RS485 on the same device

and

exchange data between those UARTs.

Please check if your code base contains my fixes.

Looking forward to hearing from you,
Petro

пн, 18 вер. 2023 р. о 21:59 Mike Moretti 

пише:

Hi,

I'm having trouble with NuttX on the ESP32S3 trying to get UART1
(configured on the default pins) working via /dev/ttyS1.  The driver
code for esp32s3_serial.c seems to configure uart1 as /dev/ttys1 when
you enable it in the configs, however, testing via
serialblaster/serialrx (and our own custom app) doesn't seem to send or
receive anything on uart1.  I've tried swapping my connections to the
pins, testing every pin on the devkit board with serialblaster and
nothing ever comes out.  I don't have this problem on an esp32 devkit
(with either uart1 or uart2).  It seems to only happen on the esp32s3
devkit.  I can successfully use serialblaster/serialrx on /dev/ttyS0 and
see the output/enter text.

Is there something I'm missing?

Thanks,
-m