I encounter an "undefined reference to `__device_dts_ord_152'" error when attempting to incorporate the peripheral_uart demo code into my customized application. Can you please assist me in resolving this issue?

I'm encountering difficulties while integrating the logic from the peripheral_uart into my customized application. To showcase the problem, I've created a brief video available at this link: https://youtube.com/live/h0GjFsJRF_0

It appears that I may have overlooked certain configurations within the .prj file, KConfig, or device tree. I would greatly appreciate your assistance in troubleshooting this issue.

  • Hi,

    First off the video is amazing for a support ticket! I'm not super experienced with the uart over bluetooth stuff, but have used wired UART a lot. I didn't see where you had any uart drivers enabled in prj.conf but I may have just missed it.

    From peripheral uart example:

    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_SERIAL=y
    CONFIG_GPIO=y
    

  • Thank you for your prompt reply. I have added all of the above in my prj.conf. Below is what I have in my file. It may be even related to my KConfig or overlay files too. I can share the repo on gihuib if that might be easier to troubleshoot.

    I believe the issue is related to this line:
    static const struct device *uart = DEVICE_DT_GET(DT_CHOSEN(nordic_nus_uart);

    What is nordic_nus_uart ?

    prj.conf

    CONFIG_STDOUT_CONSOLE=y
    CONFIG_PRINTK=y
    CONFIG_PWM=y
    CONFIG_I2C=y
    CONFIG_LOG=y
    CONFIG_LOG_PRINTK=y
    CONFIG_LOG_MODE_IMMEDIATE=y
    CONFIG_PWM_LOG_LEVEL_DBG=y
    CONFIG_USE_SEGGER_RTT=y

    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_SERIAL=y
    CONFIG_GPIO=y

    #SPI
    CONFIG_SPI=y
    CONFIG_NRFX_SPIM3=y
    CONFIG_NRFX_SPIM4=y
    CONFIG_SPI_ASYNC=y
    CONFIG_SPI_SLAVE=y

    #Floating point
    CONFIG_CBPRINTF_FP_SUPPORT=y

    # BT
    CONFIG_BT=y
    CONFIG_BT_DEBUG_LOG=y

    CONFIG_BT_CENTRAL=y
    CONFIG_BT_PERIPHERAL=y

    CONFIG_BT_SCAN=y
    CONFIG_BT_SCAN_FILTER_ENABLE=y
    CONFIG_BT_SCAN_NAME_CNT=1
    CONFIG_BT_SCAN_MANUFACTURER_DATA_CNT=1
    CONFIG_BT_SCAN_WITH_IDENTITY=y

    CONFIG_BT_EXT_ADV=y

    CONFIG_BT_DEVICE_NAME="ANTSHIV Robotics BLE"
    CONFIG_BT_DDFS=y
    CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1

    # Enable the NUS service
    CONFIG_BT_NUS=y

    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y

    # Enable DK LED and Buttons library
    CONFIG_DK_LIBRARY=y

    # This example requires more workqueue stack
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
  • I have uploaded my code on GitHub for easy access: You can find it at this repository: https://github.com/antshiv/nrf5340DroneCode.git

    Feel free to clone the repository, compile the code, and identify any issues that may arise. It's possible that I have overlooked some essential configuration settings.

  • Neat video!

    I have seen a lot of videos that are less than helpful, but this one actually really helped, and I also like your channel. Looking forward to seeing more of it!

    Just to answer the question at the end of the video, while I remember it:

    nordic_nus_uart: NUS is short for Nordic UART Service, which is a Bluetooth Service that we have used a lot for quite some time. It is a simple Bluetooth Low Energy service simulating a wireless UART connection. It doesn't actually need to use a physical UART (but the sample does so by default). It is simply a "tunnel" that can send data strings in both directions. 

    Now: nordic_nus_uart -> Nordic NUS UART -> Nordic Nordic UART Service UART. It is just a naming thing, and not a very good one, I might add. It just means "the uart instance that we will use for our NUS BLE service. So basically, a hook to one of the UART instances on the DK.

    I downloaded your project, and built it in v2.4.0. (You are probably using NCS v2.3.0 or earlier, since v2.4.0 was released yesterday, but since it builds just fine* in v2.4.0, I recommend using that, and you will include a couple of bugfixes as well). 

    *builds just fine, meaning it doesn't throw any other errors than the one you are seeing, undefined reference to __device_dts_ord_...

    When I built, I got an undefined reference to device_dts_ord_153, not 152, but I am not sure if that is because we are building on different computers, or if I used v2.4.0 and you did not. However, this message in itself doesn't tell me much, other than dts (device tree structure) is missing something. These numbers are not static, so to see which one it refers to, you need to look in your build folder.

    (I just recently learned this, so it is not really that intuitive).

    Check the file found in:

    build\zephyr\include\generated\devicetree_generated.h

    In my case, 153 refers to usbd@36000/cdc_acm_uart1. Is that the case for your 152 as well?

    You should know that it is possible to use the USB peripheral instead of the UART as an input/output in this application, but I believe you are trying to use the actual UART. 

    Both your main.c and prj.conf are looking good. The reason the peripheral_uart sample builds, while your doesn't is due to a kind of complex build system. In the peripheral_uart folder, there is a file called app.overlay. You have this file in your application folder as well, but since you also have a file in boards\nrf5340dk_nrf5340_cpuapp.overlay, this is chosen by default, overriding the app.overlay. 

    When building your project, I can see from close to the top of the build log:

    -- Found devicetree overlay: C:/Nordic_Semiconductor/SDKs/ncs/my_projects/2.4.0/test/nrf5340DroneCode-master/boards/nrf5340dk_nrf5340_cpuapp.overlay

    While if you build the peripheral_uart sample, you will see:

    -- Found devicetree overlay: c:/Nordic_Semiconductor/SDKs/ncs/my_projects/2.4.0/bluetooth/peripheral_uart/app.overlay

    It is possible to override the automatic selection of these by using the additional CMake command "-DDTC_OVERLAY_FILE=app.overlay" when creating your build configuration:

    But I don't think you want to do this, because it looks like you have already set a lot of settings here, so you probably want to keep using your nrf5340dk_nrf5340_cpuapp.overlay file (removing it gives other build errors). 

    So to build your application, you need to change line 34 in your boards\nrf5340dk_nrf5340_cpuapp.overlay from:
    nordic,nus-uart = &cdc_acm_uart1;
    to:
    nordic,nus-uart = &uart0;

    And it should build, using the UART as expected.

    Best regards,

    Edvin

  • I appreciate your response greatly. It's quite amusing that you mentioned substituting it with uart0, as I actually went ahead and did that, which allowed it to compile successfully. However, despite this change, the BLE initialization and advertising still fail to work. The specific error message I encounter is -5.

    In addition to the uart0 replacement, I've taken a few other steps. Firstly, I updated the SDK to version 2.4, for which I thank you for providing the information. Furthermore, I've created a video to showcase and demonstrate the current issue I'm facing. You can find the video at the following link: https://www.youtube.com/live/hx9JIXuMfqc?feature=share

Related