Zephyr WWDT Driver Support

This page gives an overview of the WWDT Zephyr driver which is available as part of the zephyr-amd repo.

HW Features

The window watchdog timer mode is enabled by the Enable_and_Status [WEN] bit. The two windowed watchdog timer modes are basic and Q&A, and the mode is selected by the Funct_Ctrl [WM] bit.

In both windowed modes, the timer starts with the first window defined by a 32-bit field in the First_Wind register. The first window is considered the closed window. This is followed by a second window defined by another 32-bit field in the Second_Wind register. The second window is considered the open window. The protocol to keep the watchdog timer operating correctly depends on the window mode and the optional features that are enabled. In the simplest mode, the timer is restarted during the open window time.

Normally, if software tries to restart the timer before the open window time period, a bad event occurs, and the timer can generate a system interrupt or reset.

The Q&A token window mode requires the system software to write three one-byte responses during the first window (closed window) and a one-byte write in the second window (open window). The value of the token responses are based on the seed, feedback, and an answer count value. The seed and feedback values are programmed by software. The answer count value increments by one for each token response.

The two window timer modes include:

  • Windowed Basic Mode

  • Windowed Q&A Mode

For more details refer Versal TRM.

Design Notes

  • N/A

Implementation

Features Supported

  • Driver supports only the basic window watchdog mode.

Missing Features

  • Q&A mode is not supported.

  • Second Sequence timer is not supported.

  • Program sequence monitor is not supported.

Known Issues

  • Lopper support not added yet.

Limitations

  • N/A

Kernel Configuration

CONFIG_WDT_LOG_LEVEL_DBG=y
CONFIG_WATCHDOG=y
CONFIG_WDT_DISABLE_AT_BOOT=n
CONFIG_XILINX_WINDOW_WATCHDOG=y

Device Tree

wwdtclk: wwdtclk {
    compatible = "fixed-clock";
    clock-frequency = <150000000>;
    #clock-cells = <0>;
};

wwdt0: watchdog@ecc10000 {
    compatible = "xlnx,versal-wwdt";
    status = "okay";
    reg = <0xecc10000 0x10000>;
    timeout-sec = <30>;
    clocks = <&wwdtclk>;
};

Note

  • The DTS generated by SDTGEN has multiple properties for wwdt.

  • But the required properties are based on dt-bindings of wwdt driver and lopper filters it to only the required properties.

    • Lopper changes are not added yet.

Driver Stack Size

  • TBA

Test Platform

  • KSB

Test SoC Architecture

  • RPU - R52 core

Testing Sequence

  • Build zephyr application for R52 or A78 core

    • west build -p -b <board> <sample application path>

  • Run zephyr elf on KSB.

Example Tests

Test Name

Example Source

Description

Watchdog Example

zephyr/samples/drivers/watchdog/

This example demonstrates how to use the watchdog driver API.

A typical use case for a watchdog is that the board is restarted in case some piece of code is kept in an infinite loop.

wdt_basic_api

zephyr/tests/drivers/watchdog/wdt_basic_api/

Test provides watchdog installation, setup, and wait for reset. Three variables are placed in noinit section to prevent clearing them during board reset. These variables save number of the current test case, current test state, and value to check if test passed or not.

wdt_error_cases

zephyr/tests/drivers/watchdog/wdt_error_cases

This test suite contains negative test cases for the Watchdog driver.

Test scenarios validate that invalid use of the watchdog driver, returns error code as described in the API documentation.

Code Coverage

Driver Code Coverage with Watchdog Example:

Exec

Total

Coverage

Lines

59

102

57.8%

Functions

4

5

80.0%

Branches

12

44

27.3%

Driver Code Coverage with wdt_error_cases -

Exec

Total

Coverage

Branches

29

36

80.6%

Functions

5

5

100.0%

Lines

99

102

97.1%

Expected Output

Watchdog Example

  • west build -p always -b versalnet_rpu samples/drivers/watchdog/

  • Log:

    *** Booting Zephyr OS build xilinx_v2024.2-61-gb0d216871ebe ***
    Watchdog sample application
    Callback in RESET_SOC disabled for this platform
    Feeding watchdog 5 times
    Feeding watchdog...
    Feeding watchdog...
    Feeding watchdog...
    Feeding watchdog...
    Feeding watchdog...
    Waiting for reset...
    [62329.193]PMC EAM ERR1: 0x200
    [62329.235]PSM EAM Interrupt: ERR1: 0x0 ERR2: 0x1 ERR3: 0x0 ERR4: 0x0
    [62331.024]Received EAM error. ErrorNodeId: 0x28110000, Register Mask: 0x1. The corresponding Error ID: 0x80
    
  • As the reset error is not added in cdo, it generates PMC error.

  • If error action is added in CDOs, the corresponding reset event occurs.

wdt_basic_api

  • west build -p always -b versalnet_rpu tests/drivers/watchdog/wdt_basic_api/

  • Log:

    Running TESTSUITE wdt_basic_test_suite
    ===================================================================
    START - test_wdt
    Testcase: test_wdt_no_callback
    Waiting to restart MCU
    
    
    
    Running TESTSUITE wdt_basic_test_suite
    ===================================================================
    START - test_wdt
    Testcase: test_wdt_no_callback
    Testcase passed
     PASS - test_wdt in 0.005 seconds
    ===================================================================
    TESTSUITE wdt_basic_test_suite succeeded
    
    ------ TESTSUITE SUMMARY START ------
    
    SUITE PASS - 100.00% [wdt_basic_test_suite]: pass = 1, fail = 0, skip = 0, total = 1 duration = 0.005 seconds
     - PASS - [wdt_basic_test_suite.test_wdt] duration = 0.005 seconds
    
    ------ TESTSUITE SUMMARY END ------
    
    ===================================================================
    PROJECT EXECUTION SUCCESSFUL
    
    [11145.239]PMC EAM ERR1: 0x200
    [11145.281]PSM EAM Interrupt: ERR1: 0x0 ERR2: 0x1 ERR3: 0x0 ERR4: 0x0
    [11147.067]Received EAM error. ErrorNodeId: 0x28110000, Register Mask: 0x1. The corresponding Error ID: 0x80
    
  • As the reset error is not added in cdo, it generates PMC error.

  • If error action is added in CDOs, the corresponding reset event occurs.

Note: Preferred boot mode is SD boot.

