OpenNuvoton / NUC980-linux-4.4.y

Linux 4.4 Kernel Source Code for NUC980 Series Microprocessor
Other
48 stars 58 forks source link

Watchdog Timer ON 後的2個問題 #116

Open kenlee0823 opened 2 years ago

kenlee0823 commented 2 years ago

目標板: NK-980ETH2P 2020.02.27 V1.2

將SW1旁側PG3的R24(10K)電阻移除,Watchdog Timer ON USB連線查看設置參數: PowerOn setting 0x7f6001dc

dc: 1011 1100,bit3(cfg3)=1,啟用確認

問題1: 實測在uboot內閒置超時許久也不會重置?

"NUC980 U-Boot v2016_11 使用手冊" 章節 "13.3 Watchdog timer 的時間長度"

當 Watchdog timer 功能打開後,系統閒置超過 14 秒之後, Watchdog timer 會重置系統,U-Boot 重新開機, 每當用戶在 U-Boot 命令列下完成一個命令(輸入 Enter 鍵)之後,會重新計數 14 秒.

uboot 設置: uboot: nuv980_evb.h

    #define CONFIG_HW_WATCHDOG
    #define CONFIG_NUC980_WATCHDOG

uboot環境變數:

    setenv watchdog on 
    saveenv    

問題2: 在kernel載入後3x秒發生重置?

Kernel: menuconfig 配置

    Device Drivers  --->
        [*] Watchdog Timer Support  ---->
        -*-   WatchDog Timer Driver Core
        [ ]   Disable watchdog shutdown on close
        < >   Software watchdog
        <*>   Nuvoton NUC980 Watchdog Timer
        <*>     NUC980 WDT wake-up support
        < >   Nuvoton NUC980 Window Watchdog Timer

上電後訊息如下:

U-Boot 2016.11+ (Nov 24 2022 - 18:00:02 +0800)

CPU: NUC980
Board: NUC980
DRAM:  64 MiB
NAND:  0 MiB
jedec aa21SF: Detected W25N01GV with page size 2 KiB, erase size 128 KiB, total 128 MiB
In:    serial
Out:   serial
Err:   serial
Net:   nuc980 emac
Warning: eth device name has a space!

Warning: nuc980 emac (eth0) using random MAC address - 8e:8a:41:c2:a3:50

Hit any key to stop autoboot:  0

Loading from nand0, offset 0x200000
   Image Name:   NUC980
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2479872 Bytes = 2.4 MiB
   Load Address: 00008000
   Entry Point:  00008000
## Booting kernel from Legacy Image at 00007fc0 ...
   Image Name:   NUC980
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2479872 Bytes = 2.4 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
   XIP Kernel Image ... OK

Starting kernel ...

jedec aa21SF: Detected W25N01GV with page size 2 KiB, erase size 128 KiB, total 128 MiB
SF: Device▒[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.4.289+ (root@Rocky8) (gcc version 7.5.0 (Buildroot 2020.02.12) ) #19 PREEMPT Fri Nov 25 15:31:20 CST 2022
[    0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] Machine: NUC980
[    0.000000] Memory policy: Data cache writeback
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: noinitrd root=/dev/mtdblock2 rootfstype=yaffs2 rootflags=inband-tags console=ttyS0,115200n8 rdinit=/sbin/init mtdparts=nand0:2M@0x0(uboot),6M@0x200000(kernel),32M@0x800000(rootfs),-(ext)
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Memory: 59660K/65536K available (3678K kernel code, 210K rwdata, 984K rodata, 144K init, 198K bss, 5876K reserved, 0K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xc4800000 - 0xff800000   ( 944 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc0495d6c   (4664 kB)
[    0.000000]       .init : 0xc0496000 - 0xc04ba000   ( 144 kB)
[    0.000000]       .data : 0xc04ba000 - 0xc04eea00   ( 211 kB)
[    0.000000]        .bss : 0xc04eea00 - 0xc052036c   ( 199 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  Build-time adjustment of leaf fanout to 32.
[    0.000000] NR_IRQS:545
[    0.000000] clocksource: nuc980-timer5: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 62215505635 ns
[    0.000033] sched_clock: 24 bits at 120kHz, resolution 8333ns, wraps every 69905062489ns
[    0.000741] Console: colour dummy device 80x30
[    0.193016] console [ttyS0] enabled
[    0.196483] Calibrating delay loop... 148.88 BogoMIPS (lpj=744448)
[    0.262774] pid_max: default: 32768 minimum: 301
[    0.267616] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.274283] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.283233] CPU: Testing write buffer coherency: ok
[    0.289133] Setting up static identity map for 0x8400 - 0x843c
[    0.299916] devtmpfs: initialized
[    0.321816] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.332524] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.338983] pinctrl core: initialized pinctrl subsystem
[    0.346283] NET: Registered protocol family 16
[    0.353133] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.481799] SCSI subsystem initialized
[    0.490174] usbcore: registered new interface driver usbfs
[    0.498108] usbcore: registered new interface driver hub
[    0.504724] usbcore: registered new device driver usb
[    0.519141] clocksource: Switched to clocksource nuc980-timer5
[    0.618266] NET: Registered protocol family 2
[    0.624474] IP idents hash table entries: 2048 (order: 2, 16384 bytes)
[    0.633483] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.641158] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.647516] TCP: Hash tables configured (established 1024 bind 1024)
[    0.654299] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.660358] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.667241] NET: Registered protocol family 1
[    0.672533] NetWinder Floating Point Emulator V0.97 (double precision)
[    0.773041] fuse init (API version 7.23)
[    0.785108] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    0.794141] io scheduler noop registered (default)
[    0.799874] nuc980_gpio_probe - pdev = nuc980-gpio
[    0.808549] nuc980_dma_probe - pdev = nuc980-dma
[    0.832708] nuc980-dma nuc980-dma: NUC980 DMA ready
[    0.841391] nuc980-uart.0: ttyS0 at I/O 0x0 (irq = 36, base_baud = 750000) is a NUC980
[    0.852316] nuc980-uart.1: ttyS1 at I/O 0x0 (irq = 37, base_baud = 9375000) is a NUC980
[    0.863074] nuc980-uart.2: ttyS2 at I/O 0x0 (irq = 38, base_baud = 9375000) is a NUC980
[    0.874091] nuc980-uart.3: ttyS3 at I/O 0x0 (irq = 43, base_baud = 9375000) is a NUC980
[    0.960983] brd: module loaded
[    0.968458] RX nuc980_qspi0_probe: dma0chan0 module removed
[    0.975724] TX nuc980_qspi0_probe: dma0chan1 module removed
[    0.997083] libphy: nuc980_rmii0: probed
[    1.091833] libphy: nuc980_rmii1: probed
[    1.173241] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.181533] nuc980-ehci nuc980-ehci: Nuvoton NUC980 EHCI Host Controller
[    1.188299] nuc980-ehci nuc980-ehci: new USB bus registered, assigned bus number 1
[    1.196708] nuc980-ehci nuc980-ehci: irq 23, io mem 0xb0015000
[    1.219349] nuc980-ehci nuc980-ehci: USB 2.0 started, EHCI 0.95
[    1.229508] hub 1-0:1.0: USB hub found
[    1.233941] hub 1-0:1.0: 2 ports detected
[    1.240174] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.247141] usb_hcd_nuc980_probe, id = 0, name: nuc980-ohci.0, 0
[    1.254099] nuc980-ohci nuc980-ohci.0: Nuvoton NUC980 OHCI Host Controller
[    1.261466] nuc980-ohci nuc980-ohci.0: new USB bus registered, assigned bus number 2
[    1.269566] nuc980-ohci nuc980-ohci.0: irq 24, io mem 0xb0017000
[    1.335149] hub 2-0:1.0: USB hub found
[    1.339816] hub 2-0:1.0: 8 ports detected
[    1.346924] usb_hcd_nuc980_probe, id = 1, name: nuc980-ohci.1, 0
[    1.354458] usb_hcd_nuc980_probe, id = 2, name: nuc980-ohci.2, 0
[    1.361216] usb_hcd_nuc980_probe, id = 3, name: nuc980-ohci.3, 0
[    1.367691] usb_hcd_nuc980_probe, id = 4, name: nuc980-ohci.4, 0
[    1.374816] usb_hcd_nuc980_probe, id = 5, name: nuc980-ohci.5, 0
[    1.381799] usb_hcd_nuc980_probe, id = 6, name: nuc980-ohci.6, 0
[    1.389599] usbcore: registered new interface driver usb-storage
[    1.397883] nuc980-rtc nuc980-rtc: rtc core: registered nuc980-rtc as rtc0
[    1.462799] usbcore: registered new interface driver usbhid
[    1.468333] usbhid: USB HID core driver
[    1.484158] nand: device found, Manufacturer ID: 0xef, Chip ID: 0xaa
[    1.490899] nand: Winbond W25N01GV 1G 3.3V
[    1.494974] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    1.502749] nand: WARNING: spi0.0: the ECC used on your system is too weak compared to the one required by the NAND chip
[    1.513749] Scanning device for bad blocks
[    1.777274] 4 cmdlinepart partitions found on MTD device nand0
[    1.783174] Creating 4 MTD partitions on "nand0":
[    1.787858] 0x000000000000-0x000000200000 : "uboot"
[    1.799708] 0x000000200000-0x000000800000 : "kernel"
[    1.810933] 0x000000800000-0x000002800000 : "rootfs"
[    1.822908] 0x000002800000-0x000008000000 : "ext"
[    1.836199] nf_conntrack version 0.5.0 (932 buckets, 3728 max)
[    1.846741] ip_tables: (C) 2000-2006 Netfilter Core Team
[    1.853616] ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
[    1.860641] arp_tables: (C) 2002 David S. Miller
[    1.865549] NET: Registered protocol family 17
[    1.876533] nuc980-rtc nuc980-rtc: setting system clock to 2005-01-01 00:00:00 UTC (1104537600)
[    1.919516] yaffs: dev is 32505858 name is "mtdblock2" rw
[    1.924874] yaffs: passed flags "inband-tags"
[    6.628683] random: nonblocking pool is initialized
[    9.787108] VFS: Mounted root (yaffs2 filesystem) on device 31:2.
[    9.793566] devtmpfs: mounted
[    9.798199] Freeing unused kernel memory: 144K
[   10.195866] devpts: called with bogus options
rcS start
[   10.894024] yaffs: dev is 32505859 name is "mtdblock3" rw
[   10.899849] yaffs: passed flags "inband-tags"
Mount /dev/mtdblock3 to /ext successfully.
Sat Jan  1 00:00:00 CST 2005
Starting syslogd: OK
Initializing random number generator: OK
Saving random seed: OK
Starting iptables: OK
Starting network ...
[   13.409941] nuc980-emac0 nuc980-emac0: eth0 is OPENED
Starting myinfod: OK
Starting dropbear(sshd): OK
Starting lighttpd: 2005-01-01 00:00:04: (../src/mod_openssl.c.1333) SSL: inactive/expired X509 certificate '/etc/nuc980.pem'
OK
Starting vsftpd: OK

Welcome to NUC980
iMC-10 login:

數秒後發生重置 請問如何修正?

ychuang3 commented 2 years ago

關於問題二 Linux kernel watchdog 開啟之後,需要定時餵狗,如果超時,就會 reset。 請參考範例應用 https://github.com/OpenNuvoton/NUC980_Linux_Applications/blob/master/demos/wdt/wdt.c

ychuang3 commented 2 years ago

問題一: U-Boot 不會 reset 是正常的. 原因是 U-Boot 在等待使用者從 command line 輸入命令時, 會不斷地透過 WATCHDOG_RESET() 調用 NUC980 Watchdog timer driver 的 hw_watchdog_reset() 來 reset WDT counter

image

在其他等待周邊費時較久的應用, 例如: 對 SPI NAND Flash 下了 erase 或 write 命令後, 等待 SPI NAND Flash 的 busy bit. 也是會不斷地調用 WATCHDOG_RESET() 避免系統產生 reset.

kenlee0823 commented 2 years ago

根據你提供的方式,編寫了在啟動腳本中執行的餵狗程序,問題已解決,感謝~