Skip to content

Debug Description: Programmatic indication of an error happening while __errorcontrol is set to ignore errorsΒ #325

@jreineckearm

Description

@jreineckearm

The CMSIS debug description comes with a mechanism to instruct the debugger to ignore access errors. It uses a bit in the __errorcontrol debug access variable to activate/deactivate that mode. See https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/debug_description.html#DebugVars

Historically, this mechanism was designed for write accesses. For example, depending on the HW design, a write to AIRCR.SYSRESETREQ could cause a temporary debug connection loss which ended in a protocol error because the SWDIO and SWDCLK lines weren't driven as expected.

Since then, we've seen this mechanism being used more and more for polling the device state while secured bootloaders run. During such a phase, debug may be turned off to protected sensitive assets.
Depending on the polled device state register (could be a single bit), the lack of a well-defined return value for read functions in case of an error, or even better a state variable to indicate success of the last target access becomes more and more of an issue. This gap needs to be closed.

Given that a return value (instead of a data value) may cause new corner cases where the mechanism fails (one device requires a single bit check for 0 where the other requires a 1), a proper success indicator is preferred. There are a couple approaches to the latter:

  • Reuse currently reserved bits in __errorcontrol. This may however become a fiddly with bitwise operations.
  • Introduce a debug access variable __errorstate or __lasterror indicating success of the last called debug access function.
    • This would allow more detailed error codes.

Happy to work on a proposal for this and open a docs PR for discussion.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions