Skip to content

Inspect ADIv6 access ports and RP2350 debug components. - #72

Merged
jon merged 7 commits into
mainfrom
jon/adiv6-rp2350
Sep 21, 2026
Merged

jon merged 7 commits into
mainfrom
jon/adiv6-rp2350

Conversation

@jon

@jon jon commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Add DPv3 register access, ADIv6 AP base-address selection, and MEM-AP access through the existing DAP and Arm debug owners. A borrowed debug-space reader composes with the bounded CoreSight walker to discover AP bases. The CoreSight example accepts -debug-space and -ap-base selections. The existing ADIv5 SWD and baseline JTAG paths remain available.

Given an open armdebug.Conn named connection, inspect the DP's advertised hierarchy before acquiring MEM-APs:

space := connection.Port().DebugSpace()
base, present, err := space.ReadDebugBase(ctx)
if err != nil {
    return err
}
if !present {
    return errors.New("debug port advertises no discovery root")
}
visits, err := coresight.Walk(ctx, space, base, coresight.WalkLimits{
    MaxDepth: 8, MaxComponents: 64, MaxEntries: 256,
})
fmt.Printf("components=%d\n", len(visits))
if err != nil {
    return err
}

Select a discovered MEM-AP explicitly. On the exercised RP2350, one is at 0x2000:

ap, err := dap.APAt(0x2000)
if err != nil {
    return err
}
memory, err := connection.OpenMemAP(ctx, ap)
if err != nil {
    return err
}
processor, err := cortexm.Identify(ctx, memory)
if err != nil {
    return err
}
fmt.Printf("%s CPUID=%#08x\n", ap, processor.Raw)

The caller retains connection and closes it after inspection, retrying failed cleanup. Raw debug-space reads can have register-specific effects and invalidate existing MEM-AP clients, so discovery precedes memory acquisition. Neither operation acquires or halts the processor.

APSel.Address now accepts uint16. Untyped constants need no change; typed byte offsets migrate as follows:

// Before:
address := ap.Address(offset) // offset is uint8

// After:
address := ap.Address(uint16(offset))

NewAPSel and Value describe ADIv5 indices; APAt and BaseAddress describe ADIv6 bases. The zero selector remains invalid. DPv3 also exposes DPIDR1, BASEPTR0/1, and SELECT1 through the existing logical register API.

Why

ADIv6 uses a debug address space and 4 KiB AP register windows instead of ADIv5 APSEL indices and 256-byte windows. Its discovery root belongs to the DP's address space; a MEM-AP's advertised debug base belongs to target memory. Keeping those spaces explicit lets the existing component reader and ROM walker serve both.

ADIv6 transactions complete each AP operation before sending the next, sharing the sequential execution used by JTAG. ADIv5 SWD retains packed execution. Address-width and architecture checks reject invalid selections before AP requests. If MEM-AP restoration fails, the caller can retry cleanup. DP ERRMODE and MEM-AP modes that suppress or defer errors remain unsupported and are rejected.

Documentation

Update the DAP, architecture, composition, capability, and CoreSight guides, along with the example instructions. Document the address-argument migration, borrowed-reader lifetime, discovery bounds, and the distinction between DP and target-memory roots.

Hardware evidence

On Nostalgia, J-Link EDU Mini V2 serial 000802011345 accessed the attached RP2350 over SWD at a requested 100 kHz. Two fresh sessions per path ran:

OSTIOLE_ARMDEBUG_HIL=1 \
  OSTIOLE_PROBE_HIL_PROVIDER=jlink \
  OSTIOLE_PROBE_HIL_SERIAL=000802011345 \
  OSTIOLE_ARMDEBUG_HIL_DEBUG_SPACE=1 \
  go test -tags=integration ./armdebug -run '^TestHILArmConnection$' -count=2 -v

for ap_base in 0x2000 0x4000; do
  OSTIOLE_ARMDEBUG_HIL=1 \
    OSTIOLE_PROBE_HIL_PROVIDER=jlink \
    OSTIOLE_PROBE_HIL_SERIAL=000802011345 \
    OSTIOLE_ARMDEBUG_HIL_AP_BASE="$ap_base" \
    OSTIOLE_ARMDEBUG_HIL_WALK=1 \
    go test -tags=integration ./armdebug -run '^TestHILArmConnection$' -count=2 -v
done

DPIDR was 0x4c013477, DPIDR1 was 0x94, and the discovery root was address zero. Its class 9 ROM walk completed with seven identities, including the two Arm MEM-APs. Both APs returned IDR 0x34770008, CPUID 0x411fd210, and target-memory debug base 0xe00ff000; both memory walks completed with seven identities. The integration limits were depth 8, 64 visits, 256 entry reads, and a ten-second deadline.

The example also completed the debug-space walk and both MEM-AP walks using the same provider and serial, with -debug-space -walk, -ap-base 0x2000 -walk, and -ap-base 0x4000 -walk respectively. All connection cleanup calls returned successfully. Restored state was not independently measured afterward. No target-memory write, halt, reset, component unlock, or component power request was performed. These walks cover advertised entries; addresses above 32 bits, memory writes, and injected failures have simulation coverage but were not exercised on this bench.

jon added 5 commits September 20, 2026 14:54
DPv3 banks the DPIDR address and adds the address-width and
discovery-base registers needed to locate its access ports. Treating
DPIDR as independent of SELECT would return another register after
reading a nonzero bank.

Select the correct bank for immediate and queued DP reads, expose the
DPv3 registers, and model them in the behavioral target. Earlier debug
ports and baseline JTAG reject registers they do not implement.
ADIv6 uses aligned AP base addresses and 4 KiB register windows instead
of ADIv5 APSEL indices. Reusing an index would select the wrong
register.

Keep those selectors distinct, check them against the connected DP and
its advertised address width, and select both address words when needed.
Immediate AP reads and writes retain posted completion and existing
recovery. Queued AP operations and MEM-AP acquisition remain ADIv5-only.
ADIv6 MEM-APs place their registers at offset 0xd00. Use that layout
inside the existing memory client and accept base-address selectors in
armdebug so callers retain the same acquisition and cleanup rules.

Share sequential transaction execution with JTAG while retaining packed
ADIv5 SWD transfers. Complete each AP operation before advancing,
preserve confirmed block prefixes, and keep failed restoration
retryable. Reject error modes that could suppress failures the client
needs to observe.
An ADIv6 debug port advertises a component tree in its own address
space, separate from memory reached through a MEM-AP. Expose a borrowed
word reader and decode BASEPTR0/1 so the existing bounded CoreSight
walker can discover AP bases without a second ROM parser or a hard-coded
scan.

Keep raw-access invalidation visible, reject unsupported widths and
malformed bases, and leave cleanup with the debug-port owner.
The example previously accepted only an ADIv5 AP index. Add explicit
ADIv6 AP-base and DP debug-space selections so the same bounded walker
can inspect the advertised AP hierarchy or memory behind a chosen AP.

Keep selection and output in the example while the borrowed readers own
addressing. Record the RP2350 discovery and memory observations with the
commands, cleanup results, and limits of the bench evidence.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 20, 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-09-21T00:17:04.141643Z b6349d1 Manual request
🔒 Security Review Completed 2026-09-20T23:39:13.676339Z 9fdf47c 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.

@jon

jon commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: 9fdf47c8a5

ℹ️ 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 dap/swddp.go
ADIv6 AP selectors checked the debug port's address width, but raw
SELECT and SELECT1 writes could still send reserved address bits. Apply
the same limit to immediate and queued DP writes before any traffic,
while allowing the independent DPBANKSEL field.
@jon

jon commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: be2beb57d5

ℹ️ 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 dap/sim/target.go Outdated
@jon

jon commented Sep 20, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: b2fe8711f8

ℹ️ 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 dap/sim/target.go
Fixture setup accepted selectors for incompatible or unsupported DP
versions and ADIv6 addresses beyond the configured width. The public DAP
API could not reach those fixtures despite their successful setup.

Validate selectors against the target's DPIDR during fixture setup and
updates, and check ADIv6 addresses against its supported address width.
DPv3 fixtures require DPIDR1 to be configured first.
@jon

jon commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: b6349d17cf

ℹ️ 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 dap/apv2.go
@jon

jon commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: b6349d17cf

ℹ️ 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 513fbf8 into main Sep 21, 2026
9 checks passed
@jon
jon deleted the jon/adiv6-rp2350 branch September 21, 2026 00:17
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