watchdog: sama5d4_wdt: Reset delay on start
Subsystems (2)
PATCH 1/1 watchdog: sama5d4_wdt: Reset delay on start
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening /dev/watchdog without writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.
To avoid this problem, reload the timer on opening the watchdog device.
Command: "while sleep 5; do echo 1; done > /dev/watchdog"
Before: system reset
After: the watchdog runs correctly
--- drivers/watchdog/sama5d4_wdt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/watchdog/sama5d4_wdt.c +3 -0
@@ -15,6 +15,7 @@#include <linux/platform_device.h> #include <linux/reboot.h> #include <linux/watchdog.h> +#include <linux/delay.h> #include "at91sam9_wdt.h"
@@ -58,6 +59,8 @@ static int sama5d4_wdt_start(struct watchdog_device *wdd) reg =wdt_read (wdt,AT91_WDT_MR ); reg &= ~AT91_WDT_WDDIS ;wdt_write (wdt,AT91_WDT_MR , reg); +udelay (125 );/* > 4 cycles at 32,768 Hz */ +wdt_write (wdt,AT91_WDT_CR ,AT91_WDT_KEY |AT91_WDT_WDRSTT );return 0 ; }
Signature · 1 line
2.5.0
Guenter Roeck
maintainerQuoted 5 lines · Romain Izard
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening
/dev/watchdogwithout writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.
Quoted 7 lines
To avoid this problem, reload the timer on opening the watchdog device.
Command: "while sleep 5; do echo 1; done >
/dev/watchdog"
Before: system reset
After: the watchdog runs correctlySigned-off-by Romain Izard <[email protected]>
Subject might better read "ping watchdog on start" or similar.
Does the watchdog have to be pinged before it is enabled ? I am a bit concerned that there may still be a 125 uS window during which the system could restart.
Thanks,
Guenter
Quoted 26 lines
--- drivers/watchdog/sama5d4_wdt.c | 3 +++ 1 file changed, 3 insertions(+)drivers/watchdog/sama5d4_wdt.c +3
-0@@ -15,6 +15,7 @@#include <linux/platform_device.h> #include <linux/reboot.h> #include <linux/watchdog.h> +#include <linux/delay.h> #include "at91sam9_wdt.h" @@ -58,6 +59,8 @@ static int sama5d4_wdt_start(struct watchdog_device *wdd) reg =wdt_read (wdt,AT91_WDT_MR ); reg &= ~AT91_WDT_WDDIS ;wdt_write (wdt,AT91_WDT_MR , reg); +udelay (125 );/* > 4 cycles at 32,768 Hz */ +wdt_write (wdt,AT91_WDT_CR ,AT91_WDT_KEY |AT91_WDT_WDRSTT );return 0 ; }
Hi Guenter,
2016-03-03 13:10 GMT+01:00 Guenter Roeck <[email protected]>:
Quoted 10 lines · Romain Izard
Quoted 9 lines
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening
/dev/watchdogwithout writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.To avoid this problem, reload the timer on opening the watchdog device.
Quoted 9 lines
Quoted 5 lines
Command: "while sleep 5; do echo 1; done >
/dev/watchdog"
Before: system reset
After: the watchdog runs correctlySigned-off-by Romain Izard <[email protected]>Subject might better read "ping watchdog on start" or similar.
OK. I'll change it for a v2.
Quoted 4 lines
Does the watchdog have to be pinged before it is enabled ? I am a bit concerned that there may still be a 125 uS window during which the system could restart.
According to the SAMA5D2 & SAMA5D4 datasheets, the timer ought to be reloaded when the watchdog is enabled by a write in the MR register. Unfortunately, it does not work as described, as I encountered the problem on a SAMA5D2 Xplained board.
The 4 clock delay is not in the datasheet either, but without any delay the timer is clearly not reloaded, as my issue stays the same. As there is a required delay before writing to MR after writing to CR, I applied the same type of delay in the reverse case.
Perhaps Nicolas or Wenyou have more information on this.
Best regards,
Signature · 1 line
Romain Izard
Guenter Roeck
maintainerQuoted 34 lines · Romain Izard
Hi Guenter,
2016-03-03 13:10 GMT+01:00 Guenter Roeck <[email protected]>:
Quoted 10 lines · Romain Izard
Quoted 9 lines
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening
/dev/watchdogwithout writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.To avoid this problem, reload the timer on opening the watchdog device.
Quoted 9 lines
Quoted 5 lines
Command: "while sleep 5; do echo 1; done >
/dev/watchdog"
Before: system reset
After: the watchdog runs correctlySigned-off-by Romain Izard <[email protected]>Subject might better read "ping watchdog on start" or similar.
OK. I'll change it for a v2.
Quoted 4 lines
Does the watchdog have to be pinged before it is enabled ? I am a bit concerned that there may still be a 125 uS window during which the system could restart.
According to the SAMA5D2 & SAMA5D4 datasheets, the timer ought to be reloaded when the watchdog is enabled by a write in the MR register. Unfortunately, it does not work as described, as I encountered the problem on a SAMA5D2 Xplained board.
Quoted 5 lines
The 4 clock delay is not in the datasheet either, but without any delay the timer is clearly not reloaded, as my issue stays the same. As there is a required delay before writing to MR after writing to CR, I applied the same type of delay in the reverse case.
Question is if there is now a 4 clock window where the watchdog can still reset the system. Can you reload the timer before enabling the watchdog ?
Thanks,
Guenter
Quoted 5 lines
Perhaps Nicolas or Wenyou have more information on this.
Best regards,
Signature · 1 line
Romain Izard
Hi Romain,
Quoted 10 lines · Romain Izard
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening
/dev/watchdogwithout writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.To avoid this problem, reload the timer on opening the watchdog device.
Command: "while sleep 5; do echo 1; done >
/dev/watchdog"
Before: system reset
After: the watchdog runs correctly
I didn't reproduce your issue on my side,
run the your commands as follows, it works fine, the system reset doesn't happen.
---8<----
#!/bin/sh
while [ 1 ]
do
sleep 5;
echo 1 > /dev/watchdog
done
--->8----
I also check the WDT_MR register before and after enabling watchdog, the WDV and WDD fields are correct.
Can you check it again? thank you.
Quoted 19 lines
Signed-off-by Romain Izard <[email protected]>--- drivers/watchdog/sama5d4_wdt.c | 3 +++ 1 file changed, 3 insertions(+)drivers/watchdog/sama5d4_wdt.c +1
-0@@ -15,6 +15,7 @@#include <linux/platform_device.h> #include <linux/reboot.h> #include <linux/watchdog.h> +#include <linux/delay.h> #include "at91sam9_wdt.h"
drivers/watchdog/sama5d4_wdt.c static int sama5d4_wdt_start(struct watchdog_device *wdd) · line 66
Quoted 8 lines
drivers/watchdog/sama5d4_wdt.c +2
-0@@ -58,6 +59,8 @@ static int sama5d4_wdt_start(struct watchdog_device *wdd) reg =wdt_read (wdt,AT91_WDT_MR ); reg &= ~AT91_WDT_WDDIS ;wdt_write (wdt,AT91_WDT_MR , reg); +udelay (125 );/* > 4 cycles at 32,768 Hz */ +wdt_write (wdt,AT91_WDT_CR ,AT91_WDT_KEY |AT91_WDT_WDRSTT );return 0 ; }
Best Regards,
Wenyou Yang
Guenter Roeck
maintainerQuoted 8 lines · Wenyou
Hi Romain,
Quoted 5 lines · Romain Izard
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening
/dev/watchdogwithout writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.
Quoted 8 lines
Quoted 5 lines
To avoid this problem, reload the timer on opening the watchdog device.
Command: "while sleep 5; do echo 1; done >
/dev/watchdog"
Before: system reset
After: the watchdog runs correctlyI didn't reproduce your issue on my side,
run the your commands as follows, it works fine, the system reset doesn't happen.
Different chip revision ? Different chip type ? Different chip initialization by ROMMON ?
Can we get exact chip revisions and types for both cases (working and not working), and (if it might be relevant) a dump of all associated chip registers ?
Thanks,
Guenter
Quoted 42 lines
---8<----
#!/bin/shwhile [ 1 ]
do
sleep 5;
echo 1 >/dev/watchdog
done
--->8----I also check the
WDT_MRregister before and after enabling watchdog, the WDV and WDD fields are correct.Can you check it again? thank you.
Quoted 17 lines
Signed-off-by Romain Izard <[email protected]>--- drivers/watchdog/sama5d4_wdt.c | 3 +++ 1 file changed, 3 insertions(+)drivers/watchdog/sama5d4_wdt.c +1
-0@@ -15,6 +15,7 @@#include <linux/platform_device.h> #include <linux/reboot.h> #include <linux/watchdog.h> +#include <linux/delay.h> #include "at91sam9_wdt.h" drivers/watchdog/sama5d4_wdt.c static int sama5d4_wdt_start(struct watchdog_device *wdd) · line 65
Quoted 7 lines
drivers/watchdog/sama5d4_wdt.c +2
-0@@ -58,6 +59,8 @@ static int sama5d4_wdt_start(struct watchdog_device *wdd) reg =wdt_read (wdt,AT91_WDT_MR ); reg &= ~AT91_WDT_WDDIS ;wdt_write (wdt,AT91_WDT_MR , reg); +udelay (125 );/* > 4 cycles at 32,768 Hz */ +wdt_write (wdt,AT91_WDT_CR ,AT91_WDT_KEY |AT91_WDT_WDRSTT );return 0 ; }Best Regards,
Wenyou Yang
Hi Wenyou, Guenter,
2016-03-04 6:23 GMT+01:00 Guenter Roeck <[email protected]>:
Quoted 12 lines · Wenyou
Quoted 11 lines · Romain Izard
Quoted 10 lines
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening
/dev/watchdogwithout writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.To avoid this problem, reload the timer on opening the watchdog device.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Command: "while sleep 5; do echo 1; done >
/dev/watchdog" Before:
system reset After: the watchdog runs correctlyI didn't reproduce your issue on my side,
run the your commands as follows, it works fine, the system reset doesn't happen.
I've just verified with the factory image provided on the SAMA5D2 Xplained board. It does not display this behaviour.
But the difference is that in the case without the issue, I'm using the AT91bootstrap SPL, U-Boot, and the kernel from the QSPI chip. When I have the issue, I have a U-Boot based SPL, U-Boot itself and the kernel that come from the FAT partition of an SD-Card.
Userspace does not seem to be involved in the issue, as I can reproduce it both with my buildroot environment, and the Yocto environment from the factory image.
Quoted 12 lines
Different chip revision ? Different chip type ? Different chip initialization by ROMMON ?
Can we get exact chip revisions and types for both cases (working and not working), and (if it might be relevant) a dump of all associated chip registers ?
Quoted 4 lines
I also check the
WDT_MRregister before and after enabling watchdog, the WDV and WDD fields are correct.Can you check it again? thank you.
Working case:
MR on kernel startup: 0x3fffafff MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fff
Problem case:
MR on kernel startup: 0x00008000 MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fff
So this means that the counter reload does not seem to work very well if WDD/WDV have been set to 0 in the past. The other question is why does U-Boot (from the Atmel branch based on 2015.1) put this stange value in this register.
Best regards,
Signature · 1 line
Romain Izard
Guenter Roeck
maintainerQuoted 54 lines · Romain Izard
Hi Wenyou, Guenter,
2016-03-04 6:23 GMT+01:00 Guenter Roeck <[email protected]>:
Quoted 12 lines · Wenyou
Quoted 11 lines · Romain Izard
Quoted 10 lines
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening
/dev/watchdogwithout writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.To avoid this problem, reload the timer on opening the watchdog device.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Command: "while sleep 5; do echo 1; done >
/dev/watchdog" Before:
system reset After: the watchdog runs correctlyI didn't reproduce your issue on my side,
run the your commands as follows, it works fine, the system reset doesn't happen.
I've just verified with the factory image provided on the SAMA5D2 Xplained board. It does not display this behaviour.
But the difference is that in the case without the issue, I'm using the AT91bootstrap SPL, U-Boot, and the kernel from the QSPI chip. When I have the issue, I have a U-Boot based SPL, U-Boot itself and the kernel that come from the FAT partition of an SD-Card.
Userspace does not seem to be involved in the issue, as I can reproduce it both with my buildroot environment, and the Yocto environment from the factory image.
Quoted 12 lines
Different chip revision ? Different chip type ? Different chip initialization by ROMMON ?
Can we get exact chip revisions and types for both cases (working and not working), and (if it might be relevant) a dump of all associated chip registers ?
Quoted 4 lines
I also check the
WDT_MRregister before and after enabling watchdog, the WDV and WDD fields are correct.Can you check it again? thank you.
Working case:
MR on kernel startup: 0x3fffafff MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffProblem case:
Quoted 9 lines
MR on kernel startup: 0x00008000 MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffSo this means that the counter reload does not seem to work very well if WDD/WDV have been set to 0 in the past. The other question is why does U-Boot (from the Atmel branch based on 2015.1) put this stange value in this register.
Can you check the value of AT91_WDT_SR ? Maybe it tells us something.
Also, in the error case, can you check if the watchdog times out at all after you applied your patch ?
Thanks,
Guenter
Quoted 2 lines
Best regards,
2016-03-04 14:09 GMT+01:00 Guenter Roeck <[email protected]>:
Quoted 61 lines · Romain Izard
Quoted 60 lines
2016-03-04 6:23 GMT+01:00 Guenter Roeck <[email protected]>:
Quoted 12 lines · Wenyou
Quoted 11 lines · Romain Izard
Quoted 10 lines
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening
/dev/watchdogwithout writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.To avoid this problem, reload the timer on opening the watchdog device.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Command: "while sleep 5; do echo 1; done >
/dev/watchdog" Before:
system reset After: the watchdog runs correctlyI didn't reproduce your issue on my side,
run the your commands as follows, it works fine, the system reset doesn't happen.
I've just verified with the factory image provided on the SAMA5D2 Xplained board. It does not display this behaviour.
But the difference is that in the case without the issue, I'm using the AT91bootstrap SPL, U-Boot, and the kernel from the QSPI chip. When I have the issue, I have a U-Boot based SPL, U-Boot itself and the kernel that come from the FAT partition of an SD-Card.
Userspace does not seem to be involved in the issue, as I can reproduce it both with my buildroot environment, and the Yocto environment from the factory image.
Quoted 13 lines
Different chip revision ? Different chip type ? Different chip initialization by ROMMON ?
Can we get exact chip revisions and types for both cases (working and not working), and (if it might be relevant) a dump of all associated chip registers ?
Quoted 4 lines
I also check the
WDT_MRregister before and after enabling watchdog, the WDV and WDD fields are correct.Can you check it again? thank you.
Working case:
MR on kernel startup: 0x3fffafff MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffProblem case:
MR on kernel startup: 0x00008000 MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fff
Quoted 8 lines
Quoted 5 lines
So this means that the counter reload does not seem to work very well if WDD/WDV have been set to 0 in the past. The other question is why does U-Boot (from the Atmel branch based on 2015.1) put this stange value in this register.
Can you check the value of
AT91_WDT_SR? Maybe it tells us something.
I didn't report it because it contained 0 at all times. So no information.
Quoted 2 lines
Also, in the error case, can you check if the watchdog times out at all after you applied your patch ?
It times out after 16s as expected, and reboot occurs correctly.
Signature · 1 line
Romain Izard
Guenter Roeck
maintainerQuoted 68 lines · Romain Izard
2016-03-04 14:09 GMT+01:00 Guenter Roeck <[email protected]>:
Quoted 67 lines · Romain Izard
Quoted 65 lines
2016-03-04 6:23 GMT+01:00 Guenter Roeck <[email protected]>:
Quoted 12 lines · Wenyou
Quoted 11 lines · Romain Izard
Quoted 10 lines
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening
/dev/watchdogwithout writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.To avoid this problem, reload the timer on opening the watchdog device.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Command: "while sleep 5; do echo 1; done >
/dev/watchdog" Before:
system reset After: the watchdog runs correctlyI didn't reproduce your issue on my side,
run the your commands as follows, it works fine, the system reset doesn't happen.
I've just verified with the factory image provided on the SAMA5D2 Xplained board. It does not display this behaviour.
But the difference is that in the case without the issue, I'm using the AT91bootstrap SPL, U-Boot, and the kernel from the QSPI chip. When I have the issue, I have a U-Boot based SPL, U-Boot itself and the kernel that come from the FAT partition of an SD-Card.
Userspace does not seem to be involved in the issue, as I can reproduce it both with my buildroot environment, and the Yocto environment from the factory image.
Quoted 13 lines
Different chip revision ? Different chip type ? Different chip initialization by ROMMON ?
Can we get exact chip revisions and types for both cases (working and not working), and (if it might be relevant) a dump of all associated chip registers ?
Quoted 4 lines
I also check the
WDT_MRregister before and after enabling watchdog, the WDV and WDD fields are correct.Can you check it again? thank you.
Working case:
MR on kernel startup: 0x3fffafff MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffProblem case:
MR on kernel startup: 0x00008000 MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffSo this means that the counter reload does not seem to work very well if WDD/WDV have been set to 0 in the past. The other question is why does U-Boot (from the Atmel branch based on 2015.1) put this stange value in this register.
Quoted 9 lines
Quoted 2 lines
Can you check the value of
AT91_WDT_SR? Maybe it tells us something.I didn't report it because it contained 0 at all times. So no information.
Quoted 2 lines
Also, in the error case, can you check if the watchdog times out at all after you applied your patch ?
It times out after 16s as expected, and reboot occurs correctly.
Interesting. So it looks like AT91_WDT_WDRSTT has to be set if the timer values in MR are changed from 0 to another value, or maybe after each timer value change. Wonder if that should be done in the init function, after MR is set (with the watchdog disabled).
Thoughts, anyone ?
Thanks,
Guenter
Hi,
Quoted 79 lines · On Fri, 4 Mar 2016 05:56:20 -0800 Guenter Roeck wrote:
Quoted 68 lines · Romain Izard
2016-03-04 14:09 GMT+01:00 Guenter Roeck <[email protected]>:
Quoted 67 lines · Romain Izard
Quoted 65 lines
2016-03-04 6:23 GMT+01:00 Guenter Roeck <[email protected]>:
Quoted 12 lines · Wenyou
Quoted 11 lines · Romain Izard
Quoted 10 lines
If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening
/dev/watchdogwithout writing in it will immediately trigger a reboot, instead of waiting for the delay to expire.To avoid this problem, reload the timer on opening the watchdog device.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Command: "while sleep 5; do echo 1; done >
/dev/watchdog" Before:
system reset After: the watchdog runs correctlyI didn't reproduce your issue on my side,
run the your commands as follows, it works fine, the system reset doesn't happen.
I've just verified with the factory image provided on the SAMA5D2 Xplained board. It does not display this behaviour.
But the difference is that in the case without the issue, I'm using the AT91bootstrap SPL, U-Boot, and the kernel from the QSPI chip. When I have the issue, I have a U-Boot based SPL, U-Boot itself and the kernel that come from the FAT partition of an SD-Card.
Userspace does not seem to be involved in the issue, as I can reproduce it both with my buildroot environment, and the Yocto environment from the factory image.
Quoted 13 lines
Different chip revision ? Different chip type ? Different chip initialization by ROMMON ?
Can we get exact chip revisions and types for both cases (working and not working), and (if it might be relevant) a dump of all associated chip registers ?
Quoted 4 lines
I also check the
WDT_MRregister before and after enabling watchdog, the WDV and WDD fields are correct.Can you check it again? thank you.
Working case:
MR on kernel startup: 0x3fffafff MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffProblem case:
MR on kernel startup: 0x00008000 MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffSo this means that the counter reload does not seem to work very well if WDD/WDV have been set to 0 in the past. The other question is why does U-Boot (from the Atmel branch based on 2015.1) put this stange value in this register.
Quoted 9 lines
Quoted 2 lines
Can you check the value of
AT91_WDT_SR? Maybe it tells us something.I didn't report it because it contained 0 at all times. So no information.
Quoted 2 lines
Also, in the error case, can you check if the watchdog times out at all after you applied your patch ?
It times out after 16s as expected, and reboot occurs correctly.
Quoted 7 lines
Interesting. So it looks like
AT91_WDT_WDRSTThas to be set if the timer values in MR are changed from 0 to another value, or maybe after each timer value change. Wonder if that should be done in the init function, after MR is set (with the watchdog disabled).Thoughts, anyone ?
Are you aware of the Notes in the SAMA5D4 Reference Manual (Chapter 19.5.2 Watchdog Timer Mode Register):
|Note: The first write access prevents any further modification of | the value of this register. Read accesses remain possible. |Note: The WDD and WDV values must not be modified within three slow | clock periods following a restart of the watchdog performed by | a write access in WDT_CR. Any modification will cause the watchdog to trigger an end of period earlier than expected.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
Hi Lothar,
2016-03-04 15:59 GMT+01:00 Lothar Wa?mann <[email protected]>:
Quoted 43 lines
Quoted 32 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 4 lines
Quoted 4 lines
I also check the
WDT_MRregister before and after enabling watchdog, the WDV and WDD fields are correct.Can you check it again? thank you.
Working case:
MR on kernel startup: 0x3fffafff MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffProblem case:
MR on kernel startup: 0x00008000 MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffSo this means that the counter reload does not seem to work very well if WDD/WDV have been set to 0 in the past. The other question is why does U-Boot (from the Atmel branch based on 2015.1) put this stange value in this register.
Quoted 9 lines
Quoted 2 lines
Can you check the value of
AT91_WDT_SR? Maybe it tells us something.I didn't report it because it contained 0 at all times. So no information.
Quoted 2 lines
Also, in the error case, can you check if the watchdog times out at all after you applied your patch ?
It times out after 16s as expected, and reboot occurs correctly.
Quoted 7 lines
Interesting. So it looks like
AT91_WDT_WDRSTThas to be set if the timer values in MR are changed from 0 to another value, or maybe after each timer value change. Wonder if that should be done in the init function, after MR is set (with the watchdog disabled).Thoughts, anyone ?
Are you aware of the Notes in the SAMA5D4 Reference Manual (Chapter 19.5.2 Watchdog Timer Mode Register):
Quoted 6 lines
|Note: The first write access prevents any further modification of | the value of this register. Read accesses remain possible. |Note: The WDD and WDV values must not be modified within three slow | clock periods following a restart of the watchdog performed by | a write access in WDT_CR. Any modification will cause the watchdog | to trigger an end of period earlier than expected.
This text is valid for older versions of the Watchdog controller, found in AT91SAM9 and SAMA5D3 chips. But SAMA5D4 & SAMA5D2 have a newer revision, which supports multiple writes to the MR register.
Are you sure about your datasheet? I have this in the latest version found on Atmel's site.
Quoted 10 lines
Atmel-11238B-ATARM-SAMA5D4-Datasheet_24-Aug-15
Section 18.5.2Note: Write access to this register has no effect if the LOCKMR
command is issued inWDT_CR(unlocked on hardware reset).
Note: TheWDT_MRregister values must not be modified within three slow
clock periods following a restart of the watchdog performed by a write access inWDT_CR. Any modification will cause the watchdog to trigger an end of period earlier than expected.
It matches the comments from Wenyou when he committed the sama5d4 watchdog driver to replace the existing at91sam9 watchdog.
Best regards,
Signature · 1 line
Romain Izard
Hi,
Quoted 53 lines · On Fri, 4 Mar 2016 16:26:59 +0100 Romain Izard wrote:
Hi Lothar,
2016-03-04 15:59 GMT+01:00 Lothar Wa?mann <[email protected]>:
Quoted 43 lines
Quoted 32 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 4 lines
Quoted 4 lines
I also check the
WDT_MRregister before and after enabling watchdog, the WDV and WDD fields are correct.Can you check it again? thank you.
Working case:
MR on kernel startup: 0x3fffafff MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffProblem case:
MR on kernel startup: 0x00008000 MR after watchdog init: 0x0fffafff MR after start: 0x0fff2fffSo this means that the counter reload does not seem to work very well if WDD/WDV have been set to 0 in the past. The other question is why does U-Boot (from the Atmel branch based on 2015.1) put this stange value in this register.
Quoted 9 lines
Quoted 2 lines
Can you check the value of
AT91_WDT_SR? Maybe it tells us something.I didn't report it because it contained 0 at all times. So no information.
Quoted 2 lines
Also, in the error case, can you check if the watchdog times out at all after you applied your patch ?
It times out after 16s as expected, and reboot occurs correctly.
Quoted 7 lines
Interesting. So it looks like
AT91_WDT_WDRSTThas to be set if the timer values in MR are changed from 0 to another value, or maybe after each timer value change. Wonder if that should be done in the init function, after MR is set (with the watchdog disabled).Thoughts, anyone ?
Are you aware of the Notes in the SAMA5D4 Reference Manual (Chapter 19.5.2 Watchdog Timer Mode Register):
Quoted 6 lines
|Note: The first write access prevents any further modification of | the value of this register. Read accesses remain possible. |Note: The WDD and WDV values must not be modified within three slow | clock periods following a restart of the watchdog performed by | a write access in WDT_CR. Any modification will cause the watchdog | to trigger an end of period earlier than expected.
Quoted 10 lines
This text is valid for older versions of the Watchdog controller, found in AT91SAM9 and SAMA5D3 chips. But SAMA5D4 & SAMA5D2 have a newer revision, which supports multiple writes to the MR register.
Are you sure about your datasheet? I have this in the latest version found on Atmel's site.
Quoted 3 lines
Atmel-11238B-ATARM-SAMA5D4-Datasheet_24-Aug-15
Section 18.5.2
OK, I obviously had an outdated Manual.
Lothar Wa?mann