NUC970系列資料之WDT問題及解決辦法

NUC970系列資料之WDT問題及解決辦法

1 WDT問題介紹

NUC970的必須要通過硬件Power on setting來開啓,且開啓後無法通過軟件來關閉和打開。這樣使用起來很不方便。很多客戶希望可以在linux下通過軟件來控制wdt。

WDT的硬件開關是由PWRON[3]位來控制的,它對應的GPIO是PA.3.

如果要關閉WDT,則需在系統上電前將PA.3拉到低電平。

如果要打開WDT,則需在系統上電前將PA.3拉懸空(因內部有上拉)。

 

2 WDT 測試情況2.1硬件關閉WDT的情況下測試WDT

系統啓動後,運行bsp裏wdt_demo程序後,當不喂狗時系統死機但沒有觸發重啓。

/usr # ./wdt_demo

Open watchdog0 ok

ii = 10

ii = 9

ii = 8

ii = 7

ii = 6

ii = 5

ii = 4

ii = 3

ii = 2

ii = 1

ii = 0

watchdog watchdog0: nowayout prevents watchdog being stopped!

watchdog watchdog0: watchdog did not stop!

這說明通過軟件無法打開nuc970的WDT

 

2.2硬件打開WDT的情況下測試WDT

在這種情況下,默認的bsp中u-boot是有喂狗程序的,但引導linux時就沒有喂狗程序了,如果linux系統啓動時間過長,就會出現系統沒啓動完就復位的問題。系統啓動時間短的是有機會進入系統的,但進入系統如果不立即喂狗就會重啓。

ohci_hcd: USB 1.1 ‘Open’ Host Controller (OHCI) Driver

nuc970-ohci nuc970-ohci: Nuvoton NUC970 OHCI Host Controller

nuc970-ohci nuc970-ohci: new USB bus registered, assigned bus number 2

nuc970-ohci nuc970-ohci: irq 24, io mem 0xb0007000

hub 2-0:1.0: USB hub found

hub 2-0:1.0: 2 ports detected

usbcore: registered new interface driver usb-storage

TCP: cubic registered

NET: Registered protocol family 17

Freeing unused kernel memory: 10844K (c033b000 – c0dd2000)

BusyBox v1.22.1 (2017-05-19 16:49:44 CST) built-in shell (ash)

Enter ‘help’ for a list of built-in commands.

~ #

NUC970 IBR 20151008.1735

No Key

