Skip to content

coresight: cortex_m: gracefully handle inaccessible core after reset#1953

Open
fbnors wants to merge 1 commit intopyocd:mainfrom
fbnors:fix/cortex-m-post-reset-state-check
Open

coresight: cortex_m: gracefully handle inaccessible core after reset#1953
fbnors wants to merge 1 commit intopyocd:mainfrom
fbnors:fix/cortex-m-post-reset-state-check

Conversation

@fbnors
Copy link
Copy Markdown

@fbnors fbnors commented Apr 7, 2026

When performing a post-reset check in _inner_reset to ensure the core is not halted, get_state() reads the DHCSR register via SWD. On certain MCUs (like the LPC55S28), the SWD link may drop or become temporarily inaccessible immediately after a reset, causing get_state() to throw a TransferFaultError.

Previously, this unhandled exception would bubble up and cause the flash operation to crash with a fatal status 1 exit code, even if the flash and reset were otherwise successful.

This adds a try/except block around the state check in _inner_reset() to catch exceptions.Error. If the core state cannot be read or resumed, it logs a warning instead of aborting the entire command.

When performing a post-reset check in `_inner_reset` to ensure the core is not
halted, `get_state()` reads the DHCSR register via SWD. On certain MCUs (like
the LPC55S28), the SWD link may drop or become temporarily inaccessible
immediately after a reset, causing `get_state()` to throw a TransferFaultError.

Previously, this unhandled exception would bubble up and cause the flash
operation to crash with a fatal status 1 exit code, even if the flash and
reset were otherwise successful.

This adds a `try/except` block around the state check in `_inner_reset()` to
catch `exceptions.Error`. If the core state cannot be read or resumed, it logs
a warning instead of aborting the entire command.
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.

1 participant