Arm Mbed OS support forum

Can't enable Watchdog on nrf52840

Hello everyone!

I am having linker issues when compiling my code with a Watchdog.
I am using the target nRF52840_DK.

This is my mbed_app.json file:

{
    "target_overrides": {
      "*": {
        "target.mbed_app_start": "0x27000",
        "target.mbed_app_size": "0xC6000",
        "target.bootloader_img": null,
        "target.macros_add": ["DEVICE_WATCHDOG"]
      }
    }
}

As I understand, I need to define "DEVICE_WATCHDOG" but I might be mistaken. If I don’t define it, I get compiler errors. With the configuration shown above, I get the following linker errors:

    Error: L6218E: Undefined symbol nrfx_wdt_channel_alloc (referred from BUILD/NRF52840_DK/ARMC6/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/watchdog_api.o).
    Error: L6218E: Undefined symbol nrfx_wdt_enable (referred from BUILD/NRF52840_DK/ARMC6/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/watchdog_api.o).
    Error: L6218E: Undefined symbol nrfx_wdt_feed (referred from BUILD/NRF52840_DK/ARMC6/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/watchdog_api.o).
    Error: L6218E: Undefined symbol nrfx_wdt_init (referred from BUILD/NRF52840_DK/ARMC6/mbed-os/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/watchdog_api.o).

For reference, this is my main.cpp code:

#include <mbed.h>
#include "MainController.h"
#include "Configuration.h"
#include "BLE.h"

static EventQueue event_queue(/* event count */ 10 * EVENTS_EVENT_SIZE);
void schedule_ble_events(BLE::OnEventsToProcessCallbackContext *context);

int main(){
    Watchdog &watchdog = Watchdog::get_instance();
    loglnInfo("WDT max: %d\n", Watchdog::get_instance().get_max_timeout());

    BLE &ble = BLE::Instance();
    MainController m(ble, event_queue);
    ble.onEventsToProcess(schedule_ble_events); 
    return 0;
}

/** Schedule processing of events from the BLE middleware in the event queue. */
void schedule_ble_events(BLE::OnEventsToProcessCallbackContext *context){
    event_queue.call(Callback<void()>(&context->ble, &BLE::processEvents)); 
}

Am I missing something? Is this a bug?
Any input is greatly appreciated!

Bruno