4.6.4. 测试指南

4.6.4.1. 测试环境

4.6.4.1.1. 硬件

  • 开发板

4.6.4.1.2. 软件

  • PC端的串口终端软件,用于PC和开发板进行串口通信

  • openwrt中带有的wdt测试工具

4.6.4.1.3. 软件配置

在openwrt的根目录下通过 make menuconfig 可以打开 wdt 测试工具的编译:

zx (openwrt)
    sample-code
        [*] test-watchdog

4.6.4.2. wdt 测试

wdt的主要功能是通过ioctl标准接口,来查询、设置Watchdog的。

板子上的wdt位于 /usr/local/bin/,无需进入该目录,在shell中直接运行wdt即可。

wdt的帮助信息:

[aic@] # wdt -u
Compile time: Apr 16 2022 14:31:42
Usage: wdt [options]
     -i, --info     Print the status and infomation
     -s, --set-timeout  Set a timeout, in second
     -g, --get-timeout  Get the current timeout, in second
     -p, --set-pretimeout   Set a pretimeout, in second
     -G, --get-pretimeout   Get the current pretimeout, in second
     -k, --keepalive    Keepalive the watchdog
     -u, --usage

Example: wdt -c 0 -s 12
Example: wdt -c 1 -s 100 -p 90

备注

  1. WDT V1.0驱动中对timeout参数的范围有限制:[1, 3600],即最小1秒、最多1小时。

  2. Linux的Watchdog子系统中对pretimeout参数有限制:pretimeout必须小于timeout。

wdt的使用示例:

[aic@] # wdt -i
In ZX Watchdog timer watchdog V0, options 0x8180
Status: 32768
Boot status: 0
[aic@] # wdt -s 3601
wdt_set_timeout()125 - Set chan0 timeout 3601, pretimeout 0
[ERROR] wdt_set_timeout()128 - Failed to set timeout 22[Invalid argument]
[aic@] # wdt -s 0
wdt_set_timeout()125 - Set chan0 timeout 0, pretimeout 0
[ERROR] wdt_set_timeout()128 - Failed to set timeout 22[Invalid argument]
[aic@] # wdt -g
wdt_get_timeout()155 - Get chan0 timeout 16
[aic@] # wdt -s 2
wdt_set_timeout()125 - Set chan0 timeout 2, pretimeout 0
[aic@] # wdt -g
wdt_get_timeout()155 - Get chan0 timeout 2
[aic@] # wdt -s 9
wdt_set_timeout()125 - Set chan0 timeout 9, pretimeout 0
[aic@] # wdt -g
wdt_get_timeout()155 - Get chan0 timeout 9
[aic@] # wdt -s 9 -p 4
wdt_set_timeout()125 - Set chan0 timeout 9, pretimeout 4