Enabling watchdog timer on 52840 using Zephyr

Hello,

I'm trying to enable the watchdog timer on 52840 using Zephyr.

I'm attempting to follow, as relevant, the example in the samples directory.

It appears that the driver doesn't get set up in Zephyr. (I get the dreaded "undefined reference to `__device_dts_ord_153'".)

Furthermore, it appears that CONFIG_WATCHDOG is not getting set, even though I'm setting it to y in my prj.conf file. (Parts of my code with #ifdef CONFIG_WATCHDOG don't get compiled.)

It also appears that CONFIG_NRFX_WDT is not getting set, even if I explicitly set it in my prj.conf. (My understanding is that it should be set implicitly.)

My board configuration file #include's nordic/nrf52840_qiaa.dtsi, which in turn #include's nordic/nrf52840.dtsi, which I see sets the watchdog status to "okay".

For good measure, I also set the status to "okay" in my overlay file.
What is missing?
Thanks!
Parents
  • Hi

    This looks like a DTS configuration issue. The message "undefined reference to `__device_dts_ord_153'" doesn't tell us much, other than that the dts (device tree structure) is missing something. These numbers are not static, and different for each build, so to see which one it refers to, you need to look in your build folder.

    Check the file found in build\zephyr\include\generated\devicetree_generated.h

    In an example case, 153 could refer to usbd@36000/cdc_acm_uart1, o you need to find out what it refers to in your project. 

    Best regards,

    Simon

  • Sorry, I should have been clearer. Device 153 is in fact the watchdog timer (watchdog). (I figured you'd infer that from the fact that I'm talking about the watchdog timer not coming up.)

    The tl;dr of my inquiry is:

    • The watchdog timer is set to "okay" in the DT files (both Nordic's and my own overlay - belt and suspenders).
    • I've set CONFIG_WATCHDOG=y in my project's prj.conf.
    • Despite this, the watchdog device isn't being defined in Zephyr (the corresponding DEVICE_DT_GET() generates the dread "__device_dts_ord_n" error).

    Another data point is that I've also determined that CONFIG_NRFX_WDT is not set.

    In zephyr/dts/arm/nordic/nrf52840.dtsi:

            wdt: wdt0: watchdog@40010000 {
                compatible = "nordic,nrf-wdt";
                reg = <0x40010000 0x1000>;
                interrupts = <16 NRF_DEFAULT_IRQ_PRIORITY>;
                status = "okay";
            };
    In my overlay file:
    /{
        aliases {
            ....
            wdt = &wdt;
        };
    };

    &wdt {
        status = "okay";
    };
    In my project's prj.conf:
    CONFIG_WATCHDOG=y
    In my code:
    mystruct_t mystruct = {
        ....
        .wdt = DEVICE_DT_GET(DT_ALIAS(wdt)),
        ....
    };
    Error on that DEVICE_DT_GET() line: "undefined reference to `__device_dts_ord_153'"
    In devicetree_generated.h:
    *   153 /soc/watchdog@40010000
    Thanks!
  • I suppose I should also mention that I'm using NCS v2.3.0, with Zephyr 3.2.99.

  • Some more tracing:

    CONFIG_WATCHDOG is defined in zephyr/drivers/watchdog/Kconfig:

    menuconfig WATCHDOG
        bool "Watchdog Support"
        help
          Include support for watchdogs.

    if WATCHDOG

    .... various other configs ....
    .... sourcing of various MCU-specific Kconfig files ....
    source "drivers/watchdog/Kconfig.nrfx"

    endif
    In zephyr/drivers/watchdog/Kconfig.nrfx, I see:
    config WDT_NRFX
    bool "nRF WDT nrfx driver"
    default y
    depends on DT_HAS_NORDIC_NRF_WDT_ENABLED
    select NRFX_WDT0 if HAS_HW_NRF_WDT0
    select NRFX_WDT1 if HAS_HW_NRF_WDT1
    help
    Enable support for nrfx WDT driver for nRF MCU series.
    Symbol DT_HAS_NORDIC_NRF_WDT_ENABLED is defined in my build, in <project>/build/Kconfig/Kconfig.dts:
    DT_COMPAT_NORDIC_NRF_WDT := nordic,nrf-wdt

    config DT_HAS_NORDIC_NRF_WDT_ENABLED
    def_bool $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_WDT))
    Since a nordic,nrf-wdt compatible is defined in nrf52840.dtsi - as shown in my earlier post - this should evaluate to y.
    As for HAS_HW_NRF_WDT0/HAS_HW_NRF_WDT1, they are defined in zephyr/soc/arm/nordic_nrf/Kconfig.peripherals, which I assume is included in any NRF build:
    config HAS_HW_NRF_WDT0
    def_bool $(dt_nodelabel_enabled_with_compat,wdt0,$(DT_COMPAT_NORDIC_NRF_WDT))

    config HAS_HW_NRF_WDT1
    def_bool $(dt_nodelabel_enabled_with_compat,wdt1,$(DT_COMPAT_NORDIC_NRF_WDT))
    So, as far as I can see, all the configuration should be there for enabling wdt.
    But obvs I'm missing something...
Reply
  • Some more tracing:

    CONFIG_WATCHDOG is defined in zephyr/drivers/watchdog/Kconfig:

    menuconfig WATCHDOG
        bool "Watchdog Support"
        help
          Include support for watchdogs.

    if WATCHDOG

    .... various other configs ....
    .... sourcing of various MCU-specific Kconfig files ....
    source "drivers/watchdog/Kconfig.nrfx"

    endif
    In zephyr/drivers/watchdog/Kconfig.nrfx, I see:
    config WDT_NRFX
    bool "nRF WDT nrfx driver"
    default y
    depends on DT_HAS_NORDIC_NRF_WDT_ENABLED
    select NRFX_WDT0 if HAS_HW_NRF_WDT0
    select NRFX_WDT1 if HAS_HW_NRF_WDT1
    help
    Enable support for nrfx WDT driver for nRF MCU series.
    Symbol DT_HAS_NORDIC_NRF_WDT_ENABLED is defined in my build, in <project>/build/Kconfig/Kconfig.dts:
    DT_COMPAT_NORDIC_NRF_WDT := nordic,nrf-wdt

    config DT_HAS_NORDIC_NRF_WDT_ENABLED
    def_bool $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_WDT))
    Since a nordic,nrf-wdt compatible is defined in nrf52840.dtsi - as shown in my earlier post - this should evaluate to y.
    As for HAS_HW_NRF_WDT0/HAS_HW_NRF_WDT1, they are defined in zephyr/soc/arm/nordic_nrf/Kconfig.peripherals, which I assume is included in any NRF build:
    config HAS_HW_NRF_WDT0
    def_bool $(dt_nodelabel_enabled_with_compat,wdt0,$(DT_COMPAT_NORDIC_NRF_WDT))

    config HAS_HW_NRF_WDT1
    def_bool $(dt_nodelabel_enabled_with_compat,wdt1,$(DT_COMPAT_NORDIC_NRF_WDT))
    So, as far as I can see, all the configuration should be there for enabling wdt.
    But obvs I'm missing something...
Children
No Data
Related