-
Notifications
You must be signed in to change notification settings - Fork 3k
Add watchdog lower limit timeout test #11203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add watchdog lower limit timeout test #11203
Conversation
@Tharazi97, thank you for your changes. |
2611bba
to
bb32361
Compare
@Tharazi97 if we can fix it, would be great. Just need more details. |
I reduced reviewers. Please review |
@0xc0170 Test that I added checks if watchdog is physically triggering after the timeout value, if not it chcecks how close we are to this value. |
We can change the assumption to: "The watchdog should trigger at or after the 75% timeout value.", or: "The watchdog should trigger at or after the timeout value (not applicable STM devices)." |
I would prefer to change this line... Thx |
Maybe we could add some frequency accuracy parameter in watchdog_features_t that test can check ? |
@jeromecoutant |
@@ -64,6 +64,16 @@ void test_restart_reset(); | |||
*/ | |||
void test_kick_reset(); | |||
|
|||
/** Test Watchdog timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to duplicate this test for the driver layer? As I see it, this test simply checks the actual hardware performance, right? Both HAL and driver APIs are verified by other test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -264,6 +266,48 @@ void test_kick_reset() | |||
TEST_ASSERT_MESSAGE(0, "Watchdog did not reset the device as expected."); | |||
} | |||
|
|||
template<uint32_t window> | |||
void test_timeout() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a timing test, I think it should be moved to TESTS/mbed_hal/watchdog_timing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -42,6 +42,8 @@ | |||
*/ | |||
#define KICK_ADVANCE_MS 35UL | |||
|
|||
#define TIMEOUT_LOWER_LIMIT 1000UL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the convention of adding a unit suffix.
#define TIMEOUT_LOWER_LIMIT 1000UL | |
#define TIMEOUT_LOWER_LIMIT_MS 1000UL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -310,6 +354,12 @@ Case cases[] = { | |||
#endif | |||
Case("Watchdog started again", case_setup, test_restart_reset), | |||
Case("Kicking the Watchdog prevents reset", case_setup, test_kick_reset), | |||
Case("timeout accuracy 20%", case_setup, test_timeout<200UL>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we know, for some targets these tests will fail for sure if the watchdog clock is left uncalibrated. I think we should add #if MBED_EXTENDED_TESTS
here, to skip these tests on the CI.
|
||
// Kick watchdog before timeout. | ||
// Watchdog should not trigger before timeout. | ||
// If device restarts while waiting for the kick, test fails. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently this produces an ERROR
test case result instead of FAIL
. Could you update that?
That seems useful; would help the user to determine the watchdog timing capabilities. @donatieng, @0xc0170, what do you think? |
What would this number define and how it would be used? Illustration might help |
So for example this is the documentation of STM32L073RZ. As we can see typical frequency is 38 kHz, but it may vary from 26 to 56 kHz. In its implementation of the watchdog LSI value is defined as 38 kHz, so ratio of defined value to max value is equal to 67% (rounding down). I would name this parameter clock_accuracy and it would mean how accurate is not calibrated watchdog clock. The bigger value, the watchdog clock is more precise. Practical use of this value would be to determine when to kick watchdog when it is not calibrated, so the device would not restart when not expected. With this value, the test would look something like this:
|
bb32361
to
944e8f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clock accuracy
- is this in percentage (0-100) ? Not documented in hal header file
@@ -136,6 +136,9 @@ | |||
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz | |||
The real value may vary depending on the variations | |||
in voltage and temperature.*/ | |||
#if !defined (LSI_ACCURACY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not be touching these device files as they get updated from upstream. This could be defined in our codebase (config for instance), and used in the watchdog HAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ARMmbed/team-st-mcd please review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, don't patch files in device directory (except bugs)
Thx
@ARMmbed/team-st-mcd Please review |
Silabs build errors are fixed now. As for the release notes -- I couldn't edit the original PR description. @adbridge, @0xc0170, could you paste this note there?:
|
Minor Watchdog docs update in ARMmbed/mbed-os-5-docs#1155. |
Hi, sorry for not responding. Thank you @fkjagodzinski for taking care of this functionality. |
👍 for the update, will schedule CI soon |
CI started |
Test run: FAILEDSummary: 1 of 11 test jobs failed Failed test jobs:
|
Failures related, |
@Tharazi97 Any update? |
@0xc0170, I'm looking into this failure right now. Will post an update shortly. |
CI restarted |
I updated the new test case (added in this PR) so that sleep or deepsleep mode will not be active during the wait for the watchdog reset. Testing a watchdog performance in both sleep modes is taken care of in a different test suite. As for the K64F, I've created an issue for the deepsleep watchdog case -- #11774. |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Travis has not reported back, I restarted it |
Description
Currently there is no test that checks if watchdog on the device meets the assumption specified in docs: "The watchdog should trigger at or after the timeout value.".
This PR adds one to the base of watchdog reset tests.
It checks whether the watchdog did not restart the device before the window left to the end of timeout. If watchdog restarted the device, the test will time out.
Targets with not calibrated watchdog clock won't pass this test. This is the case for some STM MCU, default calibration is not accurate at all, so we should probably:
Pull request type
Reviewers
@fkjagodzinski @0xc0170 @maciejbocianski @jamesbeyond
Release Notes
watchdog_features_t
extended by twouint32_t
members:clock_typical_frequency
andclock_max_frequency
. These values can be used to determine the accuracy of an uncalibrated watchdog clock.