Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 66 additions & 38 deletions .agents/skills/prepare-ra8p1-trace/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: prepare-ra8p1-trace
description: Prepare this repository's EK-RA8P1 CPU0 debug description and normal SWO trace runtime after a build or CMSIS refresh. Applies the temporary RA_DFP 6.6.0 configuration with CMake and the installed pyTS; does not start a hardware session.
description: Prepare this repository's EK-RA8P1 CPU0 debug description and SWO file runtime after the final build or CMSIS refresh, using the pinned debug template and installed pyTS. Does not patch a PDSC or start hardware.
---

# Prepare RA8P1 trace
Expand All @@ -9,49 +9,77 @@ Apply the temporary CPU0/AP0 and SWO configuration for `EK-RA8P1@ULINKplus`
in the repository containing `Trace.csolution.yml`. Read the
[board procedure](../../../Board/EK-RA8P1/README.md#debug-and-trace-preparation)
for the DFP gap and the [trace workflow](../../../docs/TRACE_APP.md#configure-and-generate-trace)
for normal profile generation. Other targets use their existing setup.

1. Check that the selected solution/target is this repository's
`EK-RA8P1@ULINKplus`, with `Renesas::R7KA8P1KF:CPU0` and
`Renesas::RA_DFP@6.6.0`. Do not switch a different active target silently or
apply this pinned description to another DFP version.
2. Complete any required build/refresh first. Use `cmsis_action build` when
available, or the documented `cbuild` command in the board procedure.
Require the current `out/TraceDemo/EK-RA8P1/Debug/TraceDemo.elf` and generated
`out/Trace+EK-RA8P1.cbuild-run.yml`. Preserve existing source trace settings.
3. From the repository root, apply the versioned description with the existing
build tool; no custom script or YAML rewrite is needed:
for normal profile generation. Use file tools; no custom helper or build hook.

## Preflight before changing files

1. Verify this workspace's selected solution/target is `EK-RA8P1@ULINKplus`,
device `Renesas::R7KA8P1KF:CPU0`, pack `Renesas::RA_DFP@6.6.0` and the normal
Debug context. Stop on a mismatch; do not switch another target silently.
2. Complete any required build/refresh first through `cmsis_action build` for
this workspace/target, or the documented `cbuild` command. Require the current
`out/TraceDemo/EK-RA8P1/Debug/TraceDemo.elf` and generated
`out/Trace+EK-RA8P1.cbuild-run.yml`. Check the template's pack/image paths and
resources against that output; report unexpected drift before replacing it.
3. Inspect `.cmsis/Trace+EK-RA8P1@ULINKplus.ctrace.yml` before editing the run
description. Preserve CPU0 source choices, including custom watches/channels.
The normal demo uses `g_trace_sine`, `g_trace_noise`, ITM1, PC samples,
8 MHz timestamps and DWT synchronization. Stop on an active CPU1 setup or an
incompatible timestamp clock. Plan to remove only disabled CPU1 placeholders:
pyTS can otherwise emit CPU1 disable register accesses.
If a matching `~` preview profile could redirect generation, report the
conflict and stop without changing either profile. Do not replace user
settings with defaults.

## Prepare and validate

1. Apply the preflighted profile changes: back up before removing disabled CPU1
placeholders, and preserve every CPU0 setting. If no placeholders exist,
leave the profile unchanged. Back up the generated run description outside
the pack and build inputs.
Apply the versioned [debug template](../../../Board/EK-RA8P1/debug-run.yml)
with the agent's file tools only if its contents differ. The equivalent
POSIX command from the repository root is:

```sh
cmake -E copy_if_different Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml
cp Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml
```

4. Generate the trace runtime from that run description and current ELF using
the installed CMSIS Debugger's pyTS. Resolve its executable from the installed
extension or the host's tool configuration; never hardcode a host path or
install a separate Python package. Quote the resolved executable path:
This replaces a generated description, not a pack file. Preserve the vendor
pack; this skill does not patch a PDSC. Do not add interpreter helpers,
CMake/Make preparation steps or automatic build hooks.
2. Generate the trace runtime with the installed CMSIS Debugger's bundled pyTS.
Resolve its executable from the extension or tools configuration; quote it,
and do not install a separate package or hardcode a host-specific path:

```sh
"$trace_pyts" out/Trace+EK-RA8P1.cbuild-run.yml --format json
```

The normal **Trace Generation → Convert *.ctrace.yml to *.ctrace-run.yml**
command is equivalent. If neither route is available, report the missing
trace tool and stop before claiming preparation succeeded.
5. Check the generated
`.trace/Trace+EK-RA8P1@ULINKplus.ctrace-run.yml` against the selected source
profile and current ELF: resolve enabled watches without missing symbols,
retain the requested ITM/PC/timestamp/sync sources, and require CPU0-only
register operations. Disabled CPU1 metadata alone is not a register access.
The standard demo enables `g_trace_sine`, `g_trace_noise`, ITM1, PC samples,
8 MHz timestamps and DWT synchronization. Require SWO `mode: file` at 1 Mbaud.

Report the prepared target, ELF/profile and generation result. Preparation
does not flash, reset, start/stop debugging or open a live trace TCP service.
For a separately requested hardware run, use the CMSIS tools and the normal
file capture → automatic CSV conversion on pause/end workflow.

A subsequent build, refresh or target change can replace the prepared run
description. Repeat the copy and trace generation after the last such operation
and before Enter Debug. Remove this skill and the template once the DFP/tool
flow supplies the required behavior natively and has been validated.
The UI **Convert *.ctrace.yml to *.ctrace-run.yml** command uses the same
generator with `--allow-missing`. For either route inspect errors and missing
symbols explicitly; a successful exit alone is insufficient.
3. Parse the run description through the installed pyOCD `TraceConfig` consumer
without creating a session/probe. Require one enabled SWO source in `file`
mode with 1000000 Hz input and 1000000 bit/s output, without ignored-source
warnings. `mode` and clocks are siblings of the null `swo-uart` key; nesting
them inside it passes basic YAML/pyTS checks but is ignored by pyOCD.
4. Inspect `.trace/Trace+EK-RA8P1@ULINKplus.ctrace-run.yml` against the selected
production profile and current ELF: resolve all enabled watches, preserve
requested ITM/PC/timestamp/sync sources, and require CPU0-only register
operations including `ctrace-disable`. Disabled CPU1 metadata does not make
CPU1 register accesses safe. Use the CMSIS structural validator when available;
its checks cover common structure rather than device behavior.
5. Re-read the files after extension watchers settle. A repeat without another
build or profile change must preserve the resulting configuration. Compare
before writing the template again and retain existing backups.

Report preparation and hardware reception separately. Do not flash, reset,
start/stop debugging or open a live trace TCP service. A separately requested
hardware run uses CMSIS tools and normal file capture → automatic CSV conversion
on pause/end. The sequence rejects a conflicting running trace clock before
register writes; end trace and reset the device before changing its clock mode.

Build, refresh or target changes can overwrite the generated description.
Repeat preparation after the last such operation and before Enter Debug. Remove
this skill and template once the native DFP/tool flow has been validated.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ jobs:
- name: Check explicit RA8P1 debug preparation
if: matrix.context == 'TraceDemo.Debug+EK-RA8P1'
run: |
cmake -E copy_if_different Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml
cp Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml
cmp Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml
16 changes: 13 additions & 3 deletions Board/EK-RA8P1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ cbuild Trace.csolution.yml --active 'EK-RA8P1@ULINKplus' --packs --frozen-packs
The firmware build has no custom preparation step. After the final build or
refresh, invoke `Use $prepare-ra8p1-trace` with an agent that can read this
repository's [skill](../../.agents/skills/prepare-ra8p1-trace/SKILL.md). It copies
the temporary [debug-run.yml](debug-run.yml) using the existing CMake executable
the temporary [debug-run.yml](debug-run.yml) using its file tools
and generates the normal trace runtime with the installed pyTS.

Without an agent, run the same copy from the repository root:

```sh
cmake -E copy_if_different Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml
cp Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml
```

Then generate the trace runtime from the current ELF through the normal **Trace
Expand All @@ -69,7 +69,10 @@ The unmodified DFP supplies no RA8P1 SWO sequences, processor/AP mapping or

- CPU0 on AP0, with CPU0-only processor resources and trace configuration.
- P209 SWO routing and the trace clock before CoreSight discovery and after reset.
PRCR access enables are preserved while setting TRCKCR to MOCO `/8`.
All PRCR access enables are preserved while setting TRCKCR to MOCO `/8`.
An already matching running trace clock is retained. A different running
source/divider is rejected before register writes; end trace and reset before
changing modes (Hardware Manual p.376).
- Legacy pyOCD ITM/TPIU setup; full trace setup is not enabled.
- The pinned DFP's programming algorithms and system descriptions, referenced
through `${CMSIS_PACK_ROOT}`. Solution and ELF paths are relative to `out/`.
Expand All @@ -81,6 +84,13 @@ remove the template and preparation skill together and verify the generated
description.
Installed packs and the reference project remain unchanged.

Preparation checks the production source profile before changing runtime files.
Active CPU1 settings and conflicting `~` preview profiles stop preparation;
disabled CPU1 placeholders require removal with a backup to prevent unwanted
CPU1 disable writes. Custom CPU0 sources remain intact. Both installed pyOCD
transport parsing and pyTS output must pass, including unresolved-symbol and
register-operation checks; successful conversion alone is insufficient.

SWD is 10 MHz. MOCO `/8` gives a **1 MHz trace input**, serialized at **1 Mbaud**;
CPU0 timestamps use **8 MHz**. The profile watches `g_trace_sine` and
`g_trace_noise`, enables ITM1, samples the PC every 8192 core cycles and requests
Expand Down
19 changes: 12 additions & 7 deletions Board/EK-RA8P1/debug-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,23 @@ cbuild-run:
blocks:
- execute: |
__var saved_ap = __ap;
__Result = 0;
__ap = 0;
Write32(0x4001B030, 0x00000009); // TRPORTCR: CPU0 SWO on P209.
__var trace_clock = Read8(0x4001E03F);
- if: trace_clock != 0x83
- if: "(trace_clock & 0x80) != 0 && (trace_clock & 0x1F) != 0x03"
execute: |
__ap = saved_ap;
__Result = -1;
Message(2, "RA8P1 TRCLK is running with a different source/divider; end trace and reset before changing it");
- if: __Result == 0
blocks:
- execute: |
__var saved_prcr = Read16(0x4001E3FA) & 0x000F;
Write16(0x4001E3FA, 0xA501 | saved_prcr);
- if: "(trace_clock & 0x80) != 0"
Write32(0x4001B030, 0x00000009); // TRPORTCR: CPU0 SWO on P209.
- if: "(trace_clock & 0x80) == 0"
execute: |
Write8(0x4001E03F, trace_clock & 0x7F);
- execute: |
// Preserve PRC0, PRC1, PRC3, PRC4 and PRC5 (Hardware Manual pp.525-526).
__var saved_prcr = Read16(0x4001E3FA) & 0x003B;
Write16(0x4001E3FA, 0xA501 | saved_prcr);
Write8(0x4001E03F, 0x03); // TRCK=/8 while stopped.
Write8(0x4001E03F, 0x83); // 8 MHz MOCO /8 = 1 MHz trace input.
Write16(0x4001E3FA, 0xA500 | saved_prcr);
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Capture-start and pause/end recording issues remain; see [Validation](docs/VALID
EK-RA8P1: after build/refresh, run `Use $prepare-ra8p1-trace`
([skill](.agents/skills/prepare-ra8p1-trace/SKILL.md)) or follow the
[shell procedure](Board/EK-RA8P1/README.md#debug-and-trace-preparation).
This temporary RA_DFP 6.6.0 workaround uses CMake and bundled pyTS without a build
This temporary RA_DFP 6.6.0 workaround uses a file copy and bundled pyTS without a build
hook or extra interpreter. SWO uses the standard automatic CSV workflow.

Hardware results and open capture issues are listed in
Expand Down
2 changes: 1 addition & 1 deletion docs/BOARD_SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ linker template. The Cortex-M33 CPU1 is not an application target.

The original `Renesas::RA_DFP@6.6.0` remains unmodified. A documented local
CPU0-only debug description supplies the missing CPU0/AP0 and SWO setup. The
explicit preparation skill or documented CMake command copies it after build/refresh;
explicit preparation skill or documented file-copy command copies it after build/refresh;
standard pyTS generates trace settings from the current ELF. No `.dbgconf`
defaults exist for this device in that DFP.
The board README records Debug In jumpers, separate power, security prerequisites,
Expand Down
4 changes: 2 additions & 2 deletions docs/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ build has no custom preparation step. After the final build/refresh, invoke
versioned CPU0-only debug description explicitly:

```sh
cmake -E copy_if_different Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml
cp Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml
```

Generate the trace runtime from the current ELF with the normal Trace Generation
Expand All @@ -146,4 +146,4 @@ to CSV on pause/end. This needs no additional interpreter or CMSIS tools export.

The [board README](../Board/EK-RA8P1/README.md) explains the temporary DFP 6.6.0
workaround, clock baseline and hardware prerequisites. CI builds the firmware and
checks the explicit CMake copy separately; it does not require an AI agent.
checks the explicit file copy separately; it does not require an AI agent.
2 changes: 1 addition & 1 deletion docs/DEBUG_PROBES.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ see the [file naming table](TRACE_APP.md#configuration-ownership).
Use `EK-RA8P1@ULINKplus`, 10 MHz SWD, GDB port 3333 and 1 Mbaud SWO.
After the final build/refresh, apply the versioned CPU0/AP0 description with the
[preparation skill](../.agents/skills/prepare-ra8p1-trace/SKILL.md) or the explicit
CMake command in the [board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation).
file-copy command in the [board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation).
Generate trace through the normal Trace Generation view or bundled pyTS before
Enter Debug. SWO uses file capture with automatic RAW-to-CSV conversion on
pause/end and no live trace TCP service.
Expand Down
2 changes: 1 addition & 1 deletion docs/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ and would not generate the call to `app_main()`.
EK-RA8P1 reuses the supplied Renesas RTOSDemo project's CMSIS-based CPU0
startup/header, while retaining this project's 8 MHz reset-clock baseline. Its
DFP lacks CPU0/AP0 and SWO setup; the versioned CPU0 debug description and a
preparation skill with an explicit CMake command apply the run-description
preparation skill with an explicit file-copy command apply the run-description
override workflow without changing installed Packs or adding an interpreter
dependency. See the [board layer](../Board/EK-RA8P1/README.md).

Expand Down
11 changes: 10 additions & 1 deletion docs/TRACE_APP.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,21 @@ Their development status and source/release links are recorded there.

For EK-RA8P1, apply the versioned CPU0 debug description after the final
build/refresh using the [preparation skill](../.agents/skills/prepare-ra8p1-trace/SKILL.md)
or CMake command in the [board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation).
or file-copy command in the [board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation).
Trace generation then uses this description and the current ELF through the same
view or pyTS command as the other targets. Repeat preparation after a subsequent
build, refresh or target change.
Capture uses the normal SWO file and automatic CSV workflow.

For this target, preflight the production profile before changing generated
files. Resolve preview-profile conflicts and active CPU1 settings first;
remove only disabled CPU1 placeholders with a backup. Require the installed
pyOCD transport parser to accept the SWO file source and inspect pyTS errors,
missing symbols and all register groups, including source-disable groups.
The UI converter uses `--allow-missing`, so its exit status alone is insufficient.
After extension watchers settle, re-read the output; repeated preparation
without input changes must preserve the configuration.

Equivalent offline generation with the bundled pyTS executable, for example:

```sh
Expand Down
25 changes: 25 additions & 0 deletions docs/VALIDATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,28 @@ local documentation links and diff checks passed. The common CProject now
matches `main`. The current debug session could not read the core and its server
previously reported `No such device`; no new hardware capture is claimed for
this preparation change.

## EK-RA8P1 preparation corrections — 2026-11-18

The debug template now preserves all PRCR permissions (`0x003B`) and rejects a
conflicting running trace-clock source/divider before register writes. Matching
running clocks remain untouched. The skill preflights source/preview conflicts,
checks installed-consumer acceptance and all generated register groups, and
preserves custom CPU0 settings. Preparation uses a file copy without a custom
helper or build hook; vendor pack contents remain unchanged.

**Offline PASS:** 337 host checks with the installed pyOCD YAML parser and
sequence interpreter cover both entry sequences, SWO disabled, stopped clocks,
all 32 PRCR permission combinations, matching and conflicting running clocks,
AP restoration and both throwing and log-only errors. No probe transport was
created. The installed trace consumer accepts file mode at 1 MHz/1 Mbaud.

Bundled pyTS generated all six CPU0 references from the tracked production
profile and existing GCC ELF, resolving both DWT symbols without errors or CPU1
accesses. A missing-symbol negative case was detected, including with
`--allow-missing`; normal regeneration restored identical run/profile/runtime/ELF
hashes. Skill, common YAML structure, documentation links and diff checks pass.

Firmware sources did not change; no new hardware capture is claimed. The
November 17 hardware results above predate these sequence changes, and capture
integrity plus hardware acceptance of the revised sequences remain open.