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?

  • hi,

    I am not planning to make any printf() calls, if there are any, I want those to be printed on JLink RTT logs.

    So yes, this is my question, how can I enable only RTT logs, with overflow enabled with a buffer of 512 only. 

    All other printf() calls can be replaced with RTT logs.

  • Could you post your prj.conf file here?

  • I have in prj.conf file all CONFIG related to the following functionality:

    1. ADC

    2. Flash read and write

    3. I2C sensor read

    4. RTC

    5. Openthread node in SED mode

    6. Openthread joiner enabled and node not pre-commissioned

    Here is my prj.conf file:

    #
    # Copyright (c) 2020 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    CONFIG_GPIO=y
    
    #Enable Logging
    CONFIG_LOG=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    
    #Enable RTC
    CONFIG_COUNTER=y
    CONFIG_SYSTEM_CLOCK_NO_WAIT=y
    
    #enable ADC for analog sensors
    CONFIG_HEAP_MEM_POOL_SIZE=1024
    CONFIG_ADC=y
    CONFIG_ADC_NRFX_SAADC=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 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
    
    #enable Flash read and write
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_NVS=y
    CONFIG_REBOOT=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=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=y
    CONFIG_ASSERT_NO_MSG_INFO=y
    CONFIG_MBEDTLS_SHA1_C=n
    CONFIG_FPU=y
    CONFIG_OPENTHREAD_DEBUG=y
    CONFIG_OPENTHREAD_L2_DEBUG=y

    If there are any such CONFIG that is not essential kindly let me know.

    As far as logging is considered, I want my logs only on JLink RTT platform and no where else.

    want to disable UART shell in the code.

  • Try adding CONFIG_SHELL_BACKEND_RTT=y. You can also try CONFIG_LOG_PRINTK=y

    If that doesn't work, it would be great if you could tell me where in your code that it fails.

  • I get the following crash error in my code:

    ASSERTION FAIL @ WEST_TOPDIR/zephyr/subsys/net/lib/openthread/platform/misc.c:36
    [00:01:01.697,052] <err> os: r0/a1:  0x00000004  r1/a2:  0x00000024  r2/a3:  0x20002160
    [00:01:01.697,052] <err> os: r3/a4:  0x00000015 r12/ip:  0x00000000 r14/lr:  0x0002c113
    [00:01:01.697,052] <err> os:  xpsr:  0x61000000
    [00:01:01.697,082] <err> os: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
    [00:01:01.697,082] <err> os: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
    [00:01:01.697,113] <err> os: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
    [00:01:01.697,143] <err> os: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
    [00:01:01.697,143] <err> os: fpscr:  0x00000000
    [00:01:01.697,174] <err> os: Faulting instruction address (r15/pc): 0x0004feb6
    [00:01:01.697,204] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
    [00:01:01.697,204] <err> os: Current thread: 0x20002f40 (sysworkq)
    [00:01:02.526,641] <err> fatal_error: Resetting system

    and when I run 

    arm-none-eabi-addr2line -e zephyr/zephyr.elf  0x0004feb6
    


    I get following output:
    /Users/bhumika/Project/Zipnet_Zephyr/zephyr/lib/os/assert.c:46


    So basically I get a k_panic(); in my code, but what exactly causes this K_panic() I have no idea.

    Also "ASSERTION FAIL @ WEST_TOPDIR/zephyr/subsys/net/lib/openthread/platform/misc.c:36", at this location I have following code:

    void otPlatAssertFail(const char *aFilename, int aLineNumber)
    {
    	__ASSERT(false, "OpenThread ASSERT @ %s:%d", aFilename, aLineNumber);
    }


    Can you help me fix this assertion error?

Related