wdt_error_cases

  • west build -p always -b versalnet_rpu tests/drivers/watchdog/wdt_error_cases/

  • Log:

    • versalnet_rpu wdt_error_cases test log
      *** Booting Zephyr OS build xilinx_v2024.2-61-gb0d216871ebe ***
      Running TESTSUITE wdt_coverage
      ===================================================================
      Test executed on versalnet_rpu/versalnet_rpu
      ===================================================================
      START - test_01_wdt_disable_before_wdt_setup
       PASS - test_01_wdt_disable_before_wdt_setup in 0.001 seconds
      ===================================================================
      START - test_02_wdt_setup_before_setting_timeouts
       PASS - test_02_wdt_setup_before_setting_timeouts in 0.001 seconds
      ===================================================================
      START - test_03_wdt_feed_before_wdt_setup_channel_not_configured
       PASS - test_03_wdt_feed_before_wdt_setup_channel_not_configured in 0.001 seconds
      ===================================================================
      START - test_04a_wdt_install_timeout_WDT_FLAG_RESET_NONE_not_supported
       PASS - test_04a_wdt_install_timeout_WDT_FLAG_RESET_NONE_not_supported in 0.001 seconds
      ===================================================================
      START - test_04b_wdt_install_timeout_WDT_FLAG_RESET_CPU_CORE_not_supported
       PASS - test_04b_wdt_install_timeout_WDT_FLAG_RESET_CPU_CORE_not_supported in 0.001 seconds
      ===================================================================
      START - test_04c_wdt_install_timeout_WDT_FLAG_RESET_SOC_not_supported
       SKIP - test_04c_wdt_install_timeout_WDT_FLAG_RESET_SOC_not_supported in 0.001 seconds
      ===================================================================
      START - test_04w_wdt_install_timeout_with_invalid_window
      E: The closed window timeout is invalid.
      E: The open window timeout is invalid.
       PASS - test_04w_wdt_install_timeout_with_invalid_window in 0.008 seconds
      ===================================================================
      START - test_04wm_wdt_install_timeout_with_multiple_timeout_values
       SKIP - test_04wm_wdt_install_timeout_with_multiple_timeout_values in 0.001 seconds
      ===================================================================
      START - test_05_wdt_install_timeout_after_wdt_setup
      Configured WDT channel 0
       PASS - test_05_wdt_install_timeout_after_wdt_setup in 0.003 seconds
      ===================================================================
      START - test_06d_wdt_setup_without_any_OPT
      Configured WDT channel 0
       PASS - test_06d_wdt_setup_without_any_OPT in 0.003 seconds
      ===================================================================
      START - test_07_wdt_setup_already_done
      Configured WDT channel 0
       PASS - test_07_wdt_setup_already_done in 0.003 seconds
      ===================================================================
      START - test_08a_wdt_disable_not_supported
       SKIP - test_08a_wdt_disable_not_supported in 0.001 seconds
      ===================================================================
      START - test_08c_wdt_disable_check_timeouts_reusable
      Configured WDT channel 0
      Configured WDT channel 0
       PASS - test_08c_wdt_disable_check_timeouts_reusable in 0.005 seconds
      ===================================================================
      START - test_08f_wdt_disable_in_second_window
      Configured WDT channel 0
      E: Disabling WWDT in closed window is not allowed.
       PASS - test_08f_wdt_disable_in_second_window in 5.007 seconds
      ===================================================================
      START - test_09a_wdt_feed_before_wdt_setup_channel_configured
      Configured WDT channel 0
      E: Feed in Closed window is not supported.
       PASS - test_09a_wdt_feed_before_wdt_setup_channel_configured in 0.007 seconds
      ===================================================================
      START - test_09b_wdt_feed_invalid_channel
      Configured WDT channel 0
      Test has failed if there is reset after this line
       PASS - test_09b_wdt_feed_invalid_channel in 0.007 seconds
      ===================================================================
      START - test_09c_wdt_feed_stall
       SKIP - test_09c_wdt_feed_stall in 0.001 seconds
      ===================================================================
      START - test_10_wdt_install_timeout_max_number_of_timeouts
       SKIP - test_10_wdt_install_timeout_max_number_of_timeouts in 0.001 seconds
      ===================================================================
      TESTSUITE wdt_coverage succeeded
      
      ------ TESTSUITE SUMMARY START ------
      
      SUITE PASS - 100.00% [wdt_coverage]: pass = 13, fail = 0, skip = 5, total = 18 duration = 5.053 seconds
       - PASS - [wdt_coverage.test_01_wdt_disable_before_wdt_setup] duration = 0.001 seconds
       - PASS - [wdt_coverage.test_02_wdt_setup_before_setting_timeouts] duration = 0.001 seconds
       - PASS - [wdt_coverage.test_03_wdt_feed_before_wdt_setup_channel_not_configured] duration = 0.001 seconds
       - PASS - [wdt_coverage.test_04a_wdt_install_timeout_WDT_FLAG_RESET_NONE_not_supported] duration = 0.001 seconds
       - PASS - [wdt_coverage.test_04b_wdt_install_timeout_WDT_FLAG_RESET_CPU_CORE_not_supported] duration = 0.001 seconds
       - SKIP - [wdt_coverage.test_04c_wdt_install_timeout_WDT_FLAG_RESET_SOC_not_supported] duration = 0.001 seconds
       - PASS - [wdt_coverage.test_04w_wdt_install_timeout_with_invalid_window] duration = 0.008 seconds
       - SKIP - [wdt_coverage.test_04wm_wdt_install_timeout_with_multiple_timeout_values] duration = 0.001 seconds
       - PASS - [wdt_coverage.test_05_wdt_install_timeout_after_wdt_setup] duration = 0.003 seconds
       - PASS - [wdt_coverage.test_06d_wdt_setup_without_any_OPT] duration = 0.003 seconds
       - PASS - [wdt_coverage.test_07_wdt_setup_already_done] duration = 0.003 seconds
       - SKIP - [wdt_coverage.test_08a_wdt_disable_not_supported] duration = 0.001 seconds
       - PASS - [wdt_coverage.test_08c_wdt_disable_check_timeouts_reusable] duration = 0.005 seconds
       - PASS - [wdt_coverage.test_08f_wdt_disable_in_second_window] duration = 5.007 seconds
       - PASS - [wdt_coverage.test_09a_wdt_feed_before_wdt_setup_channel_configured] duration = 0.007 seconds
       - PASS - [wdt_coverage.test_09b_wdt_feed_invalid_channel] duration = 0.007 seconds
       - SKIP - [wdt_coverage.test_09c_wdt_feed_stall] duration = 0.001 seconds
       - SKIP - [wdt_coverage.test_10_wdt_install_timeout_max_number_of_timeouts] duration = 0.001 seconds
      
      ------ TESTSUITE SUMMARY END ------
      
      ===================================================================
      PROJECT EXECUTION SUCCESSFUL
      [16263.216]PMC EAM ERR1: 0x200
      [16263.257]PSM EAM Interrupt: ERR1: 0x0 ERR2: 0x1 ERR3: 0x0 ERR4: 0x0
      [16265.045]Received EAM error. ErrorNodeId: 0x28110000, Register Mask: 0x1. The corresponding Error ID: 0x80
      
    • Download zephyr_versalnet_rpu_wdt_error_cases.log

  • As the reset error is not added in cdo, it generates PMC error.

  • If error action is added in CDOs, the corresponding reset event occurs.

