Skip to content

Conversation

tpambor
Copy link
Contributor

@tpambor tpambor commented Sep 6, 2025

This PR adds support for reporting the reset cause to native_sim.

The default is to report POR (Power-On Reset).
If the system is rebooted using sys_reboot(), the reset cause is set to SOFTWARE.

@zephyrbot zephyrbot added area: HWINFO Hardware Information Driver area: native port Host native arch port (native_sim) labels Sep 6, 2025
Copy link
Member

@aescolar aescolar left a comment

Choose a reason for hiding this comment

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

Question out of curiosity, are you doing this change because you have a need for it? or just because you thought it may be nice for somebody to have it?

Requested changes:

  • Let's also add a test for this (I just added one here, you are more than welcome to take it):
    aescolar@688ca66

  • Note a few requests for changes below.

And a general comment which does not need any action, but just a remark:
Right now, this HW_info peripheral can be built for any posix arch based target, but the reboot logic is optional and only for the native_sim target.
This means this hw_info reset cause code will only do what is expected in the native_sim case when CONFIG_NATIVE_SIM_REBOOT is enabled.
Note, in tree, we only have the native_sim and nrfbsim targets. And the nrfbsim targets are likely to have the real nrf hw info driver enabled at some point.
This is not a problem beyond being potentially confusing for users.

@aescolar
Copy link
Member

aescolar commented Sep 8, 2025

CC @koalatux

Align with native_simulator's upstream main
4eab13716376e63236d77013f996a897d24dd780

Which includes:
4eab137 Host trampolines: Add getenv/setenv

Signed-off-by: Tim Pambor <[email protected]>
Support reporting the reset cause for native_sim. The default is to
report POR (Power-On Reset). If CONFIG_NATIVE_SIM_REBOOT was enabled and
the system is rebooted using sys_reboot(), the reset cause is set to
SOFTWARE.

Signed-off-by: Tim Pambor <[email protected]>
@tpambor tpambor force-pushed the native-sim-reset-cause branch from 25ddcc9 to 0bbab08 Compare September 28, 2025 06:03
@zephyrbot zephyrbot added area: Tests Issues related to a particular existing or missing test area: Boards/SoCs labels Sep 28, 2025
@zephyrbot zephyrbot requested a review from nashif September 28, 2025 06:04
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.

Nice to have hwinfo in native_sim!
Thanks!

Add a test of the CONFIG_NATIVE_SIM_REBOOT functionality together
with the hw_info get_reset_cause() logic.

Signed-off-by: Alberto Escolar Piedras <[email protected]>
@tpambor tpambor force-pushed the native-sim-reset-cause branch from 0bbab08 to ce03563 Compare September 28, 2025 08:12
Copy link

@tpambor
Copy link
Contributor Author

tpambor commented Sep 28, 2025

@aescolar Thanks for the review and the test case. I included it in this PR. I also incorporated your requested changes and rebased on main.

@tpambor tpambor requested a review from aescolar September 28, 2025 09:02
@cfriedt cfriedt merged commit 9669cc3 into zephyrproject-rtos:main Sep 29, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Boards/SoCs area: HWINFO Hardware Information Driver area: native port Host native arch port (native_sim) area: Tests Issues related to a particular existing or missing test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants