Skip to content

Own selected Cortex-M cores and retain partial outcomes. - #82

Merged
jon merged 3 commits into
mainfrom
work/cortexm-group
Oct 4, 2026
Merged

jon merged 3 commits into
mainfrom
work/cortexm-group

Conversation

@jon

@jon jon commented Oct 4, 2026

Copy link
Copy Markdown
Owner

cortexm.AcquireGroup acquires an explicit set of Cortex-M0/M33 targets over borrowed memory clients. Selected halt, resume, and status calls return per-core outcomes, including members not reached after a failure; register and step access stays inside the owned targets.

group, err := cortexm.AcquireGroup(ctx, []cortexm.Member{
    {ID: 1, Memory: memory0},
    {ID: 2, Memory: memory1},
})
if err == nil {
    _, err = group.Halt(ctx, 1, 2)
    if err == nil {
        _, err = group.Status(ctx, 1, 2)
    }
    if err == nil {
        _, err = group.ReadRegister(ctx, 1, cortexm.PC)
    }
    if err == nil {
        err = group.WriteRegister(ctx, 1, cortexm.R4, r4Value)
    }
    if err == nil {
        err = group.Step(ctx, 1)
    }
    if err == nil {
        _, err = group.Resume(ctx, 1)
    }
}
cleanup, cancel := context.WithTimeout(context.Background(), 5*time.Second)
_, releaseErr := group.Release(cleanup)
cancel()
err = errors.Join(err, releaseErr)
if releaseErr == nil {
    err = errors.Join(err, owner.Close())
}

The memory clients above are borrowed from one Arm owner; r4Value is an intentional register change which persists after release. If release fails, retain the group and Arm owner for another cleanup attempt. Group.Results copies the latest member outcomes without traffic.

Why

Separate targets already control the RP2350 cores, but their caller must track partial progress and cleanup independently. The group owns that lifecycle, preserves inherited halts, releases only halt requests it still owns, and attempts independent cleanup after a member fails. The caller still serializes calls over the shared connection. Sequential stopping does not promise simultaneous halt, and the group does not own CTI routing.

Documentation

Update the Cortex-M guide, architecture, composition, and capability table with group ownership, selected control, member access, and cleanup limits.

Hardware evidence

On the prepared RP2350 Secure dual-counter bench, J-Link EDU Mini V2 000802011345 at 1 MHz with APs 0x2000/0x4000, run:

OSTIOLE_RP2350_HIL_GROUP=1 \
OSTIOLE_RP2350_HIL_PROGRAM=bf878b47815bc5eaf6afb5279efaa6ff163832bd178c5b7b1604f80e6ad6cde9 \
go test -tags integration ./target/cortexm -run '^TestHILRP2350Group$' -count=1 -v

Two fresh sessions read all 19 registers on each core, verified one PC/R0/RAM step per core while its peer advanced, stopped both cores sequentially, verified another core-0 step while its peer stayed stopped, and resumed only core 0. In each session, group release restored progress on both cores and their initial disabled-debug/running state before the shared owner closed; DSCSR and inactive CTI configuration were unchanged. Group release and owner close succeeded in both sessions. Post-close state was not independently measured. Register writes and injected failures were not exercised physically, and the prepared RAM programs and instruction effects remain.

jon added 3 commits October 2, 2026 04:26
Callers that acquire several targets currently have to track which
acquisitions succeeded and which targets still need restoration. Own
those targets over borrowed memory, retain per-member results, and
restore independent members after failure. Keep lower owners live while
restoration remains pending.
Independent targets require callers to track partial stop and resume
progress. Report selected outcomes in membership order, preserve unowned
halts, and retain uncertain members for cleanup without replaying
writes. Observe execution separately from a retained halt-request claim.
A group cannot lend raw targets without bypassing its lifecycle. Route
register and step operations through its selected member and retain the
same transfer, event, and cleanup rules. Exercise the composition on the
prepared RP2350 counters without changing inherited CTI routing.
@jon

jon commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T19:47:02.616298Z 4331bf6 Manual request
🔒 Security Review ✅ Completed 2026-10-04T19:39:50.379811Z 4331bf6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4331bf6c64

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread target/cortexm/group.go Resolved
@jon

jon commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review the individual commits as well as the final diff. The previous commit-size finding counted the complete PR as one commit; the published series already separates acquisition/release (89ecdf0, 168 added non-test Go lines), selected control (0098318, 156), and member access (4331bf6, 43), each with tests and documentation. The head remains 4331bf6.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 4331bf6c64

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jon
jon merged commit 0c8f75b into main Oct 4, 2026
9 checks passed
@jon
jon deleted the work/cortexm-group branch October 4, 2026 19:48
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