This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Error in west compilation in zephyr in shell_uart.c

Hi,

I have removed UART from my custom board dts file as in my current application, I am not using UART for any transfer.

But due to this, I am unable to compile code as some internal logging/Device_DT is using UART.

I am getting the following error:

/zephyr/include/net/net_l2.h:164:22: note: expected 'struct net_pkt *' but argument is of type 'struct net_pkt *'
[656/817] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_uart.c.obj
FAILED: zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_uart.c.obj 
ccache /opt/nordic/ncs/v1.8.0/toolchain/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.7.0-ncs1 -DKERNEL -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DNRF52840_XXAA -DNRF_802154_ACK_TIMEOUT_ENABLED=1 -DNRF_802154_CCA_CORR_LIMIT_DEFAULT=2 -DNRF_802154_CCA_CORR_THRESHOLD_DEFAULT=45 -DNRF_802154_CCA_ED_THRESHOLD_DEFAULT=45 -DNRF_802154_CCA_MODE_DEFAULT=NRF_RADIO_CCA_MODE_ED -DNRF_802154_CSMA_CA_ENABLED=1 -DNRF_802154_ECB_PRIORITY=0 -DNRF_802154_ENCRYPTION_ENABLED=0 -DNRF_802154_IE_WRITER_ENABLED=0 -DNRF_802154_INTERNAL_RADIO_IRQ_HANDLING=0 -DNRF_802154_PENDING_EXTENDED_ADDRESSES=16 -DNRF_802154_PENDING_SHORT_ADDRESSES=16 -DNRF_802154_RX_BUFFERS=16 -DNRF_802154_SECURITY_WRITER_ENABLED=0 -DNRF_802154_SWI_PRIORITY=1 -DNRF_802154_TX_STARTED_NOTIFY_ENABLED=1 -DNRF_802154_USE_RAW_API=1 -DPSA_CRYPTO_SECURE -DUSE_PARTITION_MANAGER=0 -D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/Users/bhumika/Pr/zephyr/kernel/include -I/zephyr/arch/arm/include -I/nrf/drivers/mpsl/clock_control -I/zephyr/include -I/app/sed/build/zephyr/include/generated -I/zephyr/soc/arm/nordic_nrf/nrf52 -I/zephyr/lib/libc/newlib/include -I/zephyr/lib/util/fnmatch/. -I/zephyr/subsys/net/lib/coap/. -I/zephyr/subsys/net/lib/sockets/. -I/zephyr/subsys/net/lib/conn_mgr/. -I/zephyr/subsys/net/lib/openthread/platform/. -I/zephyr/subsys/settings/include -I/nrf/include -I/nrf/lib/multithreading_lock/. -I/nrf/subsys/net/lib/coap_utils/. -I/zephyr/drivers/flash -I/modules/hal/cmsis/CMSIS/Core/Include -I/modules/hal/nordic/nrfx -I/modules/hal/nordic/nrfx/drivers/include -I/modules/hal/nordic/nrfx/mdk -I/zephyr/modules/hal_nordic/nrfx/. -I/modules/debug/segger/SEGGER -I/modules/debug/segger/Config -I/zephyr/modules/segger/. -I/nrfxlib/mpsl/include -I/nrfxlib/mpsl/include/protocol -I/nrfxlib/nrf_802154/driver/include -I/nrfxlib/nrf_802154/sl/include -I/app/sed/build/modules/openthread/build/etc/cmake -I/modules/lib/openthread/etc/cmake -I/modules/lib/openthread/include -I/app/sed/build/modules/nrfxlib/nrfxlib/nrf_security/include/mbedtls_generated/mbedtl /app/sed/build/modules/nrfxlib/nrfxlib/nrf_security/include/mbedtls_generated -I/app/sed/build/modules/nrfxlib/nrfxlib/nrf_security/include -I/nrfxlib/nrf_security/include -I/mbedtls/library -I/Users/bhumika/Project/Zipnet_Zephyr/mbedtls/include -I/Users/bhumika/Project/Zipnet_Zephyr/mbedtls/include/mbedtls -I/Users/bhumika/Project/Zipnet_Zephyr/mbedtls/include/psa -I/Users/bhumika/Project/Zipnet_Zephyr/nrfxlib/nrf_security/include/mbedcrypto_glue/mbedtls/threading -isystem /Users/bhumika/Project/Zipnet_Zephyr/zephyr/subsys/cpp/include -isystem /Users/bhumika/Project/Zipnet_Zephyr/modules/lib/openthread/zephyr/../include -isystem /Users/bhumika/Project/Zipnet_Zephyr/modules/lib/openthread/zephyr/../examples/platforms -isystem /Users/bhumika/Project/Zipnet_Zephyr/nrfxlib/crypto/nrf_cc310_platform/include -Os -imacros /Users/bhumika/Project/Zipnet_Zephyr/app/sed/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mfp16-format=ieee -imacros /Users/bhumika/Project/Zipnet_Zephyr/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=/Users/bhumika/Project/Zipnet_Zephyr/app/sed=CMAKE_SOURCE_DIR -fmacro-prefix-map=/Users/bhumika/Project/Zipnet_Zephyr/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/Users/bhumika/Project/Zipnet_Zephyr=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_uart.c.obj -MF zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_uart.c.obj.d -o zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_uart.c.obj -c /Users/bhumika/Project/Zipnet_Zephyr/zephyr/subsys/shell/shell_uart.c
In file included from /zephyr/include/toolchain/gcc.h:66,
                 from /zephyr/include/toolchain.h:50,
                 from /zephyr/include/kernel_includes.h:19,
                 from /zephyr/include/kernel.h:17,
                 from /zephyr/include/zephyr.h:18,
                 from /zephyr/include/shell/shell.h:10,
                 from /zephyr/include/shell/shell_uart.h:10,
                 from /zephyr/subsys/shell/shell_uart.c:7:
