AMD-Xilinx MPSoC的器件里,提供了內(nèi)置的Watchdog。在Vivado里選擇Watchdog,并在設(shè)備樹里使能Watchdog,還不能在Linux中正常使用。
pmu-firmware修改
如果要在Linux中使用Watchdog,需要在project-spec/meta-user/recipes-bsp/embeddedsw/pmu-firmware_%.bbappend中添加如下內(nèi)容:
2021.1以前的版本:
#pmu-firmware_%.bbappendcontent YAML_COMPILER_FLAGS_append="-DENABLE_EM-DENABLE_SCHEDULER"
2022.1及以后的版本:
#pmu-firmware_%.bbappendcontent YAML_COMPILER_FLAGS:append="-DENABLE_EM-DENABLE_SCHEDULER"
Devicetree
檢查Devicetree,確保其中的status為"okay", 也有屬性reset-on-timeout。
watchdog@fd4d0000{ clocks=<0x03?0x4b>; compatible="cdns,wdt-r1p2"; interrupt-parent=<0x04>; interrupts=<0x00?0x71?0x01>; phandle=<0x76>; reg=<0x00?0xfd4d0000?0x00?0x1000>; reset-on-timeout; status="okay"; timeout-sec=<0x3c>; }; watchdog@ff150000{ clocks=<0x03?0x70>; compatible="cdns,wdt-r1p2"; interrupt-parent=<0x04>; interrupts=<0x00?0x34?0x01>; phandle=<0x77>; reg=<0x00?0xff150000?0x00?0x1000>; status="okay"; timeout-sec=<0x0a>; };
啟動信息
使用命令“dmesg”檢查啟動信息,有如下信息。
#dmesg-c|grepwatchdog [539.845269]watchdog:watchdog0:watchdogdidnotstop! [691.897271]watchdog:watchdog1:watchdogdidnotstop! [702.136679]cdns-wdtff150000.watchdog:Watchdogtimedout.Internalresetnotenabled
通過設(shè)備節(jié)點控制Watchdog
通過設(shè)備節(jié)點“/dev/watchdog0”可以控制Watchdog。
執(zhí)行命令“echo s > /dev/watchdog0”,能啟動Watchdog,但是沒有清狗操作。時間久了,單板會自動重啟動。
#echos>/dev/watchdog0 [154.773229]watchdog:watchdog0:watchdogdidnotstop! #dmesg-c|tail-n20 [154.773229]watchdog:watchdog0:watchdogdidnotstop! #dmesg-c|tail-n20 #cat/proc/uptime 193.70738.72 #XilinxZynqMPFirstStageBootLoader Release2022.1Apr112022-09:29:50 NOTICE:BL31:v2.6(release):v1.1-9207-g67ca59c67
執(zhí)行命令“echo 'V' > /dev/watchdog0”,能停止Watchdog,單板再也不會自動重啟動。
#echos>/dev/watchdog0&&cat/proc/uptime [1850.817370]watchdog:watchdog0:watchdogdidnotstop! 1850.697364.03 #sleep1 #echo'V'>/dev/watchdog0&&cat/proc/uptime 1852.407370.84 #cat/proc/uptime 1887.117509.61 #cat/proc/uptime 1971.677847.72 #cat/proc/uptime 2159.968600.54
通過應(yīng)用程序控制Watchdog
Linux也提供了應(yīng)用程序watchdog控制Watchdog,啟動Watchdog并清狗。下面是啟動Watchdog的示例。如果由于特殊原因,應(yīng)用程序watchdog異常退出,就會導(dǎo)致單板復(fù)位。下面的例子中,使用kill命令殺死了應(yīng)用程序watchdog的進程,導(dǎo)致單板復(fù)位。
#watchdog-T10-t3/dev/watchdog0 #ps-A|grepwatchdog 95?00:00:00watchdogd 1159?00:00:00watchdog #cat/proc/uptime 1880.187481.78 #cat/proc/uptime 1895.657543.65 #kill-91159 #[1904.549498]watchdog:watchdog0:watchdogdidnotstop! #XilinxZynqMPFirstStageBootLoader Release2022.1Apr112022-09:29:50 NOTICE:BL31:v2.6(release):v1.1-9207-g67ca59c67
通過系統(tǒng)腳本啟動Watchdog并清狗
Linux也提供系統(tǒng)腳本/etc/init.d/watchdog-init控制Watchdog。
系統(tǒng)腳本/etc/init.d/watchdog-init也使用了應(yīng)用程序控制Watchdog。如果使用kill命令殺死應(yīng)用程序watchdog的進程,也會導(dǎo)致單板復(fù)位。
#/etc/init.d/watchdog-initstart&&cat/proc/uptime Sethealthybit /etc/init.d/watchdog-init:line92:/sys/firmware/zynqmp/health_status:Permissiondenied StartingWDT 2199.548758.78 #ps-A|grepwatchdog 95?00:00:00watchdogd 1110?00:00:00watchdog #sleep5 #/etc/init.d/watchdog-initstop&&cat/proc/uptime StopingWDT 2204.628779.08 #cat/proc/uptime 2299.329157.71 #cat/proc/uptime 2628.2210472.73
參考文檔
Cadence WDT Driver
測試單板
KV260 2022.1 BSP
審核編輯:湯梓紅
-
amd
+關(guān)注
關(guān)注
25文章
5441瀏覽量
133933 -
Linux
+關(guān)注
關(guān)注
87文章
11225瀏覽量
208910 -
Xilinx
+關(guān)注
關(guān)注
71文章
2163瀏覽量
120999 -
MPSoC
+關(guān)注
關(guān)注
0文章
198瀏覽量
24248
發(fā)布評論請先 登錄
相關(guān)推薦
評論