This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Nordic NRF SDK v1.6: Issue with AT_CMD_PARSER

Hi

I'm testing RC3 of NRF Connect SDK v1.6 in combination with our application. I have an issue with the configuration when I want to enable CONFIG_LTE_LINK_CONTROL. This flag automatically selects AT_CMD_PARSER. The problem is that AT_CMD_PARSER seems to have a dependency on NEWLIB_LIBC or EXTERNAL_LIBC.

We want to use MINIMAL_LIBC in our project rather than NEWLIBC. On one hand because it should be less resource hungry and on the other hand there are compile issues with NEWLIBC in our application. The compile issues have to do with multiple definitions of POSIX functions.

Could you please show me a way how to use the NB-IoT modem with MINIMAL_LIB? We are coming from NRF Connect SDK v1.5.1 where this setup worked.

Best regards,

Michael

  • Hi,

     

    The modem can return values > 32 bit, so strtoll() is required, which minimal libc lacks support for at this time.

    There has been work on this in the upstream zephyr, but it seems to be stale:

    https://github.com/zephyrproject-rtos/zephyr/pull/16511

     

    The compile issues have to do with multiple definitions of POSIX functions.

    Is there any specific functions that clashes?

     

    Kind regards,

    Håkon

  • Hi Håkon

    Thanks for pointing out the reason for using NEW_LIBC. If I try to compile with NEW_LIBC I get errors about multiple definitions of functions and variables related to POSIX threads.

    Please have a look at the following log-file to see the details:

    FAILED: modules/civetweb/CMakeFiles/..__modules__lib__civetweb.dir/src/civetweb.c.obj 
    ccache /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.6.0-rc1-ncs1 -DEXT_API_MAGIC=0x281ee6de,0xb845acea,23298 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,23298 -DKERNEL -DMBEDTLS_CONFIG_FILE=\"config-tls-generic.h\" -DMG_EXTERNAL_FUNCTION_log_access -DMG_EXTERNAL_FUNCTION_mg_cry_internal_impl -DNO_ALTERNATIVE_QUEUE -DNO_CACHING -DNO_CGI -DNO_FILES -DNO_FILESYSTEMS -DNO_SSL -DNRF9160_XXAA -DNRF_TRUSTZONE_NONSECURE -DOPENSSL_API_1_1 -DUSE_PARTITION_MANAGER=1 -DUSE_STACK_SIZE=0 -DZEPHYR_VERSION=\"2.6.0-rc1\" -D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/opt/zephyrproject/iiot-firmware-nordic-nrf91/iiot_main_firmware/include/compatibility -I/opt/zephyrproject/zephyr/include -Izephyr/include/generated -I/opt/zephyrproject/zephyr/soc/arm/nordic_nrf/nrf91 -I/opt/zephyrproject/zephyr/lib/libc/newlib/include -I/opt/zephyrproject/zephyr/subsys/net/lib/sockets/. -I/opt/zephyrproject/zephyr/subsys/net/lib/tls_credentials/. -I/opt/zephyrproject/zephyr/subsys/net/lib/dns/. -I/opt/zephyrproject/zephyr/subsys/net/ip -I/opt/zephyrproject/zephyr/subsys/net/l2 -I/opt/zephyrproject/nrf/include -I/opt/zephyrproject/nrf/lib/at_notif/. -I/opt/zephyrproject/modules/lib/civetweb/include -I/opt/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -I/opt/zephyrproject/modules/hal/nordic/nrfx -I/opt/zephyrproject/modules/hal/nordic/nrfx/drivers/include -I/opt/zephyrproject/modules/hal/nordic/nrfx/mdk -I/opt/zephyrproject/zephyr/modules/hal_nordic/nrfx/. -I/opt/zephyrproject/modules/debug/segger/SEGGER -I/opt/zephyrproject/modules/debug/segger/Config -I/opt/zephyrproject/zephyr/modules/segger/. -I/opt/zephyrproject/nrfxlib/nrf_modem/include -I/opt/zephyrproject/modules/crypto/mbedtls/mbedtls/include -I/opt/zephyrproject/zephyr/modules/mbedtls/configs -I/opt/zephyrproject/modules/lib/civetweb/src -I/opt/zephyrproject/iiot-firmware-nordic-nrf91/iiot_main_firmware/src -Og -imacros /opt/zephyrproject/iiot-firmware-nordic-nrf91/iiot_main_firmware/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros /opt/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/opt/zephyrproject/iiot-firmware-nordic-nrf91/iiot_main_firmware=CMAKE_SOURCE_DIR -fmacro-prefix-map=/opt/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/opt/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT modules/civetweb/CMakeFiles/..__modules__lib__civetweb.dir/src/civetweb.c.obj -MF modules/civetweb/CMakeFiles/..__modules__lib__civetweb.dir/src/civetweb.c.obj.d -o modules/civetweb/CMakeFiles/..__modules__lib__civetweb.dir/src/civetweb.c.obj   -c /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c
    In file included from /opt/zephyrproject/zephyr/include/posix/time.h:61,
                     from /opt/zephyrproject/zephyr/include/posix/pthread.h:12,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/posix_types.h:45:3: error: conflicting types for 'pthread_attr_t'
       45 | } pthread_attr_t;
          |   ^~~~~~~~~~~~~~
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:75:3: note: previous declaration of 'pthread_attr_t' was here
       75 | } pthread_attr_t;
          |   ^~~~~~~~~~~~~~
    In file included from /opt/zephyrproject/zephyr/include/posix/time.h:61,
                     from /opt/zephyrproject/zephyr/include/posix/pthread.h:12,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/posix_types.h:47:15: error: conflicting types for 'pthread_t'
       47 | typedef void *pthread_t;
          |               ^~~~~~~~~
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:32:20: note: previous declaration of 'pthread_t' was here
       32 | typedef __uint32_t pthread_t;            /* identify a thread */
          |                    ^~~~~~~~~
    In file included from /opt/zephyrproject/zephyr/include/posix/time.h:61,
                     from /opt/zephyrproject/zephyr/include/posix/pthread.h:12,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/posix_types.h:58:3: error: conflicting types for 'pthread_mutex_t'
       58 | } pthread_mutex_t;
          |   ^~~~~~~~~~~~~~~
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:154:20: note: previous declaration of 'pthread_mutex_t' was here
      154 | typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
          |                    ^~~~~~~~~~~~~~~
    In file included from /opt/zephyrproject/zephyr/include/posix/time.h:61,
                     from /opt/zephyrproject/zephyr/include/posix/pthread.h:12,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/posix_types.h:62:3: error: conflicting types for 'pthread_mutexattr_t'
       62 | } pthread_mutexattr_t;
          |   ^~~~~~~~~~~~~~~~~~~
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:169:3: note: previous declaration of 'pthread_mutexattr_t' was here
      169 | } pthread_mutexattr_t;
          |   ^~~~~~~~~~~~~~~~~~~
    In file included from /opt/zephyrproject/zephyr/include/posix/time.h:61,
                     from /opt/zephyrproject/zephyr/include/posix/pthread.h:12,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/posix_types.h:67:3: error: conflicting types for 'pthread_cond_t'
       67 | } pthread_cond_t;
          |   ^~~~~~~~~~~~~~
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:176:20: note: previous declaration of 'pthread_cond_t' was here
      176 | typedef __uint32_t pthread_cond_t;       /* identify a condition variable */
          |                    ^~~~~~~~~~~~~~
    In file included from /opt/zephyrproject/zephyr/include/posix/time.h:61,
                     from /opt/zephyrproject/zephyr/include/posix/pthread.h:12,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/posix_types.h:70:3: error: conflicting types for 'pthread_condattr_t'
       70 | } pthread_condattr_t;
          |   ^~~~~~~~~~~~~~~~~~
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:186:3: note: previous declaration of 'pthread_condattr_t' was here
      186 | } pthread_condattr_t;         /* a condition attribute object */
          |   ^~~~~~~~~~~~~~~~~~
    In file included from /opt/zephyrproject/zephyr/include/posix/pthread.h:15,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/posix_sched.h:23:8: error: redefinition of 'struct sched_param'
       23 | struct sched_param {
          |        ^~~~~~~~~~~
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:23,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/sched.h:48:8: note: originally defined here
       48 | struct sched_param {
          |        ^~~~~~~~~~~
    In file included from /opt/zephyrproject/zephyr/include/posix/pthread.h:16,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/pthread_key.h:18:18: error: conflicting types for 'pthread_once_t'
       18 | typedef uint32_t pthread_once_t;
          |                  ^~~~~~~~~~~~~~
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:195:3: note: previous declaration of 'pthread_once_t' was here
      195 | } pthread_once_t;       /* dynamic package initialization */
          |   ^~~~~~~~~~~~~~
    In file included from /opt/zephyrproject/zephyr/include/posix/pthread.h:16,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/pthread_key.h:21:15: error: conflicting types for 'pthread_key_t'
       21 | typedef void *pthread_key_t;
          |               ^~~~~~~~~~~~~
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:190:20: note: previous declaration of 'pthread_key_t' was here
      190 | typedef __uint32_t pthread_key_t;        /* thread-specific data keys */
          |                    ^~~~~~~~~~~~~
    In file included from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/pthread.h:56: warning: "PTHREAD_CREATE_JOINABLE" redefined
       56 | #define PTHREAD_CREATE_JOINABLE     PTHREAD_JOINABLE
          | 
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:47: note: this is the location of the previous definition
       47 | #define PTHREAD_CREATE_JOINABLE  1
          | 
    In file included from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:190:
    /opt/zephyrproject/zephyr/include/posix/pthread.h:57: warning: "PTHREAD_CREATE_DETACHED" redefined
       57 | #define PTHREAD_CREATE_DETACHED     PTHREAD_DETACHED
          | 
    In file included from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h:223,
                     from /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h:28,
                     from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:186:
    /opt/toolchains/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h:46: note: this is the location of the previous definition
       46 | #define PTHREAD_CREATE_DETACHED 0
          | 
    In file included from /opt/zephyrproject/modules/lib/civetweb/src/civetweb.c:188:
    /opt/zephyrproject/iiot-firmware-nordic-nrf91/iiot_main_firmware/include/compatibility/libc_extensions.h:32:5: error: expected ')' before '+' token
       32 | int iscntrl(int c);
          |     ^~~~~~~
    /opt/zephyrproject/iiot-firmware-nordic-nrf91/iiot_main_firmware/include/compatibility/libc_extensions.h:32:5: error: expected ')' before '[' token
       32 | int iscntrl(int c);
          |     ^~~~~~~
    /opt/zephyrproject/iiot-firmware-nordic-nrf91/iiot_main_firmware/include/compatibility/libc_extensions.h:32:5: error: expected ')' before '&' token
       32 | int iscntrl(int c);
          |     ^~~~~~~
    
    

    We need CONFIG_POSIX_API=y and CONFIG_PTHREAD_IPC=y as well as CONFIG_POSIX_MQUEUE=y in our application because we are using Civetweb (webserver).

    Do you have any ideas on how to go ahead with NEW_LIBC?

    Kind regards,

    Michael

  • Hi Michael,

     

    I reproduced this by compiling zephyr/samples/net/civetweb/http_server/ and setting newlibc.

    Using civetweb with newlib looks to be a hard incompatibility, as per this issue:

    https://github.com/zephyrproject-rtos/zephyr/issues/16683

     

    It looks like the simplest path is to get strtoll/strtoull support for minimal libc, then remove this dep:

    https://github.com/nrfconnect/sdk-nrf/blob/master/lib/at_cmd_parser/Kconfig#L9

     

    Unfortunately, both needs to be addressed in the zephyr project. Have you tried creating an issue on their github?

    https://github.com/zephyrproject-rtos/zephyr/issues

     

    Kind regards,

    Håkon

  • Hi Håkon

    Thanks for the update. I agree with you. It would be good to have the support for strtoll/strtoull in minimal libc and then ged rid of the dependeny to new libc. I posted in this thread here: https://github.com/zephyrproject-rtos/zephyr/pull/16511

    If I don't get an answer I will create a new feature request. In that case I will keep you posted.

    Kind regards,

    Michael

  • Hi Håkon

    If I don't get an answer I will create a new feature request. In that case I will keep you posted.

    As I didn't hear anything in the old PR thread I created a new Issue in Zephyr: https://github.com/zephyrproject-rtos/zephyr/issues/36645

    I hope somebody will add the functions to minimal libc.

    Best regards,

    Michael

Related