/zephyr/subsys/shell/shell_uart.c: In function 'enable_shell_uart':
/zephyr/include/device.h:81:39: error: '__device_dts_ord_DT_CHOSEN_zephyr_shell_uart_ORD' undeclared (first use in this function)
   81 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
      |                                       ^~~~~~~~~
/zephyr/include/toolchain/common.h:124:26: note: in definition of macro '_DO_CONCAT'
  124 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/zephyr/include/device.h:81:31: note: in expansion of macro '_CONCAT'
   81 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
      |                               ^~~~~~~
/zephyr/include/device.h:233:37: note: in expansion of macro 'DEVICE_NAME_GET'
  233 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_NAME(node_id))
      |                                     ^~~~~~~~~~~~~~~
/zephyr/include/device.h:247:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
  247 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
      |                                  ^~~~~~~~~~~~~~~~~~
/zephyr/subsys/shell/shell_uart.c:317:29: note: in expansion of macro 'DEVICE_DT_GET'
  317 |  const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_shell_uart));
      |                             ^~~~~~~~~~~~~
/zephyr/include/device.h:81:39: note: each undeclared identifier is reported only once for each function it appears in
   81 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
      |                                       ^~~~~~~~~
/zephyr/include/toolchain/common.h:124:26: note: in definition of macro '_DO_CONCAT'
  124 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/zephyr/include/device.h:81:31: note: in expansion of macro '_CONCAT'
   81 | #define DEVICE_NAME_GET(name) _CONCAT(__device_, name)
      |                               ^~~~~~~
/zephyr/include/device.h:233:37: note: in expansion of macro 'DEVICE_NAME_GET'
  233 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_NAME(node_id))
      |                                     ^~~~~~~~~~~~~~~
/zephyr/include/device.h:247:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
  247 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
      |                                  ^~~~~~~~~~~~~~~~~~
