How to know the cause of reboot with Watchdog in Linux?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to know the cause of reboot with Watchdog in Linux?

3,882 Views
toanjunifer
Senior Contributor I

HI,
I'm trying to recognize the reason cause reboot with Watchdog in Linux. In details, I use iMX8MM and Yocto OS image.

It's have a watchdog hardware(and a watchdog SW) and it's working good. Now, I wanna know the reason of the last reboot. I use WIOF_GETBOOTSTATUE flag to read state. This is a statement:

if (ioctl(fd, WDIOC_GETBOOTSTATUS , &bootstatus) == 0) {
fprintf(stdout, "Last boot is caused by : %s\n",
(bootstatus != 0) ? "Watchdog" : "Power-On-Reset");


But with any case, I still receive one result: Power-On-Reset

Case 1: I wrote a application. In the first 5 sec, It will send a ping message to watchdog. From there, It's will no longer send anything. After 60s, my device is reboot. But then, I check WDIOC_GETBOOTSTATUS flag, I still receive: Power-On-Reset --> It should be Watchdog, right ?

Case 2: I unplug the power cable and plug it in again. And I get : Power-On-Reset --> Correctly.

Did I do the right thing? If not, what should I do ?

Thank you so much,

Toan

Labels (1)
6 Replies

3,755 Views
flaviosuligoi
Contributor III

Hi Toan,

try with:

memtool -16 3039005c 1

I have the same need as you. In my case the result is always POR

 

0 Kudos

3,776 Views
igorpadykov
NXP Employee
NXP Employee

Hi Toan

reset reason (source) can be found using SRC_SRSR register described in

sect.6.5.5.13 SRC Reset Status Register (SRC_SRSR)

i.MX 8M Mini Applications Processor Reference Manual

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

3,776 Views
toanjunifer
Senior Contributor I

Hi igorpadykov‌,

Thank you for your reply. As follow your guide, I'm trying to read SRSR which has address is 

3039_0000h base + 5Ch offset = 3039_005Ch

This is my program:

#include <stdio.h>

int main(){
   char ptr = *(char*)0x3039005C;
   printf("%c\n", ptr);
return 0;
}

But I got: 

Segmentation fault (core dumped)

Do you have any way to read it ?

Have a nice day !

0 Kudos

3,776 Views
igorpadykov
NXP Employee
NXP Employee

for register read example one can look at memtool

memtool\test - imx-test - i.MX Driver Test Application Software 

Best regards
igor

3,776 Views
toanjunifer
Senior Contributor I

Hi igorpadykov‌,

I switched to iMX8MQ board. Then I execute:

   $ ./memtool WDOG1.SRC_SRSR.*
SOC: i.MX8MQ
WDOG1 Addr:0x30280000

As you can see, It's only show address.

0 Kudos

3,776 Views
toanjunifer
Senior Contributor I

Hi igorpadykov‌,

I found memtool application in /units_test directory. Then I run:

 $ ./memtool SRC_SRSR.*

SOC: i.MX8MM
Unknown SOC

Did I do the right way ?

As source code above, I guess that memtool supports imx8mq only.

0 Kudos