Boottttttæ“{kæ44aÃÿand_boot

U-Boot 2013.04-rc2 (Nov 25 2015 – 13:25:12)

CPU: NUC972

DRAM: 64 MiB

NAND: 128 MiB

MMC: mmc: 0, mmc: 1

In: serial

Out: serial

Err: serial

Net: emac

Hit any key to stop autoboot: 0

Using emac device

TFTP from server 10.130.11.18; our IP address is 10.130.11.120

Filename ‘970uimage’.

Load address: 0x7fc0

在這種情況,系統啓動後就運行wdt_demo程序是可以控制WDT正常工作的:正常喂狗時系統正常工作,不喂狗時WDT復位。

NET: Registered protocol family 17

Freeing unused kernel memory: 10844K (c033b000 – c0dd2000)

BusyBox v1.22.1 (2017-05-19 16:49:44 CST) built-in shell (ash)

Enter ‘help’ for a list of built-in commands.

Open watchdog0 ok

ii = 10

ii = 9

ii = 8

ii = 7

ii = 6

ii = 5

ii = 4

ii = 3

ii = 2

ii = 1

ii = 0

watchdog watchdog0: nowayout prevents watchdog being stopped!

watchdog watchdog0: watchdog did not stop!

~ #

NUC970 IBR 20151008.1735

No Key

Boottttttæ“{kæ44aÃÿand_boot

U-Boot 2013.04-rc2 (Nov 25 2015 – 13:25:12)

CPU: NUC972

DRAM: 64 MiB

NAND: 128 MiB

MMC: mmc: 0, mmc: 1

In: serial

Out: serial

Err: serial

Net: emac

不配置內核Disable watchdog shutdown on close時,當wdt_demo運行結束退出後,linux系統會關閉wdt。

Device drivers—>

  • Watchdog Timer Support—>

[ ] Disable watchdog shutdown on close

測試結果如下:

hub 2-0:1.0: 2 ports detected

usbcore: registered new interface driver usb-storage

TCP: cubic registered

NET: Registered protocol family 17

Freeing unused kernel memory: 10844K (c033b000 – c0dd2000)

BusyBox v1.22.1 (2017-05-19 16:49:44 CST) built-in shell (ash)

Enter ‘help’ for a list of built-in commands.

Open watchdog0 ok

ii = 10

ii = 9

ii = 8

ii = 7

ii = 6

ii = 5

ii = 4

ii = 3

ii = 2

ii = 1

ii = 0

Stopping WDT is probably not a good idea

系統沒有重啓,表明linux系統可以通過軟件關閉nuc970的WDT。

通過軟件關閉WDT後,還能否通過軟件來開啓WDT呢?

修改Wdt_demo程序在程序喂狗結束後不退出程序,加入一個死循環程序

While(1){}

編譯demo程序並保存爲wdt_demo1

TCP: cubic registered

NET: Registered protocol family 17

Freeing unused kernel memory: 10884K (c033b000 – c0ddc000)

BusyBox v1.22.1 (2017-05-19 16:49:44 CST) built-in shell (ash)

Enter ‘help’ for a list of built-in commands.

Open watchdog0 ok

ii = 10

ii = 9

ii = 8

ii = 7

ii = 6

ii = 5

ii = 4

ii = 3

ii = 2

ii = 1

ii = 0

Stopping WDT is probably not a good idea

~ #

~ #

~ #

~ #

/usr # ./wdt_demo1

Open watchdog0 ok

ii = 10

ii = 9

ii = 8

ii = 7

ii = 6

ii = 5

ii = 4

ii = 3

ii = 2

ii = 1

ii = 0

NUC970 IBR 20151008.1735

No Key

Boottttttæ“{kæ44aÃÿand_boot

U-Boot 2013.04-rc2 (Nov 25 2015 – 13:25:12)

CPU: NUC972

DRAM: 64 MiB

NAND: 128 MiB

MMC: mmc: 0, mmc: 1

In: serial

Out: serial

Err: serial

Net: emac

Hit any key to stop autoboot: 0

Using emac device

TFTP from server 10.130.11.18; our IP address is 10.130.11.120

Filename ‘970uimage’.

Load address: 0x7fc0

以上測試表明,nuc970的WDT雖然只能由硬件來打開,但硬件打開後,軟件就可以正常控制WDT的打開與關閉。

 

2.3 在硬件打開WDT的情況下,U-BOOT下如何關閉WDT

默認情況下硬件打開WDT後,u-boot是不會關閉WDT的,客戶正常使用WDT時希望進入linux系統後再打開WDT。如何在U-boot下關閉WDT呢?

上面測試表明,硬件打開WDT後,是可以通過軟件來控制WDT的開關的。所以只要在u-boot的WDT驅動中關閉通過軟件關閉WDT即可。

打開wdt的驅動文件,分析發現nuc970的wdt驅動中預留了通過環境變量watchdog來控制WDT的開關的方法。

設置環境變量watchdog=off時,u-boot就關閉WDT。不設置環境變量watchog或設置爲其他值,就不關閉WDT。

在u-boot下通過如下命令設置watchog環境變量。

U-Boot>set watchdog off

U-Boot>save

設置好以後,重啓系統:

NET: Registered protocol family 17

Freeing unused kernel memory: 10884K (c033b000 – c0ddc000)

BusyBox v1.22.1 (2017-05-19 16:49:44 CST) built-in shell (ash)

Enter ‘help’ for a list of built-in commands.

~ #

工作正常,進入系統後不重啓,表明WDT已經關閉。

 

3 NUC970 WDT的使用方法

通過上面的測試,可以總結出nuc970系列芯片WDT的使用方法:

1)要通過硬件power on setting打開WDT,否則WDT不可用

2)設置u-boot下環境變量watchdog=off來關閉WDT

3)進入系統後要使用WDT時打開WDT。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章