Performance Metric

  • TBA

Mainline Status

Driver Source Path

  • drivers/watchdog/wdt_xilinx_wwdt.c

Misra C Report

Misra-C Rule

Severity

Actual File Violations

Kernel Utility Violations

HIS_COMF

4

0

HIS_GOTO

4

0

HIS_RETURN

1

0

MISRA C-2012 Directive 4.6

Advisory

9

0

MISRA C-2012 Directive 4.8

Advisory

0

7

MISRA C-2012 Directive 4.9

Advisory

0

5

MISRA C-2012 Rule 1.2

Advisory

0

19

MISRA C-2012 Rule 10.1

Required

1

0

MISRA C-2012 Rule 10.3

Required

18

0

MISRA C-2012 Rule 10.4

Required

25

0

MISRA C-2012 Rule 10.6

Required

1

0

MISRA C-2012 Rule 11.5

9

0

MISRA C-2012 Rule 11.8

Required

0

8

MISRA C-2012 Rule 12.1

Advisory

5

8

MISRA C-2012 Rule 14.3

Required

0

4

MISRA C-2012 Rule 15.1

11

0

MISRA C-2012 Rule 15.4

0

4

MISRA C-2012 Rule 15.5

1

0

MISRA C-2012 Rule 15.6

Required

1

0

MISRA C-2012 Rule 2.5

2

0

MISRA C-2012 Rule 2.7

Advisory

1

0

MISRA C-2012 Rule 20.10

0

1

MISRA C-2012 Rule 20.12

Required

0

4

MISRA C-2012 Rule 21.2

Required

0

21

MISRA C-2012 Rule 5.9

Advisory

0

4

MISRA C-2012 Rule 8.13

0

4

MISRA C-2012 Rule 8.4

Required

0

1

MISRA C-2012 Rule 8.6

Required

0

1

MISRA C-2012 Rule 8.7

0

6

Total violations

93

97