在Freescale Android 5.0.2 系統中的看門狗(Watchdog)

若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。

在kernel_imx/arch/arm/boot/dts/imx6qdl.dtsi,可看到如下內容:


在 Source code裡就有WDOG2的Driver source code (imx2_wdt.c),


試著修改kernel_imx/arch/arm/boot/dts/imx6qdl-sabresd.dtsi


結果發現driver的probe函式會被呼叫兩次,
imx2-wdt1 20bc000.wdog: wdt1_probe.
imx2-wdt1 20bc000.wdog: ProbeCnt:1imx2-wdt1 20bc000.wdog: wdt1_base pass.
imx2-wdt1 20bc000.wdog: wdt1_clk pass.
imx2-wdt1 20bc000.wdog: wdt1_get_irq pass.
imx2-wdt1 20bc000.wdog: wdt1_request_irq.
imx2-wdt1 20bc000.wdog: wdt1_misc_registering...
imx2-wdt1 20bc000.wdog: IMX2+ Watchdog1 Timer enabled. timeout=60s (nowayout=0)
imx2-wdt1 20c0000.wdog: wdt1_probe.
imx2-wdt1 20c0000.wdog: ProbeCnt:2imx2-wdt1 20c0000.wdog: wdt1_base pass.
imx2-wdt1 20c0000.wdog: wdt1_clk pass.
imx2-wdt1 20c0000.wdog: wdt1_get_irq pass.
imx2-wdt1 20c0000.wdog: wdt1_request_irq.
imx2-wdt1 20c0000.wdog: wdt1_misc_registering...
imx2-wdt1: probe of 20c0000.wdog failed with error -16
此錯誤代碼,表示misc_register失敗,於是把miscdevice struct 中的minor與name修改為如下:
static struct miscdevice imx2_wdt1_miscdev = {
  .minor = WATCHDOG_MINOR + 1,
  .name = "watchdog1",
  .fops = &imx2_wdt1_fops,
};
目的要讓WDOG1與WDOG2的miscdevice不一樣,再加上用一個變數(ProbeCnt)分別註冊WDOG1與WDOG2的miscdevice,WDOG的功能即可如預期運作。

在 kernel_imx/Documentation/watchdog/ 資料夾下看到一些說明文件。

測試程式範例可參考底下檔案:
system/core/init/watchdogd.h
system/core/init/watchdogd.c
external/busybox/miscutils/watchdog.c

在device/fsl/imx6/etc/init.rc 中service 後頭的 [service_name] 名稱的長度不能超過16,例如:service setup_watchdog_60,此例setup_watchdog_60已超過名稱長度16了。Android Init Language可參考此網址:https://github.com/android/platform_system_core/blob/master/init/readme.txt

沒有留言: