Skip to content
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

tests: boards: nrf: hwinfo: Add test for reset cause on nrf54* #83126

Conversation

nordic-segl
Copy link
Contributor

@nordic-segl nordic-segl commented Dec 17, 2024

Add test that checks reset cause reported by HWINFO.

Check that hwinfo_get_supported_reset_cause() returns expected value.

Check that hwinfo_get_reset_cause() correctly detects:

  • RESET_PIN,
  • RESET_SOFTWARE,
  • RESET_WATCHDOG.

Check that reset cause can be cleared with hwinfo_clear_reset_cause().

@zephyrbot zephyrbot added the area: HWINFO Hardware Information Driver label Dec 17, 2024
@nordic-segl
Copy link
Contributor Author

FYI: @nordic-piks , @kl-cruz.

@nordic-segl nordic-segl force-pushed the NRFX-6895_Test-hwinfo-reset-cause branch 2 times, most recently from f9a9ae6 to 505de46 Compare December 18, 2024 07:26
nordic-segl added a commit to nordic-segl/sdk-nrf that referenced this pull request Dec 18, 2024
Include
tests: drivers: hwinfo: Add test for reset cause on nrf54h20
nrfconnect/sdk-zephyr#2401
zephyrproject-rtos/zephyr#83126

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
@nordic-segl nordic-segl force-pushed the NRFX-6895_Test-hwinfo-reset-cause branch 2 times, most recently from 99cbcef to 38ef8e2 Compare December 18, 2024 09:30
@nordic-segl
Copy link
Contributor Author

Build failure on nrf54l15dk (undefined reference to `sys_reboot') will be analysed by driver developers.
I will remove this target from platform_allow until build failure is fixed.

@nordic-segl nordic-segl force-pushed the NRFX-6895_Test-hwinfo-reset-cause branch from 38ef8e2 to 1ccf77c Compare December 18, 2024 10:16
nordic-segl added a commit to nordic-segl/sdk-nrf that referenced this pull request Dec 18, 2024
Include
tests: drivers: hwinfo: Add test for reset cause on nrf54h20
nrfconnect/sdk-zephyr#2401
zephyrproject-rtos/zephyr#83126

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
Copy link
Member

@alexanderwachter alexanderwachter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm not in favor of this tests.
This test are very hw dependent. For example, I don't think that there is a guarantee that data is retained after a reset in noinit sections.
Second, you should make use of the testing framework for maintainability.

@nordic-segl
Copy link
Contributor Author

nordic-segl commented Jan 7, 2025

To be honest, I'm not in favor of this tests. This test are very hw dependent. For example, I don't think that there is a guarantee that data is retained after a reset in noinit sections. Second, you should make use of the testing framework for maintainability.

Indeed, this test is "complicated". However, this is because there are resets in the middle of each test case:

  • read reset causes and confirm it was RESET_PIN (first assumption - there is pin-reset after flashing HEX file);
  • print supported reset causes;
  • trigger software rest;
  • after boot, confirm that reset cause is RESET_SOFTWARE;
  • configure watchdog and wait until it expires / resets CPU;
  • after boot, confirm that reset cause is RESET_WATCHDOG

This test are very hw dependent.

Therefore, I put platform_allow in the testcase.yaml

For example, I don't think that there is a guarantee that data is retained after a reset in noinit sections.

I have to store somehow information about test suite state. Solution where test state is stored in variable at .noinit section was copied from following watchdog driver test:
https://github.com/zephyrproject-rtos/zephyr/blob/main/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c#L384

Second, you should make use of the testing framework for maintainability.

ZTEST test framework doesn't support reset in the middle of test. After boot, it will always start with the first test case.
Above mentioned watchdog test has single ZTEST for all test cases. It uses single variable and multiple if statements to detect which test case was executed and to determine test result. What I don't like there is that test result PASS doesn't inform which particular test cases were executed.
I've decided to use State Machine design pattern instead.

@alexanderwachter : What about moving it to a different directory?
https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/boards/nrf

@nordic-segl nordic-segl force-pushed the NRFX-6895_Test-hwinfo-reset-cause branch from 1ccf77c to 272bd40 Compare January 7, 2025 11:33
nordic-segl added a commit to nordic-segl/sdk-nrf that referenced this pull request Jan 7, 2025
Include
tests: drivers: hwinfo: Add test for reset cause on nrf54h20
nrfconnect/sdk-zephyr#2401
zephyrproject-rtos/zephyr#83126

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
@nordic-segl nordic-segl force-pushed the NRFX-6895_Test-hwinfo-reset-cause branch 3 times, most recently from 5b750fe to 1daa2e2 Compare January 8, 2025 13:04
nordic-segl added a commit to nordic-segl/sdk-nrf that referenced this pull request Jan 8, 2025
Include
tests: drivers: hwinfo: Add test for reset cause on nrf54h20
nrfconnect/sdk-zephyr#2401
zephyrproject-rtos/zephyr#83126

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
@nordic-segl nordic-segl changed the title tests: drivers: hwinfo: Add test for reset cause on nrf54h20 tests: drivers: hwinfo: Add test for reset cause on nrf54* Jan 8, 2025
nordic-segl added a commit to nordic-segl/sdk-nrf that referenced this pull request Jan 9, 2025
Include
tests: drivers: hwinfo: Add test for reset cause on nrf54h20
nrfconnect/sdk-zephyr#2401
zephyrproject-rtos/zephyr#83126

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
Add test that checks reset cause reported by HWINFO.

Check that hwinfo_get_supported_reset_cause() returns
expected value.

Check that hwinfo_get_reset_cause() correctly detects:
- RESET_PIN,
- RESET_SOFTWARE,
- RESET_WATCHDOG.

Check that reset cause can be cleared
with hwinfo_clear_reset_cause().

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
@nordic-segl nordic-segl force-pushed the NRFX-6895_Test-hwinfo-reset-cause branch from 1daa2e2 to 8461966 Compare January 13, 2025 07:43
@nordic-segl nordic-segl changed the title tests: drivers: hwinfo: Add test for reset cause on nrf54* tests: boards: nrf: hwinfo: Add test for reset cause on nrf54* Jan 13, 2025
@nordic-segl
Copy link
Contributor Author

I moved test to zephyr/tests/boards/nrf/hwinfo/reset_cause/

nordic-segl added a commit to nordic-segl/sdk-nrf that referenced this pull request Jan 16, 2025
Include
tests: drivers: hwinfo: Add test for reset cause on nrf54h20
nrfconnect/sdk-zephyr#2401
zephyrproject-rtos/zephyr#83126

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
nordic-segl added a commit to nordic-segl/sdk-nrf that referenced this pull request Jan 17, 2025
Include
tests: drivers: hwinfo: Add test for reset cause on nrf54h20
nrfconnect/sdk-zephyr#2401
zephyrproject-rtos/zephyr#83126

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
@nordic-segl nordic-segl deleted the NRFX-6895_Test-hwinfo-reset-cause branch January 17, 2025 11:39
nordic-segl added a commit to nordic-segl/sdk-nrf that referenced this pull request Jan 20, 2025
Include
tests: drivers: hwinfo: Add test for reset cause on nrf54h20
nrfconnect/sdk-zephyr#2401
zephyrproject-rtos/zephyr#83126

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
nordic-segl added a commit to nordic-segl/sdk-nrf that referenced this pull request Jan 20, 2025
Include
tests: drivers: hwinfo: Add test for reset cause on nrf54h20
nrfconnect/sdk-zephyr#2401
zephyrproject-rtos/zephyr#83126

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
rlubos pushed a commit to nrfconnect/sdk-nrf that referenced this pull request Jan 20, 2025
Include
tests: drivers: hwinfo: Add test for reset cause on nrf54h20
nrfconnect/sdk-zephyr#2401
zephyrproject-rtos/zephyr#83126

Signed-off-by: Sebastian Głąb <sebastian.glab@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: HWINFO Hardware Information Driver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants