Calling wdt_setup returns EBUSY

Toolchain v2.70, SDK v2.7.0, VS Code, Windows

I am trying to enable the watchdog in my application, and I can successfully locate the device node and add a timeout, but when I call wdt_setup, it returns EBUSY. According to the docs, this means that it has already been setup. But I have not configured it, so I am at a loss as to how this is happening. I am building for FOTA, so I guess there is a boot loader running ahead of my code. Could that be setting up the watchdog and stopping me using it in my application?

The code is pretty simple:

        struct device const *wdt = DEVICE_DT_GET(DT_NODELABEL(wdt0));

        if( wdt ) {

                struct wdt_timeout_cfg cfg = {};

                cfg.flags      = WDT_FLAG_RESET_SOC;
                cfg.window.min = 0u;
                cfg.window.max = 1000u;

                int chan = wdt_install_timeout(wdt, &cfg);

                if( chan >= 0 ) {
                               
                        int r = wdt_setup(wdt, WDT_OPT_PAUSE_HALTED_BY_DBG);

                        if( !r ) {

                                for(;;) {

                                        k_sleep(K_MSEC(500));

                                        wdt_feed(wdt, chan);
                                }
                        }
                }
        }
Any ideas would be appreciated...
Parents Reply Children
Related