Skip to content

WFI: Reacquire control of the core in the debugger after it executes a WFI instruction#43

Merged
eyck merged 1 commit intoMinres:mainfrom
quic-prateek:debugger_stop_issue_with_wfi
Mar 7, 2026
Merged

WFI: Reacquire control of the core in the debugger after it executes a WFI instruction#43
eyck merged 1 commit intoMinres:mainfrom
quic-prateek:debugger_stop_issue_with_wfi

Conversation

@quic-prateek
Copy link
Contributor

Issue: When the core executes a WFI instruction (or RISC-V equivalent) we cannot regain the core from the debugger

Root Cause: When the firmware executes the WFI instruction, core start waiting for the WFI event and it suspends the thread that runs execute_inst. The problem is that this same thread is responsible for checking whether the debugger has issued a stop request. Because the thread is suspended during WFI, it cannot evaluate the stop condition or call the GDB session’s stop_callback.

Fix: A new gdb_stop_evt event was added, triggered when the debugger issues a stop request. The thread now waits on wfi_evt or gdb_stop_evt (SystemC OR event list). After waking, it checks whether gdb_stop_evt triggered; if so, it exits the loop immediately.

eyck
eyck previously approved these changes Mar 6, 2026
Copy link
Contributor

@eyck eyck left a comment

Choose a reason for hiding this comment

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

LGTM

@eyck eyck dismissed their stale review March 6, 2026 15:05

Failing build

Copy link
Contributor

@eyck eyck left a comment

Choose a reason for hiding this comment

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

There is an update of the dbt-rise-core commit hash in the toplevel CMakeList.txt line 30 needed

@quic-prateek quic-prateek force-pushed the debugger_stop_issue_with_wfi branch 3 times, most recently from ad01da6 to d168843 Compare March 6, 2026 17:03
…a WFI instruction.

A new gdb_stop_evt event was added, triggered when the debugger issues
a stop request. The thread now waits on wfi_evt or gdb_stop_evt
(SystemC OR event list). After waking, it checks whether gdb_stop_evt triggered;
if so, it exits the loop immediately.
@quic-prateek quic-prateek force-pushed the debugger_stop_issue_with_wfi branch from d168843 to bd008da Compare March 6, 2026 17:05
@quic-prateek
Copy link
Contributor Author

There is an update of the dbt-rise-core commit hash in the toplevel CMakeList.txt line 30 needed

updated with 5d1ab03db17819fc113d3c4182cf0cee666085f2 hash. Thanks!

@eyck eyck merged commit d0acc6c into Minres:main Mar 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants