The role of the microcontroller watchdog[Copy link]
The function of the watchdog is to feed the watchdog regularly and reset the timer when the system CPU is working normally. If there is a problem with the system and the watchdog is not fed, the watchdog will reset the CPU due to timeout. After initialization, the system registers the watchdog interrupt request_irq(WDT0_ACCSCSSNBARK_INT, wdog_bark_handler, 0, "apps_wdog_bark", NULL); and initializes the watchdog timeout bark time, __raw_writel(timeout, msm_tmr0_base + WDT0_BARK_TIME); __raw_writel(timeout + 3*WDT_HZ, msm_tmr0_base + WDT0_BITE_TIME); __raw_writel(timeout + 3*WDT_HZ, msm_tmr0_base + WDT0_BITE_TIME); Reset the watchdog, enable the watchdog and interrupt polarity. __raw_writel(1, msm_tmr0_base + WDT0_EN); __raw_writel(1, msm_tmr0_base + WDT0_RST); enable_percpu_irq(WDT0_ACCSC SSNBARK_INT, IRQ_TYPE_EDGE_RISING); And initialize and start a timer, such as once every 10 seconds, schedule_delayed_work_on(0, &dogwork_struct, delay_time); static DECLARE_DELAYED_WORK(dogwork_struct, pet_watchdog_work); static DECLARE_WORK(init_dogwork_struct, init_watchdog_work); static struct msm_watchdog_pdata msm_watchdog_pdata = { =4].pet_time = 10000, .bark_time = 11000, .has_secure = true, .needs_expired_enable = true, }; delay_time = msecs_to_jiffies(pdata->pet_time); schedule_work_on(0, &init_dogwork_struct); When the timer is up, reset the pet dog timer and restart the timer. static void pet_watchdog_work(struct work_struct *work){pet_watchdog();if (enable)schedule_delayed_work_on(0, &dogwork_struct, delay_time);}}if (enable)schedule_delayed_work_on(0, &dogwork_struct, delay_time);} Execute panic. panic("Apps watchdog bark received!");