siemens / meta-iot2050

SIMATIC IOT2050 Isar/Debian Board Support Package
MIT License
131 stars 77 forks source link

iot2050:watchdog: Add support for WDIOF_CARDRESET #474

Closed huaqianli closed 1 year ago

huaqianli commented 1 year ago

This patch adds the WDIOF_CARDRESET support for the TI AM65x platform watchdog, to know if the board reboot is due to a watchdog reset.

This is done via reserved memory(RAM), which indicates if specific info saved in k3-rti-wdt, triggering the watchdog reset in last boot.

jan-kiszka commented 1 year ago

Just to note this clearly: This will also need the k3-wdt firmware patch - or an update of upstream once the needed changes are accepted there.

huaqianli commented 1 year ago

Yes, I didn't add it because I don't know which commit id will be used. Once the k3-wdt firmware is merged, I will update it.

jan-kiszka commented 1 year ago

Quick question: How do I obtain the status from the kernel driver easiest?

huaqianli commented 1 year ago

Quick question: How do I obtain the status from the kernel driver easiest?

From my perspective, waiting for an email from community is the easiest way. You and @BaochengSu have more experience on upstreaming, maybe you know better.

jan-kiszka commented 1 year ago

Misunderstanding: I meant how to read back the reset status on the device if this patch here is applied?

huaqianli commented 1 year ago

Misunderstanding: I meant how to read back the reset status on the device if this patch here is applied?

Here is an example:

void foo(void)
{
    if ((fd = open("/dev/watchdog", O_RDWR)) < 0) {
        printf("Failed to open watchdog\n");
        return;
    }

    if (ioctl(fd, WDIOC_GETBOOTSTATUS, &status) < 0) {
        printf("Failed to get boot status!");
    }

    if (WDIOF_CARDRESET & status) {
        // WDIOF_CARDRESET is detected, do what you want to do
    }
}
jan-kiszka commented 1 year ago

Ah, found it myself: cat /sys/class/watchdog/watchdog0/bootstatus