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,

    Try adding CONFIG_SHELL_BACKEND_SERIAL=n to your prj.conf file.

  • Hi,

    I have done this and added this config in prj.conf.

    Now my application is getting built, but I am facing a runtime crash in the application.

    Following is the crash message:

    [00:00:32.095,489] <err> os: ***** MPU FAULT *****
    [00:00:32.101,257] <err> os:   Data Access Violation
    [00:00:32.107,177] <err> os:   MMFAR Address: 0x20011260
    [00:00:32.113,494] <err> os: r0/a1:  0x0004e5ab  r1/a2:  0x00061914  r2/a3:  0x00066c1a
    [00:00:32.122,650] <err> os: r3/a4:  0x20011308 r12/ip:  0x00000020 r14/lr:  0x0000a37d
    [00:00:32.131,774] <err> os:  xpsr:  0x21000000
    [00:00:32.137,268] <err> os: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
    [00:00:32.148,284] <err> os: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
    [00:00:32.159,271] <err> os: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
    [00:00:32.170,257] <err> os: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
    [00:00:32.181,274] <err> os: fpscr:  0xaaaaaaaa
    [00:00:32.186,767] <err> os: Faulting instruction address (r15/pc): 0x000091f0
    [00:00:32.195,068] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
    [00:00:32.203,399] <err> os: Current thread: 0x20001c00 (unknown)
    [00:00:32.220,550] <err> fatal_error: Resetting system

    When I checked the error file using the following command:

    ➜ build git:(master) ✗ arm-none-eabi-addr2line -e zephyr/zephyr.elf 0x000091f0

    zephyr/lib/os/cbprintf_complete.c:1339

    So it is giving an error in this file, can you help me in resolving this crash?

  • You can try adding CONFIG_SHELL=n or CONFIG_SHELL_BACKEND_DUMMY=y

    Only one of them at a time.

  • can you also explain to me the role of these configs in prj.conf?

  • Checking if the problem is due to having shell enabled with no backend enabled.

    CONFIG_SHELL=n would try to disable shell.

    CONFIG_SHELL_BACKEND_DUMMY=y would instead keep shell enabled, but give it a dummy backend, so it won't run into issues due to lacking a backend.

    It would be useful to know if your code contains any printf() calls, and if so where would you like those to be printed?

Related