/zephyr/subsys/shell/shell_uart.c:317:29: note: in expansion of macro 'DEVICE_DT_GET'
  317 |  const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_shell_uart));
      |                             ^~~~~~~~~~~~~
[661/817] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/net/lib/sockets/sockets.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/local/bin/cmake --build /app/sed/build
➜  sed git:(master) ✗ 

Can you tell me which file by default uses shell_uart.c?

How can I remove this error?

  • In your prj.conf you have: CONFIG_ASSERT_NO_COND_INFO=y and CONFIG_ASSERT_NO_MSG_INFO=y.

    Set these to n and see if you get more info from the assert.

  • Hi,

    I have made above changes in conf.

    Now I am getting following message at crash:

    ASSERTION FAIL [0] @ WEST_TOPDIR/zephyr/subsys/net/lib/openthread/platform/misc.c:36
    	OpenThread ASSERT @ WEST_TOPDIR/modules/lib/openthread/src/core/common/message.cpp:111
    [00:03:31.695,953] <err> os: r0/a1:  0x00000004  r1/a2:  0x00000024  r2/a3:  0x20002160
    [00:03:31.695,953] <err> os: r3/a4:  0x00000016 r12/ip:  0x00000000 r14/lr:  0x0002d887
    [00:03:31.695,983] <err> os:  xpsr:  0x61000000
    [00:03:31.695,983] <err> os: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
    [00:03:31.696,044] <err> os: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
    [00:03:31.696,075] <err> os: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
    [00:03:31.696,105] <err> os: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
    [00:03:31.696,105] <err> os: fpscr:  0x00000000
    [00:03:31.696,136] <err> os: Faulting instruction address (r15/pc): 0x0005162a
    [00:03:31.696,136] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
    [00:03:31.696,166] <err> os: Current thread: 0x20002f40 (sysworkq)
    [00:03:32.447,692] <err> fatal_error: Resetting system

  • The failing assert seems to be this one in MessagePool::Free :

    void MessagePool::Free(Message *aMessage)
    {
        OT_ASSERT(aMessage->Next() == nullptr && aMessage->Prev() == nullptr);
    
        FreeBuffers(static_cast<Buffer *>(aMessage));
    }

    Do you make any calls to this function in your code? If so you should check those.

  • Hi,

    Yes, I have seen that and corrected that, now this crash is resolved.

    In addition to that, fort he below shared prj.conf file, can you explain to me the use of some config parameters, if they are not useful to my application I will remove them to reduce application size:

    #
    # Copyright (c) 2020 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # To use GPIO Pins
    CONFIG_GPIO=y
    
    #Enable RTC
    CONFIG_COUNTER=y
    CONFIG_SYSTEM_CLOCK_NO_WAIT=y
    
    #Enable Logging
    CONFIG_LOG=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    CONFIG_SHELL_BACKEND_RTT=y
    CONFIG_LOG_PRINTK=y
    
    # Enable MTD Sleepy End Device
    CONFIG_OPENTHREAD_MTD=y
    CONFIG_OPENTHREAD_MTD_SED=y
    CONFIG_OPENTHREAD_POLL_PERIOD=30000
    CONFIG_RAM_POWER_DOWN_LIBRARY=y
    CONFIG_PM_DEVICE=y
    
    # This variant requires increased system workqueue stack size
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=1536
    
    #enable ADC for analog sensors
    CONFIG_HEAP_MEM_POOL_SIZE=1024
    CONFIG_ADC=y
    CONFIG_ADC_NRFX_SAADC=y
    
    #enable Flash
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_NVS=y
    CONFIG_REBOOT=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    #Enable sensors
    CONFIG_I2C=y
    CONFIG_SENSOR=y
    
    
    #enable SHTC3
    CONFIG_SHTCX=y
    
    # Enable CoAP utils and CoAP protocol
    CONFIG_COAP_UTILS=y
    CONFIG_OPENTHREAD_COAP=y
    
    # Configure sample logging setting
    CONFIG_COAP_CLIENT_LOG_LEVEL_DBG=y
    CONFIG_COAP_CLIENT_UTILS_LOG_LEVEL_DBG=y
    CONFIG_COAP_UTILS_LOG_LEVEL_DBG=y
    
    # Network shell
    CONFIG_SHELL=y
    CONFIG_OPENTHREAD_SHELL=y
    CONFIG_SHELL_ARGC_MAX=26
    CONFIG_SHELL_CMD_BUFF_SIZE=416
    
    # Generic networking options
    CONFIG_NETWORKING=y
    CONFIG_NET_L2_OPENTHREAD=y
    
    # Enable OpenThread features set
    CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y
    
    # Network sockets
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    CONFIG_NET_SOCKETS_POLL_MAX=4
    
    # Same network Master Key for client and server
    CONFIG_OPENTHREAD_NETWORKKEY="fb:9d:04:b4:bc:8d:7a:24:ee:e4:d1:fd:a2:fd:ed:0b"
    CONFIG_OPENTHREAD_PANID=64413
    
    
    CONFIG_OPENTHREAD_MANUAL_START=n
    CONFIG_OPENTHREAD_JOINER=y
    CONFIG_OPENTHREAD_JOINER_AUTOSTART=y
    CONFIG_OPENTHREAD_JOINER_PSKD="J01NTHREAD"
    CONFIG_SHELL_STACK_SIZE=3168
    
    CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF=y
    CONFIG_ASSERT=y
    CONFIG_ASSERT_NO_COND_INFO=n
    CONFIG_ASSERT_NO_MSG_INFO=n
    CONFIG_MBEDTLS_SHA1_C=n
    CONFIG_FPU=y
    CONFIG_OPENTHREAD_DEBUG=y
    CONFIG_OPENTHREAD_L2_DEBUG=y
    

    Above are all prj.conf:

    In the above file, I have mentioned the above configuration for why I have added them.

    Can you explain to me the below configuration and which of them can be removed:

    
    # This variant requires increased system workqueue stack size
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=1536
    
    
    # Configure sample logging setting
    #can I remove below logging settings:
    CONFIG_COAP_CLIENT_LOG_LEVEL_DBG=y
    CONFIG_COAP_CLIENT_UTILS_LOG_LEVEL_DBG=y
    CONFIG_COAP_UTILS_LOG_LEVEL_DBG=y
    
    # Network shell
    #are all these configs essential
    CONFIG_SHELL=y
    CONFIG_OPENTHREAD_SHELL=y
    CONFIG_SHELL_ARGC_MAX=26
    CONFIG_SHELL_CMD_BUFF_SIZE=416
    
    # Generic networking options
    CONFIG_NETWORKING=y
    CONFIG_NET_L2_OPENTHREAD=y
    
    # Enable OpenThread features set
    CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y
    
    # Network sockets
    #what does network socket means here?, can I remove them?
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    CONFIG_NET_SOCKETS_POLL_MAX=4
    
    
    CONFIG_OPENTHREAD_MANUAL_START=n
    CONFIG_OPENTHREAD_JOINER=y
    CONFIG_OPENTHREAD_JOINER_AUTOSTART=y
    CONFIG_OPENTHREAD_JOINER_PSKD="J01NTHREAD"
    CONFIG_SHELL_STACK_SIZE=3168
    
    
    #use of belwo configurations in openthread
    CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF=y
    CONFIG_ASSERT=y
    CONFIG_ASSERT_NO_COND_INFO=n
    CONFIG_ASSERT_NO_MSG_INFO=n
    CONFIG_MBEDTLS_SHA1_C=n
    CONFIG_FPU=y
    CONFIG_OPENTHREAD_DEBUG=y
    CONFIG_OPENTHREAD_L2_DEBUG=y
    

  • This is a different issue than the one asked about in the original post, so please open a new ticket for this.

    Separating each distinct issue into their own tickets makes the forum much easier to read and search.

Related