Facing issue in RTC

I want to use RTC in my project. I'm facing build issue (undefined reference to `__device_dts_ord_113') in my project . 

STEPS TAKEN:
1. I have enabled the RTC configuration in your prj.conf file.
2. I have  define the RTC node and alias in my DTS file.

3.Clean and rebuild my project.

Please give me a solution for that.

SDK Version  -  v2.6.1
Custom Board - nrf7002dk_nrf5340  

RTC Project file

#include <zephyr/drivers/rtc.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL);

/*
===========================
 project Includes
===========================
*/
#include "main.h"

/*
=================================
 Macro Definitions
=================================
*/

#define RTC_TEST_ALARM_SET_TIME		      (1609507790)

static const struct device *rtc = DEVICE_DT_GET(DT_ALIAS(rtc));



#include <zephyr/types.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <zephyr/sys/printk.h>
#include <zephyr/sys/byteorder.h>
#include <soc.h>
int main(void)
{
	int err;
	int ret;
    time_t timer_set;
  //  time_t timer_get;
	struct rtc_time time_set;


	printk("Starting GATT Discovery Manager example\n");
	/* Initialize RTC time to set */
	timer_set = RTC_TEST_ALARM_SET_TIME;

	gmtime_r(&timer_set, (struct tm *)(&time_set));

	time_set.tm_isdst = -1;
	time_set.tm_nsec = 0;

	
	/* Set RTC time */
	ret = rtc_set_time(rtc, &time_set);
	printk("rtc_set_time done\n");
	//printk("Failed to set time");
	
      //  ret = rtc_get_time(rtc, &time_get);
		printk("rtc_get_time done\n");

	
	return 0;
}

Project Configuration file

# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
#
# This file contains selected Kconfig options for the application.

CONFIG_SENSOR=y
CONFIG_APP_EVENT_MANAGER=y
CONFIG_REBOOT=y
CONFIG_TFM_KEY_FILE_S="D:/nrf_projects/Workspace/modules/tee/tf-m/trusted-firmware-m/bl2/ext/mcuboot/root-RSA-3072.pem"
CONFIG_TFM_KEY_FILE_NS="D:/nrf_projects/Workspace/modules/tee/tf-m/trusted-firmware-m/bl2/ext/mcuboot/root-RSA-3072_1.pem"

CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y

CONFIG_POSIX_MQUEUE=y
CONFIG_POLL=y
CONFIG_PWM=y
CONFIG_GPIO=y
CONFIG_RTC=y

# compiler
CONFIG_DEBUG_OPTIMIZATIONS=y

# console
CONFIG_CONSOLE=y

# UART console
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=y

# logging
CONFIG_LOG=y
CONFIG_APP_LOG_LEVEL_DBG=y

#wifi log
CONFIG_NRFX_QSPI_LOG=y
CONFIG_NRFX_CLOCK_LOG=y
# CONFIG_WIFI_NRF700X_BUS_LOG_LEVEL_ERR=y
# CONFIG_WIFI_NRF700X_BUS_LOG_LEVEL_INF=y
# CONFIG_WIFI_NRF700X_BUS_LOG_LEVEL_WRN=y
# CONFIG_WIFI_NRF700X_BUS_LOG_LEVEL_DBG=y
# CONFIG_WIFI_NRF700X_BUS_LOG_LEVEL_DEFAULT=y

#WIFI
CONFIG_WIFI_FIXED_MAC_ADDRESS="22:22:22:44:44:44"

CONFIG_WIFI=y
CONFIG_WIFI_NRF700X=y

# Include WPA Supplement.
CONFIG_WPA_SUPP=y

# System settings
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_NANO=n

# Networking
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_LOG=y
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=n
CONFIG_NET_UDP=y
CONFIG_NET_TCP=y
# Use DHCP for IPv4
CONFIG_NET_DHCPV4=y
CONFIG_DNS_RESOLVER=y
# CONFIG_DNS_RESOLVER_AI_MAX_ENTRIES=10

CONFIG_NET_STATISTICS=y
CONFIG_NET_PKT_RX_COUNT=8
CONFIG_NET_PKT_TX_COUNT=8
# CONFIG_NET_PKT_RX_COUNT=10
# CONFIG_NET_PKT_TX_COUNT=10

CONFIG_NET_BUF_RX_COUNT=20
CONFIG_NET_BUF_TX_COUNT=20
CONFIG_NET_BUF_DATA_SIZE=128
CONFIG_HEAP_MEM_POOL_SIZE=153600
CONFIG_NET_TC_TX_COUNT=1

CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
# CONFIG_NET_MAX_CONTEXTS=10
CONFIG_NET_MAX_CONTEXTS=5
CONFIG_NET_CONTEXT_SYNC_RECV=y

CONFIG_INIT_STACKS=y
CONFIG_NET_L2_WIFI_MGMT=y

# Or assign a static IP address (useful for testing)
# Following line must be enabled, otherwise WiFi connection fails with -1.
CONFIG_NET_CONFIG_SETTINGS=y
# Add CONFIG_INIT_TIMEOUT to prevent 30 second timeout when starting:
# [00:00:30.600,250] <err> net_config: Timeout while waiting network interface
# [00:00:30.600,250] <err> net_config: Network initialization failed (-115)
# CONFIG_NET_CONFIG_INIT_TIMEOUT=1
CONFIG_NET_CONFIG_INIT_TIMEOUT=0
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.165.100.150"
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.165.100.1"

CONFIG_NET_SOCKETS_POLL_MAX=10


# CONFIG_HTTP_CLIENT=y


# CONFIG_NET_CONFIG_AUTO_INIT=y

# CONFIG_NET_CONFIG_NEED_IPV4=y
CONFIG_NET_CONFIG_MY_IPV4_NETMASK="255.255.255.0"
CONFIG_NET_CONFIG_MY_IPV4_GW="192.168.1.1"
CONFIG_NET_CONFIG_NEED_IPV6=n
#CONFIG_NET_CONFIG_MY_IPV6_ADDR="fe80::100"

# Enabling logging can be helpful for debugging
CONFIG_WIFI_LOG_LEVEL_ERR=y
# CONFIG_NET_IPV6_LOG_LEVEL_DBG=y

CONFIG_NET_TX_STACK_SIZE=4096
CONFIG_NET_RX_STACK_SIZE=4096

# Added to prevent error with missing #include <ethernet/eth_stats.h> for esp_wifi_drv.c
# Adding this line will cause CMAKE Warning: No SOURCES given to Zephyr library: drivers__ethernet
# Just ignore.
CONFIG_NET_L2_ETHERNET=y

# Enable nordic security backend and PSA APIs
CONFIG_NRF_SECURITY=y
CONFIG_MBEDTLS_PSA_CRYPTO_C=y

CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=8192

# Required to prevent undefined reference to `z_impl_sys_rand32_get'
CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y

CONFIG_MAIN_STACK_SIZE=4096
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

#Bluetooth
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Nordic Discovery Sample"

CONFIG_BT_SMP=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GATT_DM=y
CONFIG_BT_GATT_DM_DATA_PRINT=y

CONFIG_BT_BUF_ACL_RX_SIZE=151
CONFIG_BT_L2CAP_TX_MTU=147
CONFIG_BT_BUF_ACL_TX_SIZE=151

CONFIG_BT_RX_STACK_SIZE=5120
CONFIG_BT_BONDABLE=n

CONFIG_WIFI_MGMT_EXT=y
# Setting BT supervision timeout to 75units (750ms) to avoid timeout of BT connection when radio is granted to Wi-Fi during scan.
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=75

# Similar to shell sample, add this option to ensure the event can get served.
CONFIG_NET_MGMT_EVENT_QUEUE_TIMEOUT=5000

# Needed to print UUID.
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_GATT_DM_DATA_PRINT=y

CONFIG_DK_LIBRARY=y

#spi
CONFIG_SPI=y

CONFIG_FLASH=y
#prov
CONFIG_WIFI_CREDENTIALS=y
CONFIG_WIFI_CREDENTIALS_MAX_ENTRIES=1

CONFIG_NANOPB=y

CONFIG_BT_WIFI_PROV=y
CONFIG_BT_WIFI_PROV_LOG_LEVEL_INF=y

CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y

CONFIG_NVS=y

CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS=y

Overlay 

Overlay
/ {
    aliases {
        rtc = &rtc0;
    };

    soc {
        peripheral@50000000 {
            rtc0: rtc@14000 {
                status = "okay";
            };
            rtc1: rtc@15000 {
                status = "disabled";
            };
        };
    };
};

Error log

Building Node_1
C:\WINDOWS\system32\cmd.exe /d /s /c "west build -t clean --build-dir c:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/build_1"

-- west build: running target clean
[2/2] Cleaning all built files...
Cleaning... 560 files.
* Terminal will be reused by tasks, press any key to close it.

* Executing task: nRF Connect: Build: Node_1/build_1 (active)

Building Node_1
C:\WINDOWS\system32\cmd.exe /d /s /c "west build --build-dir c:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/build_1 c:/ncs/v2.6.1/Waggle_Sensors/application/Node_1"

[4/552] Generating include/generated/version.h
-- Zephyr version: 3.5.99 (C:/ncs/v2.6.1/zephyr), build: v3.5.99-ncs1-1
[1/3] Linking C executable zephyr\zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 175460 B 256 KB 66.93%
RAM: 47692 B 64 KB 72.77%
SRAM1: 0 GB 64 KB 0.00%
IDT_LIST: 0 GB 32 KB 0.00%
[193/552] Building C object CMakeFiles/app.dir/src/CoreCode/Tasks/source/CloudManager.c.obj
C:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/src/CoreCode/Tasks/source/CloudManager.c: In function 'CloudManagerTask':
C:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/src/CoreCode/Tasks/source/CloudManager.c:103:34: warning: passing argument 1 of 'Get_uart_buf' from incompatible pointer type [-Wincompatible-pointer-types]
103 | if((Get_uart_buf(&tx_buf) == 0))
| ^~~~~~~
| |
| char (*)[32]
In file included from C:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/src/CoreCode/Tasks/include/CloudManager.h:32,
from C:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/src/CoreCode/Tasks/source/CloudManager.c:23:
C:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/src/CoreCode/Tasks/include/SystemUpgradeManager.h:51:25: note: expected 'char *' but argument is of type 'char (*)[32]'
51 | bool Get_uart_buf(char *buf);
| ~~~~~~^~~
[197/552] Building C object CMakeFiles/app.dir/src/Main/main.c.obj
C:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/src/Main/main.c: In function 'main':
C:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/src/Main/main.c:334:9: warning: implicit declaration of function 'gmtime_r' [-Wimplicit-function-declaration]
334 | gmtime_r(&timer_set, (struct tm *)(&time_set));
| ^~~~~~~~
C:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/src/Main/main.c:323:13: warning: unused variable 'err' [-Wunused-variable]
323 | int err;
| ^~~
[545/552] Linking C executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map C:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/build_1/zephyr/zephyr_pre0.map
cmd.exe /C "cd . && C:\ncs\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -gdwarf-4 @CMakeFiles\zephyr_pre0.rsp -o zephyr\zephyr_pre0.elf && cmd.exe /C "cd /D C:\ncs\v2.6.1\Waggle_Sensors\application\Node_1\build_1\zephyr && C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.exe -E true""
c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj): in function `main':
C:/ncs/v2.6.1/Waggle_Sensors/application/Node_1/src/Main/main.c:390: undefined reference to `__device_dts_ord_113'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.EXE' --build 'c:\ncs\v2.6.1\Waggle_Sensors\application\Node_1\build_1'

* The terminal process terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.

Parents
  • Hi,

    /main.c:390: undefined reference to `__device_dts_ord_113'

    What is at line 390 in the main.c file?

    regards

    Jared 

  • Hi,


    /main.c:390: } 

    Line 390 is closed curly bracket

  • Hi,

    I have shared the file here.

    The 390th line is the last line of the code.


    I have built the code with the commented lines so that it shows 390 lines, but my actual code is given below. I have done this to ensure that line 390 corresponds to the last line of the code. Please review the provided code to help identify any issues or errors that might be present


    #include <zephyr/drivers/rtc.h>
    
    #include <zephyr/logging/log.h>
    LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL);
    
    /*
    ===========================
     project Includes
    ===========================
    */
    #include "main.h"
    
    /*
    =================================
     Macro Definitions
    =================================
    */
    
    #define RTC_TEST_ALARM_SET_TIME		      (1609507790)
    
    static const struct device *rtc = DEVICE_DT_GET(DT_ALIAS(rtc));
    
    
    
    #include <zephyr/types.h>
    #include <stddef.h>
    #include <string.h>
    #include <errno.h>
    #include <zephyr/sys/printk.h>
    #include <zephyr/sys/byteorder.h>
    #include <soc.h>
    int main(void)
    {
    	int err;
    	int ret;
        time_t timer_set;
      //  time_t timer_get;
    	struct rtc_time time_set;
    
    
    	printk("Starting GATT Discovery Manager example\n");
    	/* Initialize RTC time to set */
    	timer_set = RTC_TEST_ALARM_SET_TIME;
    
    	gmtime_r(&timer_set, (struct tm *)(&time_set));
    
    	time_set.tm_isdst = -1;
    	time_set.tm_nsec = 0;
    
    	
    	/* Set RTC time */
    	ret = rtc_set_time(rtc, &time_set);
    	printk("rtc_set_time done\n");
    	//printk("Failed to set time");
    	
          //  ret = rtc_get_time(rtc, &time_get);
    		printk("rtc_get_time done\n");
    
    	
    	return 0;
    }

    regards


    Sasikumar

Reply
  • Hi,

    I have shared the file here.

    The 390th line is the last line of the code.


    I have built the code with the commented lines so that it shows 390 lines, but my actual code is given below. I have done this to ensure that line 390 corresponds to the last line of the code. Please review the provided code to help identify any issues or errors that might be present


    #include <zephyr/drivers/rtc.h>
    
    #include <zephyr/logging/log.h>
    LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL);
    
    /*
    ===========================
     project Includes
    ===========================
    */
    #include "main.h"
    
    /*
    =================================
     Macro Definitions
    =================================
    */
    
    #define RTC_TEST_ALARM_SET_TIME		      (1609507790)
    
    static const struct device *rtc = DEVICE_DT_GET(DT_ALIAS(rtc));
    
    
    
    #include <zephyr/types.h>
    #include <stddef.h>
    #include <string.h>
    #include <errno.h>
    #include <zephyr/sys/printk.h>
    #include <zephyr/sys/byteorder.h>
    #include <soc.h>
    int main(void)
    {
    	int err;
    	int ret;
        time_t timer_set;
      //  time_t timer_get;
    	struct rtc_time time_set;
    
    
    	printk("Starting GATT Discovery Manager example\n");
    	/* Initialize RTC time to set */
    	timer_set = RTC_TEST_ALARM_SET_TIME;
    
    	gmtime_r(&timer_set, (struct tm *)(&time_set));
    
    	time_set.tm_isdst = -1;
    	time_set.tm_nsec = 0;
    
    	
    	/* Set RTC time */
    	ret = rtc_set_time(rtc, &time_set);
    	printk("rtc_set_time done\n");
    	//printk("Failed to set time");
    	
          //  ret = rtc_get_time(rtc, &time_get);
    		printk("rtc_get_time done\n");
    
    	
    	return 0;
    }

    regards


    Sasikumar

Children
No Data
Related