From 8f8048f091522e892f05b369bbbdfbae39d5de08 Mon Sep 17 00:00:00 2001 From: Thorsten de Buhr Date: Tue, 17 Nov 2026 11:37:03 +0100 Subject: [PATCH 1/5] Update tool requirements and L552 probe selection --- Trace.csolution.yml | 4 ++-- vcpkg-configuration.json | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Trace.csolution.yml b/Trace.csolution.yml index 581ed65..8bacfa7 100644 --- a/Trace.csolution.yml +++ b/Trace.csolution.yml @@ -1,7 +1,7 @@ # Build inputs; cbuild generates *.cbuild*.yml and the debugger run description. solution: created-for: CMSIS-Toolbox@2.15.0 - compiler: GCC@14.3.1 + compiler: GCC cdefault: packs: @@ -47,7 +47,7 @@ solution: images: - project-context: TraceDemo.Debug debugger: - name: ULINKplus@pyOCD + name: ULINKpro@pyOCD protocol: swd clock: 10000000 trace: diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 1c63254..311864d 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -7,9 +7,9 @@ } ], "requires": { - "arm:tools/open-cmsis-pack/cmsis-toolbox": "2.15.0", - "arm:compilers/arm/arm-none-eabi-gcc": "14.3.1", - "arm:tools/kitware/cmake": "3.31.5", - "arm:tools/ninja-build/ninja": "1.13.2" + "arm:tools/open-cmsis-pack/cmsis-toolbox": "*", + "arm:compilers/arm/arm-none-eabi-gcc": "*", + "arm:tools/kitware/cmake": "*", + "arm:tools/ninja-build/ninja": "*" } } From 17822669387c919e4650e0860f9d981916303bee Mon Sep 17 00:00:00 2001 From: Thorsten de Buhr Date: Tue, 17 Nov 2026 11:37:03 +0100 Subject: [PATCH 2/5] Add EK-RA8P1 CPU0 board and automatic SWO CSV workflow --- .cmsis/Trace+EK-RA8P1@ULINKplus.ctrace.yml | 25 ++++ .github/workflows/build.yml | 1 + Board/EK-RA8P1/Board.clayer.yml | 28 +++++ Board/EK-RA8P1/README.md | 113 ++++++++++++++++++ Board/EK-RA8P1/main.c | 12 ++ Board/EK-RA8P1/prepare_trace.rb | 123 ++++++++++++++++++++ Board/EK-RA8P1/regions.h | 15 +++ Board/EK-RA8P1/target.c | 36 ++++++ Board/EK-RA8P1/trace-override.yml | 49 ++++++++ Projects/TraceDemo/TraceDemo.cproject.yml | 9 ++ README.md | 11 +- ThirdParty/README.md | 18 +++ ThirdParty/Renesas/ek-ra8p1/ra8p1.h | 71 +++++++++++ ThirdParty/Renesas/ek-ra8p1/startup_ra8p1.c | 88 ++++++++++++++ ThirdParty/Renesas/ek-ra8p1/system_ra8p1.c | 36 ++++++ ThirdParty/Renesas/ek-ra8p1/system_ra8p1.h | 40 +++++++ ThirdParty/Renesas/sources.json | 35 ++++++ Trace.cbuild-pack.yml | 3 + Trace.csolution.yml | 25 ++++ docs/BOARD_SUPPORT.md | 21 +++- docs/BUILD.md | 30 ++++- docs/DEBUG_PROBES.md | 18 +++ docs/DESIGN.md | 14 ++- docs/TRACE_APP.md | 5 + docs/VALIDATION.md | 56 +++++++++ 25 files changed, 865 insertions(+), 17 deletions(-) create mode 100644 .cmsis/Trace+EK-RA8P1@ULINKplus.ctrace.yml create mode 100644 Board/EK-RA8P1/Board.clayer.yml create mode 100644 Board/EK-RA8P1/README.md create mode 100644 Board/EK-RA8P1/main.c create mode 100644 Board/EK-RA8P1/prepare_trace.rb create mode 100644 Board/EK-RA8P1/regions.h create mode 100644 Board/EK-RA8P1/target.c create mode 100644 Board/EK-RA8P1/trace-override.yml create mode 100644 ThirdParty/Renesas/ek-ra8p1/ra8p1.h create mode 100644 ThirdParty/Renesas/ek-ra8p1/startup_ra8p1.c create mode 100644 ThirdParty/Renesas/ek-ra8p1/system_ra8p1.c create mode 100644 ThirdParty/Renesas/ek-ra8p1/system_ra8p1.h create mode 100644 ThirdParty/Renesas/sources.json diff --git a/.cmsis/Trace+EK-RA8P1@ULINKplus.ctrace.yml b/.cmsis/Trace+EK-RA8P1@ULINKplus.ctrace.yml new file mode 100644 index 0000000..81ff898 --- /dev/null +++ b/.cmsis/Trace+EK-RA8P1@ULINKplus.ctrace.yml @@ -0,0 +1,25 @@ +--- +ctrace: + setup: + - pname: CPU0 + core: Cortex-M85 + timestamps: + clock: 8000000 + itm-prescaler: 1 + data: + - location: g_trace_sine + label: Sine + access: W + size: 4 + output: value + - location: g_trace_noise + label: Noise + access: W + size: 4 + output: value + itm: + enable: 2 + pcsampling: + period: 8192 + synchronization: + DWT: 16M diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 77270a3..d2add59 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,6 +30,7 @@ jobs: - TraceDemo.Debug+STM32F4-DISCO - TraceDemo.Debug+STM32F429I-DISCO - TraceDemo.Debug+STM32H7B3I-DK + - TraceDemo.Debug+EK-RA8P1 steps: - name: Checkout diff --git a/Board/EK-RA8P1/Board.clayer.yml b/Board/EK-RA8P1/Board.clayer.yml new file mode 100644 index 0000000..b7e10c7 --- /dev/null +++ b/Board/EK-RA8P1/Board.clayer.yml @@ -0,0 +1,28 @@ +layer: + type: Board + description: EK-RA8P1 CPU0 with internal MRAM/SRAM0 and the 8 MHz MOCO reset clock + for-device: Renesas::R7KA8P1KF:CPU0 + + packs: + - pack: Renesas::RA_DFP@6.6.0 + + define: + - CMSIS_device_header: '"ra8p1.h"' + + add-path: + - ../../ThirdParty/Renesas/ek-ra8p1 + + groups: + - group: Board + files: + - file: main.c + - file: target.c + - group: CMSIS Device + files: + - file: ../../ThirdParty/Renesas/ek-ra8p1/startup_ra8p1.c + - file: ../../ThirdParty/Renesas/ek-ra8p1/system_ra8p1.c + + linker: + - script: ../Support/gcc_linker_script.ld.src + regions: regions.h + for-compiler: GCC diff --git a/Board/EK-RA8P1/README.md b/Board/EK-RA8P1/README.md new file mode 100644 index 0000000..4bc0829 --- /dev/null +++ b/Board/EK-RA8P1/README.md @@ -0,0 +1,113 @@ +# Renesas EK-RA8P1 + +Target `EK-RA8P1`, debugger set `ULINKplus`, device +`Renesas::R7KA8P1KF:CPU0` (Cortex-M85). The board is fitted with +`R7KA8P1KFLCAC`; CPU1, the Cortex-M33, is outside this target. + +## Firmware and dependencies + +The layer uses `Renesas::RA_DFP@6.6.0`, CMSIS-Core 6.3.0 and RTX5 5.9.0. +Startup, core header and `SystemInit()` are adapted from the supplied +`Renesas_EK-RA8P1/RTOSDemo.csolution.yml` project, originally based on +`ARM::Cortex_DFP@1.1.0`. [The source manifest](../../ThirdParty/Renesas/sources.json) +records provenance, source hashes and local changes. The DFP's FSP-dependent +startup is not selected. No FSP generator, BSP or full SDK is required. + +The image uses 1 MiB code MRAM at `0x02000000` and 512 KiB SRAM0 at +`0x22000000`, with a 4 KiB main stack and no C-library heap. TCM and external +memory are unused. The 112-entry `.vectors` table is aligned to 512 bytes. +The shared GCC linker template retains it at the MRAM origin and provides +`__StackTop`/`__StackLimit` and the CMSIS C-runtime copy table; newlib startup +clears `.bss`. RTX supplies SVC, PendSV and SysTick handlers. + +CPU0 retains the **8 MHz MOCO reset clock**, with its divider at one. +`target_init()` checks the source, divider and oscillator state and stops +before RTX if that clock is not recognized (`SystemCoreClock == 0`). Start +from a device reset. The reference project's 1-GHz PLL/voltage/cache setup +is intentionally not imported: the reset-clock baseline also leaves adequate +SWO bandwidth for periodic PC sampling. The common RTX idle thread spins. + +`trustzone: off`, FPU/MVE off and branch protection off are compiler settings. +They do not provision device security. The MRAM/SRAM and system/debug registers +must already be accessible to CPU0 and the external debugger. This project +changes no lifecycle, OTP, option or security configuration. + +## Debug and trace preparation + +Select **EK-RA8P1 → ULINKplus** in CMSIS Manage Solution Settings and build: + +```sh +cbuild Trace.csolution.yml --active 'EK-RA8P1@ULINKplus' --packs --frozen-packs --update-rte +``` + +The normal solution build automatically runs `PrepareRA8P1Trace` after linking, +including an otherwise up-to-date build. The step locates the installed CMSIS +Debugger's pyTS through `.cmsis/tools-environment.yml`, applies the CPU0 override +and regenerates the current-ELF trace configuration. Ruby with its standard YAML +library is required for this target. **Enter Debug / Load & Debug** then uses the +prepared run description and GDB port 3333. + +After a standalone refresh, manual trace conversion or a build with `--context` +(which skips CMSIS Toolbox `executes` steps), prepare the run description with +`ruby Board/EK-RA8P1/prepare_trace.rb`. An optional executable-path argument +selects pyTS when the CMSIS tools environment is unavailable. + +Trace uses the normal **file capture → automatic CSV conversion** workflow. +There is no live trace TCP service. Pausing or ending debugging converts the +RAW file to `.trace/Trace+EK-RA8P1@ULINKplus.SWO.csv`; the GDB TCP connection is +only for debugging. + +The unmodified DFP supplies no RA8P1 SWO sequences, processor/AP mapping or +`.dbgconf` defaults. [trace-override.yml](trace-override.yml) and +[prepare_trace.rb](prepare_trace.rb) implement the project's +[temporary run-description override workflow](../../docs/TRACE_APP.md#temporary-run-description-overrides): + +- Map CPU0 to AP0 and limit this generated run to the selected CPU0 image. +- Enable P209 SWO output and the trace clock before CoreSight discovery and + after reset. Preserve PRCR access enables while setting TRCKCR to `/8`. +- Retain legacy pyOCD ITM/TPIU setup. Full trace setup is not enabled. +- Generate the runtime profile from the current ELF and omit only inactive + CPU1 disable writes. The supplied reference project reports CPU1/AP2 `WAIT ACK`; + no CPU1 workload or enabled trace source is removed. + +The debugger uses the prepared `out/Trace+EK-RA8P1.cbuild-run.yml`, and trace +uses `.trace/Trace+EK-RA8P1@ULINKplus.ctrace-run.yml`. The filenames and relative +paths stay unchanged. Builds regenerate the run description and then reapply the override; installed +packs and the reference project stay unchanged. A standalone CMSIS refresh +regenerates the vendor-only run description until the next solution build. + +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 +DWT synchronization every 16M cycles. RA8P1 CPU0 implements eight DWT comparators, +ITM and a dedicated SWO TPIU. pyTS allocates the watch comparators. + +## Power and Debug In wiring + +The board manual Rev. 1.04, section 5.2.2 (PDF p. 27), specifies: + +| Setting | Debug In position | +| --- | --- | +| J6 | 2–3 | +| J8 | 1–2 | +| J9 | 1–2; holds the onboard debug MCU in reset | +| J29 | All four shunts: 1–2, 3–4, 5–6, 7–8 | +| External debugger | J13 (10-pin) or J20 (20-pin), correct pin-1 orientation | + +P209/SWO is pin 6 on J13/J20. Supply board power separately through J10, J11 +or J7 as described in section 5.1; VTref is a voltage reference. Change jumpers +with power disconnected. Confirm the physical board revision and probe locally +before loading. The solution retains automatic probe selection. + +## References and validation + +- [EK-RA8P1 v1 User's Manual](https://www.renesas.com/en/document/mat/ek-ra8p1-v1-users-manual), Rev. 1.04: power and Debug In, PDF pp. 23–28. +- [RA8P1 hardware manual](https://www.renesas.com/en/document/mah/ra8p1-group-users-manual-hardware), Rev. 1.30: CPU0 features pp. 115–116; debug/trace pp. 134–145; MRAM map pp. 238–239; clock registers pp. 330, 332, 343, 375–376; SRAM0 pp. 3537–3543. +- [Cortex-M85 TRM](https://developer.arm.com/documentation/101924/latest): DWT, ITM and TPIU. + +Build, Load & Debug to `main`, RTX runtime at 8 MHz and automatic CSV creation +on pause passed on 2026-11-17 through ULINKplus. The capture contains both DWT +sources, ITM1 and PC samples. Capture integrity remains open: one invalid ITM +packet near startup and one incomplete packet at pause/EOF were reported. +The supplied reference project's 1-GHz ITM0 results do not validate this image. +See the single [validation record](../../docs/VALIDATION.md). diff --git a/Board/EK-RA8P1/main.c b/Board/EK-RA8P1/main.c new file mode 100644 index 0000000..d3b2601 --- /dev/null +++ b/Board/EK-RA8P1/main.c @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +#include "app.h" +#include "target.h" + +int main(void) +{ + target_init(); + (void)app_main(); + for (;;) { + /* app_main returns only when RTX5 startup fails. */ + } +} diff --git a/Board/EK-RA8P1/prepare_trace.rb b/Board/EK-RA8P1/prepare_trace.rb new file mode 100644 index 0000000..38c64fd --- /dev/null +++ b/Board/EK-RA8P1/prepare_trace.rb @@ -0,0 +1,123 @@ +# SPDX-License-Identifier: Apache-2.0 +# Apply the documented CPU0-only override to the generated run description. +# Ruby's standard YAML library is the only dependency; no board access occurs. +require 'yaml' + +root = File.expand_path('../..', __dir__) +path = File.join(root, 'out/Trace+EK-RA8P1.cbuild-run.yml') +abort 'Usage: ruby Board/EK-RA8P1/prepare_trace.rb [path/to/pyTS]' if ARGV.length > 1 +if ARGV.empty? + environment_path = File.join(root, '.cmsis/tools-environment.yml') + abort 'Missing .cmsis/tools-environment.yml; refresh CMSIS Solution first' unless File.file?(environment_path) + environment = YAML.safe_load(File.read(environment_path)).fetch('cmsis-tools-environment') + debugger = environment.fetch('tools').find { |tool| tool['name'] == 'pyOCD' } + abort 'CMSIS Debugger pyOCD tool not found in the selected environment' unless debugger + directory = File.expand_path('../pyts', debugger.fetch('directory')) + candidates = %w[pyTS pyTS.exe].map { |name| File.join(directory, name) } + pyts = candidates.find { |candidate| File.file?(candidate) && File.executable?(candidate) } + abort 'Bundled pyTS not found; pass its executable path explicitly' unless pyts +else + pyts = File.expand_path(ARGV[0]) +end +abort 'pyTS executable not found' unless File.file?(pyts) && File.executable?(pyts) + +def require_value(condition, message) + abort "RA8P1 trace setup: #{message}" unless condition +end + +# Retain csolution's indentation for image entries. Some build-artifact +# consumers scan these entries line by line instead of parsing the YAML. +def write_yaml(path, document) + # Use literal blocks for sequence code. Psych otherwise emits some + # multiline strings as single quotes ending at column zero, which the + # CMSIS Solution YAML reader rejects. + syntax = Psych.parse_stream(YAML.dump(document)) + literal_strings = lambda do |node| + if node.is_a?(Psych::Nodes::Scalar) && node.value.include?("\n") + node.style = Psych::Nodes::Scalar::LITERAL + end + Array(node.children).each { |child| literal_strings.call(child) } + end + literal_strings.call(syntax) + text = syntax.yaml + if document.key?('cbuild-run') + text.sub!(/(^ output:\n)(.*?)(?=^ [a-z])/m) do + Regexp.last_match(1) + Regexp.last_match(2).lines.map { |line| ' ' + line }.join + end + end + require_value(YAML.safe_load(text) == document, 'YAML round-trip mismatch') + temporary = "#{path}.ra8p1-tmp" + File.write(temporary, text) + File.rename(temporary, path) +end + +begin + document = YAML.safe_load(File.read(path)) + run = document.fetch('cbuild-run') + expected = { + 'target-type' => 'EK-RA8P1', 'target-set' => 'ULINKplus', + 'device' => 'Renesas::R7KA8P1KF', 'device-pack' => 'Renesas::RA_DFP@6.6.0' + } + expected.each { |key, value| require_value(run[key] == value, "unexpected #{key}; rebuild EK-RA8P1@ULINKplus") } + require_value(run.fetch('output').all? { |image| image['pname'] == 'CPU0' }, 'expected CPU0 images only') + debugger = run.fetch('debugger') + require_value(debugger['name'] == 'ULINKplus@pyOCD', 'unexpected debugger') + swo = debugger.fetch('trace').fetch(0) + require_value(swo.key?('swo-uart') && swo['input-clock'] == 1_000_000 && swo['output-clock'] == 1_000_000, + 'expected 1 MHz trace input and 1 Mbaud SWO') + + override = YAML.safe_load(File.read(File.join(__dir__, 'trace-override.yml'))) + sequences = run['debug-sequences'] + require_value(sequences.nil? || sequences == override['debug-sequences'], + 'unexpected debug sequences; review instead of overwriting them') + require_value(!run.key?('debug-sequences-conf'), 'expected legacy trace setup') + topology = run.fetch('debug-topology') + require_value(topology == { 'trace-sinks' => [{ 'serialwire' => nil }, { 'tracebuffer' => nil }] } || + topology == override['debug-topology'], 'unexpected debug topology') + + resources = run.fetch('system-resources') + processors = resources.fetch('processors') + require_value(processors.map { |p| p['pname'] }.sort == %w[CPU0 CPU1] || + processors.map { |p| p['pname'] } == ['CPU0'], 'unexpected processors') + # This run describes the selected CPU0 image. CPU1/AP2 is not available in + # the reference setup; pyTS must not emit disable writes for that processor. + resources['processors'] = processors.select { |p| p['pname'] == 'CPU0' } + resources['memory'].reject! { |m| m['pname'] == 'CPU1' } + debugger['gdbserver'] = debugger.fetch('gdbserver').select { |server| [nil, 'CPU0'].include?(server['pname']) } + debugger['gdbserver'].each { |server| server['pname'] = 'CPU0' } + override.each { |key, value| run[key] = value } + + # Keep the filename and directory so relative ELF/profile paths stay valid. + # Atomic replacement also avoids leaving a partial run description on failure. + write_yaml(path, document) + + source_path = File.join(root, '.cmsis/Trace+EK-RA8P1@ULINKplus.ctrace.yml') + source = YAML.safe_load(File.read(source_path)) + setup = source.fetch('ctrace').fetch('setup') + require_value(setup.select { |entry| entry['pname'] == 'CPU1' }.all? { |entry| entry.key?('disable') }, + 'refusing to remove an enabled CPU1 source profile') + if setup.any? { |entry| entry['pname'] == 'CPU1' } + setup.reject! { |entry| entry['pname'] == 'CPU1' } + write_yaml(source_path, source) + end + abort 'pyTS generation failed' unless system(pyts, path, '--format', 'json') + + runtime_path = File.join(root, '.trace/Trace+EK-RA8P1@ULINKplus.ctrace-run.yml') + runtime = YAML.safe_load(File.read(runtime_path)) + trace = runtime.fetch('ctrace-run') + cpu1 = trace.fetch('ctrace-setup').select { |entry| entry['pname'] == 'CPU1' } + require_value(cpu1.all? { |entry| entry.key?('disable') }, 'refusing to remove an enabled CPU1 source') + require_value(trace.fetch('ctrace-refs').all? { |entry| [nil, 'CPU0'].include?(entry['pname']) && entry.fetch('ref').start_with?('CPU0/') }, + 'expected CPU0 trace sources only') + # Older generated source profiles may retain inactive CPU1 settings. + # Omit only disable accesses; enabled CPU1 sources were rejected above. + %w[ctrace-setup ctrace-disable].each do |key| + trace.fetch(key).reject! { |entry| entry['pname'] == 'CPU1' } + end + require_value(trace.fetch('ctrace-setup').map { |entry| entry['pname'] } == ['CPU0'], + 'unexpected trace processors') + write_yaml(runtime_path, runtime) + puts 'Prepared CPU0/AP0 SWO and generated the trace runtime without CPU1 accesses.' +rescue KeyError, TypeError, NoMethodError, Psych::Exception, SystemCallError => error + abort "RA8P1 trace setup: #{error.message}" +end diff --git a/Board/EK-RA8P1/regions.h b/Board/EK-RA8P1/regions.h new file mode 100644 index 0000000..f4c8d02 --- /dev/null +++ b/Board/EK-RA8P1/regions.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +#ifndef EK_RA8P1_REGIONS_H +#define EK_RA8P1_REGIONS_H + +/* RA8P1 hardware manual Rev. 1.30, pp. 238-239 and 3537-3543. + * CPU0 code MRAM and SRAM0 only; no TCM or external memory. + */ +#define __ROM0_BASE 0x02000000 +#define __ROM0_SIZE 0x00100000 +#define __RAM0_BASE 0x22000000 +#define __RAM0_SIZE 0x00080000 +#define __STACK_SIZE 0x00001000 +#define __HEAP_SIZE 0x00000000 + +#endif diff --git a/Board/EK-RA8P1/target.c b/Board/EK-RA8P1/target.c new file mode 100644 index 0000000..b2404be --- /dev/null +++ b/Board/EK-RA8P1/target.c @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +#include CMSIS_device_header +#include "target.h" + +/* RA8P1 hardware manual Rev. 1.30: SCKSCR (p. 332), SCKDIVCR2 + * (p. 330), MOCOCR (p. 343). Recognize the reset CPU0 clock only. + */ +#define SCKSCR (*(volatile const uint8_t *)0x4001E026UL) +#define SCKDIVCR2 (*(volatile const uint16_t *)0x4001E024UL) +#define MOCOCR (*(volatile const uint8_t *)0x4001E038UL) +#define MOCO_HZ 8000000U + +uint32_t SystemCoreClock = MOCO_HZ; + +void SystemCoreClockUpdate(void) +{ + const uint32_t source = SCKSCR & 7U; + const uint32_t divider = SCKDIVCR2 & 15U; + SystemCoreClock = (source == 1U && divider == 0U && (MOCOCR & 1U) == 0U) + ? MOCO_HZ : 0U; +} + +void target_init(void) +{ + SystemCoreClockUpdate(); + if (SystemCoreClock == 0U) { + for (;;) { + /* Reset the device; inherited clock configurations are unsupported. */ + } + } +} + +uint32_t target_core_clock_hz(void) +{ + return SystemCoreClock; +} diff --git a/Board/EK-RA8P1/trace-override.yml b/Board/EK-RA8P1/trace-override.yml new file mode 100644 index 0000000..81d3e23 --- /dev/null +++ b/Board/EK-RA8P1/trace-override.yml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: Apache-2.0 +# CPU0-only SWO adaptation of Renesas_EK-RA8P1's legacy-ra8p1-swo-device.xml. +# RA8P1 hardware manual Rev. 1.30, pp. 144-145, 375-376, 524-526. +# Keep legacy pyOCD ITM/TPIU setup; trace-setup: full would bypass it. +debug-topology: + debugports: + - dpid: 0 + accessports: + - apid: 0 + index: 0 + processors: + - pname: CPU0 + apid: 0 + trace-sinks: + - serialwire: +debug-sequences: + - name: SetupRA8P1SWO + blocks: + - execute: | + __var saved_ap = __ap; + __ap = 0; + Write32(0x4001B030, 0x00000009); // TRPORTCR: CPU0 SWO on P209. + __var trace_clock = Read8(0x4001E03F); + - if: trace_clock != 0x83 + blocks: + - execute: | + __var saved_prcr = Read16(0x4001E3FA) & 0x000F; + Write16(0x4001E3FA, 0xA501 | saved_prcr); + - if: (trace_clock & 0x80) != 0 + execute: | + Write8(0x4001E03F, trace_clock & 0x7F); + - execute: | + Write8(0x4001E03F, 0x03); // TRCK=/8 while stopped. + Write8(0x4001E03F, 0x83); // 8 MHz MOCO /8 = 1 MHz trace input. + Write16(0x4001E3FA, 0xA500 | saved_prcr); + - execute: | + __ap = saved_ap; + - name: DebugDeviceUnlock + blocks: + - if: (__traceout & 1) != 0 + execute: | + // Enable the clock before CoreSight discovers the CPU0 TPIU. + Sequence("SetupRA8P1SWO"); + - name: TraceStart + blocks: + - if: (__traceout & 1) != 0 + execute: | + // Restore routing after reset, before generic ITM/TPIU setup. + Sequence("SetupRA8P1SWO"); diff --git a/Projects/TraceDemo/TraceDemo.cproject.yml b/Projects/TraceDemo/TraceDemo.cproject.yml index 8563561..d8d66af 100644 --- a/Projects/TraceDemo/TraceDemo.cproject.yml +++ b/Projects/TraceDemo/TraceDemo.cproject.yml @@ -37,6 +37,15 @@ project: - file: ../../Common/Trace/itm_output.c - file: ../../Common/Include/trace.h + executes: + - execute: PrepareRA8P1Trace + for-context: .Debug+EK-RA8P1 + run: ruby "$input(1)$" + always: + input: + - $elf()$ + - $SolutionDir()$/Board/EK-RA8P1/prepare_trace.rb + layers: - layer: $Board-Layer$ type: Board diff --git a/README.md b/README.md index 6b2c7f6..79237e7 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ bring-up project or a reference example, and is currently not intended as a starting point for customer projects. A common firmware baseline for testing trace across Cortex-M boards and debug - probes. One **CMSIS solution** builds a shared **RTX5 application** through eight -local board layers, covering Cortex-M4, Cortex-M7 and Cortex-M33. + probes. One **CMSIS solution** builds a shared **RTX5 application** through ten +local board layers, covering Cortex-M4, Cortex-M7, Cortex-M33 and Cortex-M85. The workload updates sine and deterministic-noise variables every 100 ms for DWT and emits an ITM channel 1 counter every 200 ms. Debugger profiles add PC sampling @@ -33,6 +33,9 @@ Capture-start and pause/end recording issues remain; see [Validation](docs/VALID | [NUCLEO-F446RE](Board/NUCLEO-F446RE/README.md) | Cortex-M4 | `STLink` | | [STM32H7B3I-DK](Board/STM32H7B3I-DK/README.md) | Cortex-M7 | `ULINKplus` | | [STM32F4-DISCO](Board/STM32F4-DISCO/README.md), MB997 B-02 | Cortex-M4 | `ULINKplus`, `STLink` | +| [EK-RA8P1](Board/EK-RA8P1/README.md) | Cortex-M85 CPU0, TrustZone build off | `ULINKplus` | + +EK-RA8P1 applies its [CPU0 trace preparation](Board/EK-RA8P1/README.md#debug-and-trace-preparation) automatically during a solution build. Hardware results and open capture issues are listed in [Validation](docs/VALIDATION.md). This project currently implements SWO; @@ -97,8 +100,8 @@ If your agent does not discover repository skills, ask it to read the linked | File or directory | Purpose | | --- | --- | | `Trace.csolution.yml`, `Projects/TraceDemo/TraceDemo.cproject.yml` | Targets, debugger sets, common application and RTX5 components | -| `Common/`, `Board/` | Shared application and eight local board layers | -| `.cmsis/`, `Trace.cbuild-pack.yml`, `vcpkg-configuration.json` | Trace/debug profiles and pinned dependencies | +| `Common/`, `Board/` | Shared application and ten local board layers | +| `.cmsis/`, `Trace.cbuild-pack.yml`, `vcpkg-configuration.json` | Trace/debug profiles, Pack locks and tool requirements | | [DESIGN.md](docs/DESIGN.md) | Agreed requirements, architecture and how the baseline was assembled | | [BUILD.md](docs/BUILD.md), [DEBUG_PROBES.md](docs/DEBUG_PROBES.md) | Tool setup, builds and switching probes | | [TRACE_APP.md](docs/TRACE_APP.md) | Signal definitions, capture/CSV workflow and host-tool scope | diff --git a/ThirdParty/README.md b/ThirdParty/README.md index 2c33e2a..386586a 100644 --- a/ThirdParty/README.md +++ b/ThirdParty/README.md @@ -31,3 +31,21 @@ symbols used by ST GNU startup. That startup initializes only the primary CMSIS-Core and RTX5 are consumed from packs. CMSIS tools copy application configuration and DFP debugger defaults into `RTE/` and `.cmsis/`; their original notices remain intact. + +## Renesas EK-RA8P1 core support + +[Renesas/sources.json](Renesas/sources.json) records the startup, system source +and core headers imported from the supplied `Renesas_EK-RA8P1` project, with the +source revision, original byte hashes and retained-file hashes. They adapt +`ARM::Cortex_DFP@1.1.0` Cortex-M85 templates and retain their Apache-2.0 notices. +The local system header removes the reference project's 1-GHz clock API; that +clock implementation and its FSP dependency are not imported. Board clock +recognition is project code in `Board/EK-RA8P1/target.c`. + +The CMSIS C startup places `.vectors` at MRAM origin using the shared linker +script, initializes data through the CMSIS copy table and lets newlib initialize +BSS. The DFP's FSP-generated startup is not selected. Renesas::RA_DFP@6.6.0 +supplies device metadata, SVD and programming algorithms from the installed pack; +its contents are unchanged. The board-local trace override adapts the supplied +project's historical CPU0 SWO sequence, with the reset-clock frequency and +explicit AP preservation. See the [board documentation](../Board/EK-RA8P1/README.md). diff --git a/ThirdParty/Renesas/ek-ra8p1/ra8p1.h b/ThirdParty/Renesas/ek-ra8p1/ra8p1.h new file mode 100644 index 0000000..e84643a --- /dev/null +++ b/ThirdParty/Renesas/ek-ra8p1/ra8p1.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2022-2023 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Adapted from ARM::Cortex_DFP@1.1.0, Device/ARMCM85/Include/ARMCM85.h. + */ + +#ifndef RA8P1_H +#define RA8P1_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* RA8P1 Hardware Manual Rev. 1.30, Cortex-M85 processor, pp. 115-116: + * docs/renesas/ra8p1-group-users-manual-hardware.pdf. + * Peripheral interrupt routing is outside this core-only board layer. + */ +#define RA8P1_DEVICE_IRQ_COUNT 96U +#define RA8P1_VECTOR_COUNT (16U + RA8P1_DEVICE_IRQ_COUNT) + +typedef enum IRQn { + NonMaskableInt_IRQn = -14, + HardFault_IRQn = -13, + MemoryManagement_IRQn = -12, + BusFault_IRQn = -11, + UsageFault_IRQn = -10, + SecureFault_IRQn = -9, + SVCall_IRQn = -5, + DebugMonitor_IRQn = -4, + PendSV_IRQn = -2, + SysTick_IRQn = -1, + IRQ0_IRQn = 0, + IRQ95_IRQn = 95 +} IRQn_Type; + +#define __CM85_REV 0x0101U +#define __NVIC_PRIO_BITS 4U +#define __Vendor_SysTickConfig 0U +#define __VTOR_PRESENT 1U +#define __MPU_PRESENT 1U +#define __FPU_PRESENT 1U +#define __FPU_DP 1U +#define __DSP_PRESENT 1U +#define __SAUREGION_PRESENT 1U +#define __PMU_PRESENT 1U +#define __PMU_NUM_EVENTCNT 8U +#define __ICACHE_PRESENT 1U +#define __DCACHE_PRESENT 1U + +#include "core_cm85.h" +#include "system_ra8p1.h" + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Renesas/ek-ra8p1/startup_ra8p1.c b/ThirdParty/Renesas/ek-ra8p1/startup_ra8p1.c new file mode 100644 index 0000000..525dea9 --- /dev/null +++ b/ThirdParty/Renesas/ek-ra8p1/startup_ra8p1.c @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Adapted from ARM::Cortex_DFP@1.1.0, Device/ARMCM85/Source/startup_ARMCM85.c. + */ + +#include "ra8p1.h" + +extern uint32_t __INITIAL_SP; +extern uint32_t __STACK_LIMIT; +#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +extern uint32_t __STACK_SEAL; +#endif +extern __NO_RETURN void __PROGRAM_START(void); + +__NO_RETURN void Reset_Handler(void); +__NO_RETURN void Default_Handler(void); + +void NMI_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void HardFault_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void MemManage_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void BusFault_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void UsageFault_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void SecureFault_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void SVC_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void DebugMon_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void PendSV_Handler(void) __attribute__((weak, alias("Default_Handler"))); +void SysTick_Handler(void) __attribute__((weak, alias("Default_Handler"))); + +/* 16 core exceptions and 96 ICU interrupts require 512-byte VTOR alignment. + * See RA8P1 Hardware Manual Rev. 1.30, pp. 115-116. RTX provides the strong + * SVC, PendSV and SysTick handlers; unused peripheral slots trap here. + */ +extern const VECTOR_TABLE_Type __VECTOR_TABLE[RA8P1_VECTOR_COUNT]; +const VECTOR_TABLE_Type __VECTOR_TABLE[RA8P1_VECTOR_COUNT] + __VECTOR_TABLE_ATTRIBUTE __ALIGNED(512) = { + (VECTOR_TABLE_Type) (&__INITIAL_SP), + Reset_Handler, + NMI_Handler, + HardFault_Handler, + MemManage_Handler, + BusFault_Handler, + UsageFault_Handler, + SecureFault_Handler, + 0, + 0, + 0, + SVC_Handler, + DebugMon_Handler, + 0, + PendSV_Handler, + SysTick_Handler, + [16 ... RA8P1_VECTOR_COUNT - 1U] = Default_Handler +}; + +__NO_RETURN void Reset_Handler(void) +{ + __set_PSP((uint32_t) (uintptr_t) &__INITIAL_SP); + __set_MSPLIM((uint32_t) (uintptr_t) &__STACK_LIMIT); + __set_PSPLIM((uint32_t) (uintptr_t) &__STACK_LIMIT); + +#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + __TZ_set_STACKSEAL_S((uint32_t *) &__STACK_SEAL); +#endif + + SystemInit(); + __PROGRAM_START(); +} + +__NO_RETURN void Default_Handler(void) +{ + for (;;) { + } +} diff --git a/ThirdParty/Renesas/ek-ra8p1/system_ra8p1.c b/ThirdParty/Renesas/ek-ra8p1/system_ra8p1.c new file mode 100644 index 0000000..5054e6d --- /dev/null +++ b/ThirdParty/Renesas/ek-ra8p1/system_ra8p1.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Adapted from ARM::Cortex_DFP@1.1.0, Device/ARMCM85/Source/system_ARMCM85.c. + */ + +#include "ra8p1.h" + +extern const VECTOR_TABLE_Type __VECTOR_TABLE[RA8P1_VECTOR_COUNT]; + +void SystemInit(void) +{ + SCB->VTOR = (uint32_t) (uintptr_t) &__VECTOR_TABLE[0]; + + /* Cortex-M85 template setup for low-overhead loops and branch prediction. + * Instruction/data caches, SAU partitioning and vendor registers retain + * their reset settings. The project disables FPU, MVE and PAC/BTI use. + */ + SCB->CCR |= SCB_CCR_LOB_Msk | SCB_CCR_BP_Msk; + __DSB(); + __ISB(); +} diff --git a/ThirdParty/Renesas/ek-ra8p1/system_ra8p1.h b/ThirdParty/Renesas/ek-ra8p1/system_ra8p1.h new file mode 100644 index 0000000..ea4228d --- /dev/null +++ b/ThirdParty/Renesas/ek-ra8p1/system_ra8p1.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Adapted from ARM::Cortex_DFP@1.1.0, Device/ARMCM85/Include/system_ARMCM85.h. + */ + +#ifndef SYSTEM_RA8P1_H +#define SYSTEM_RA8P1_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*VECTOR_TABLE_Type)(void); +extern uint32_t SystemCoreClock; + +void SystemInit(void); +void SystemCoreClockUpdate(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Renesas/sources.json b/ThirdParty/Renesas/sources.json new file mode 100644 index 0000000..9bf8c4e --- /dev/null +++ b/ThirdParty/Renesas/sources.json @@ -0,0 +1,35 @@ +{ + "source_project": "Renesas_EK-RA8P1", + "source_revision": "3d94574ee1e95704ebca3d6ba173e0360b92872a", + "note": "Imported working-tree bytes are identified by source_sha256; the source project may contain uncommitted changes. CMSIS files adapt ARM::Cortex_DFP@1.1.0. The local system header removes the reference project clock-configuration API; the board uses the 8 MHz MOCO reset clock.", + "files": [ + { + "source_path": "src/startup_ra8p1.c", + "path": "ek-ra8p1/startup_ra8p1.c", + "sha256": "13a51131dc0480bac4c5e09e487008bb0e86afeaa43bf46ea7bc624cfec94051", + "size": 3008, + "source_sha256": "13a51131dc0480bac4c5e09e487008bb0e86afeaa43bf46ea7bc624cfec94051" + }, + { + "source_path": "src/system_ra8p1.c", + "path": "ek-ra8p1/system_ra8p1.c", + "sha256": "6f1b578f94faf0f6b575e1a80b433164b4cc96c47eb7dfc8dd131e743e25225d", + "size": 1221, + "source_sha256": "6f1b578f94faf0f6b575e1a80b433164b4cc96c47eb7dfc8dd131e743e25225d" + }, + { + "source_path": "board/ek-ra8p1/ra8p1.h", + "path": "ek-ra8p1/ra8p1.h", + "sha256": "7a07ab94dcecdabbf4450455c978bb4ec53e1c34f6221a1633fe3cd09013ee2c", + "size": 2057, + "source_sha256": "7a07ab94dcecdabbf4450455c978bb4ec53e1c34f6221a1633fe3cd09013ee2c" + }, + { + "source_path": "board/ek-ra8p1/system_ra8p1.h", + "path": "ek-ra8p1/system_ra8p1.h", + "sha256": "541e2c409597ff41644fe399a5a96bbdd0f6ac880c8af5d99c1ce837ed436d30", + "size": 1009, + "source_sha256": "db81d5c3259db1e79b57917f92a5a20a8869b5bf0e2c407af2a4cb252c15145d" + } + ] +} diff --git a/Trace.cbuild-pack.yml b/Trace.cbuild-pack.yml index 77b7f18..b73ce32 100644 --- a/Trace.cbuild-pack.yml +++ b/Trace.cbuild-pack.yml @@ -21,3 +21,6 @@ cbuild-pack: - resolved-pack: Keil::STM32L5xx_DFP@2.0.0 selected-by-pack: - Keil::STM32L5xx_DFP@2.0.0 + - resolved-pack: Renesas::RA_DFP@6.6.0 + selected-by-pack: + - Renesas::RA_DFP@6.6.0 diff --git a/Trace.csolution.yml b/Trace.csolution.yml index 8bacfa7..ad4a602 100644 --- a/Trace.csolution.yml +++ b/Trace.csolution.yml @@ -268,6 +268,31 @@ solution: input-clock: 16000000 output-clock: 1000000 + - type: EK-RA8P1 + device: Renesas::R7KA8P1KF:CPU0 + processor: + trustzone: off + fpu: off + mve: off + branch-protection: off + variables: + - Board-Layer: $SolutionDir()$/Board/EK-RA8P1/Board.clayer.yml + target-set: + - set: ULINKplus + images: + - project-context: TraceDemo.Debug + debugger: + name: ULINKplus@pyOCD + protocol: swd + clock: 10000000 + gdbserver: + - port: 3333 + trace: + - swo-uart: + mode: file + input-clock: 1000000 + output-clock: 1000000 + projects: - project: Projects/TraceDemo/TraceDemo.cproject.yml for-context: diff --git a/docs/BOARD_SUPPORT.md b/docs/BOARD_SUPPORT.md index 126d017..a410539 100644 --- a/docs/BOARD_SUPPORT.md +++ b/docs/BOARD_SUPPORT.md @@ -1,11 +1,11 @@ # Board support and references -All eight targets use local device-based layers in `Board//Board.clayer.yml`. +All ten targets use local device-based layers in `Board//Board.clayer.yml`. The solution selects each through `Board-Layer`. Device names and pinned DFPs below match the local configuration. Confirm the physical PCB revision separately from the catalog board revision. -| Local board layer | CMSIS device (`STMicroelectronics::`) | Core | Pinned DFP (`Keil::`) | +| Local board layer | CMSIS device (ST unless qualified) | Core | Pinned DFP (Keil unless qualified) | | --- | --- | --- | --- | | [MCBSTM32F400](../Board/MCBSTM32F400/README.md) | `STM32F407IGHx` | Cortex-M4 | `STM32F4xx_DFP@3.0.0` | | [NUCLEO-L552ZE-Q](../Board/NUCLEO-L552ZE-Q/README.md) | `STM32L552ZETxQ` | Cortex-M33 | `STM32L5xx_DFP@2.0.0` | @@ -16,10 +16,11 @@ from the catalog board revision. | [NUCLEO-F446RE](../Board/NUCLEO-F446RE/README.md) | `STM32F446RETx` | Cortex-M4 | `STM32F4xx_DFP@3.0.0` | | [STM32H7B3I-DK](../Board/STM32H7B3I-DK/README.md) | `STM32H7B3LIHxQ` | Cortex-M7 | `STM32H7xx_DFP@4.1.3` | | [STM32F4-DISCO](../Board/STM32F4-DISCO/README.md) | `STM32F407VGTx` | Cortex-M4 | `STM32F4xx_DFP@3.0.0` | +| [EK-RA8P1](../Board/EK-RA8P1/README.md) | `Renesas::R7KA8P1KF:CPU0` | Cortex-M85 | `Renesas::RA_DFP@6.6.0` | ## Shared layer design -Each layer selects standalone ST CMSIS device headers, GCC startup assembly and +STM32 layers select standalone ST CMSIS device headers, GCC startup assembly and system sources from [ThirdParty/ST](../ThirdParty/README.md), plus the shared GCC linker template. `regions.h` selects one internal Flash region, one SRAM region and a 4 KiB main stack. The board `main()` calls `target_init()` and the common @@ -197,3 +198,17 @@ onboard-probe hardware; select documentation for the physical PCB revision. Use the [board README](../Board/STM32F4-DISCO/README.md) and [MB997 wiring notes](ST_BOARD_BRINGUP.md#stm32f4-disco--mb997-b-02). + +### EK-RA8P1 + +The [RA8P1 layer](../Board/EK-RA8P1/README.md) uses the supplied RTOSDemo project's +CMSIS-based CPU0 startup and core header, internal code MRAM/SRAM0 and the +8 MHz MOCO reset clock. It shares the application, RTX configuration and GCC +linker template. The Cortex-M33 CPU1 is not an application target. + +The original `Renesas::RA_DFP@6.6.0` remains unmodified. A documented local +run-description override supplies missing CPU0/AP0 and SWO setup; a preparation +script generates CPU0-only trace settings from the current ELF. The solution +build runs it automatically; invoke it explicitly after a standalone refresh. No `.dbgconf` defaults exist for this device in that DFP. +The board README records Debug In jumpers, separate power, security prerequisites, +manual links and the remaining hardware checks. diff --git a/docs/BUILD.md b/docs/BUILD.md index a3c3bc7..b72ffca 100644 --- a/docs/BUILD.md +++ b/docs/BUILD.md @@ -2,14 +2,17 @@ ## Environment and dependencies -Use CMSIS-Toolbox 2.15.0, GNU Arm Toolchain 14.3.1, CMake 3.31.5 and Ninja 1.13.2. -Arm Environment Manager and CI install these versions from -[`vcpkg-configuration.json`](../vcpkg-configuration.json); the CMSIS Solution -extension can also supply the toolbox for local builds. +Arm Environment Manager and CI select the available build tools from +[`vcpkg-configuration.json`](../vcpkg-configuration.json), which currently uses +`*` version requirements. The earlier reference environment used CMSIS-Toolbox +2.15.0, GNU Arm Toolchain 14.3.1, CMake 3.31.5 and Ninja 1.13.2. Actual validation +versions are recorded in [Validation](VALIDATION.md). The CMSIS Solution extension +can also supply the toolbox for local builds. For a manual installation, put those tools on `PATH`, set `CMSIS_COMPILER_ROOT` -to the toolbox's `etc` directory and `GCC_TOOLCHAIN_14_3_1` to the compiler's `bin` -directory. Check the environment from the repository root: +to the toolbox's `etc` directory and the matching `GCC_TOOLCHAIN_` +variable to the compiler's `bin` directory (for example `GCC_TOOLCHAIN_14_3_1`). +Check the environment from the repository root: ```sh cbuild --version @@ -122,3 +125,18 @@ GNU newlib-nano/libnosys warns about unimplemented `_close`, `_lseek`, `_read` and `_write`. No STDIO transport is provided; the application makes no STDIO calls. See [Validation](VALIDATION.md) for hardware checks and results. + +## EK-RA8P1 trace setup + +Build `EK-RA8P1@ULINKplus` normally with the installed GCC toolchain. The +`PrepareRA8P1Trace` post-build step automatically applies the CPU0-only run +override and invokes the installed pyTS for the current ELF, including no-op +builds. Ruby's standard YAML library and the CMSIS Debugger tools export are +required for this target. Normal Load & Debug then works with file-based SWO +and automatic RAW-to-CSV conversion on pause/end; no trace TCP server is used. + +After a standalone refresh, ordinary manual trace conversion or a `--context` +build (which skips CMSIS `executes`), run +`ruby Board/EK-RA8P1/prepare_trace.rb` explicitly. An optional argument selects +pyTS when the tools export is unavailable. The [board README](../Board/EK-RA8P1/README.md) +explains the DFP gaps, clock baseline and hardware prerequisites. diff --git a/docs/DEBUG_PROBES.md b/docs/DEBUG_PROBES.md index 11fa4e8..064edc8 100644 --- a/docs/DEBUG_PROBES.md +++ b/docs/DEBUG_PROBES.md @@ -32,6 +32,10 @@ type are connected, select the intended probe before loading an image. | NUCLEO-F446RE | `STLink` | 16 MHz | | STM32H7B3I-DK | `ULINKplus` (unnamed set) | 64 MHz | | STM32F4-DISCO (MB997 B-02) | `ULINKplus`, `STLink` | 16 MHz | +| EK-RA8P1 | `ULINKplus` | 8 MHz CPU0/timestamps; 1 MHz trace input | + +The L552 target set is still named `ULINKplus`; its debugger selection currently +uses `ULINKpro@pyOCD`. For the two unnamed sets, select `--active MCBSTM32F400` or `--active STM32H7B3I-DK`, without an `@ULINKplus` suffix. The other boards @@ -63,3 +67,17 @@ cbuild Trace.csolution.yml --active 'NUCLEO-F756ZG@STLink' --packs --frozen-pack The generated `.cbuild-run.yml` represents the active set and is replaced when switching. Source and generated trace profiles include `@` for named sets; see the [file naming table](TRACE_APP.md#configuration-ownership). + +## EK-RA8P1 CPU0 preparation + +Use `EK-RA8P1@ULINKplus`, 10 MHz SWD, GDB port 3333 and 1 Mbaud SWO. +The target-specific `PrepareRA8P1Trace` step applies the CPU0/AP0 clock/routing +override and generates the runtime profile automatically after a solution build. +Enter Debug uses the prepared run description. SWO uses file capture with +automatic RAW-to-CSV conversion on pause/end; no live trace TCP port is used. + +After a standalone refresh, manual trace conversion or a `--context` build, +run `ruby Board/EK-RA8P1/prepare_trace.rb`. See the +[board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation). +Load/debug, RTX and automatic CSV on pause passed; capture-boundary errors +remain recorded in [Validation](VALIDATION.md#ek-ra8p1-cpu0--2026-11-17). diff --git a/docs/DESIGN.md b/docs/DESIGN.md index bdf4796..8cab991 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -6,7 +6,7 @@ hardware results and capture limitations are in [Validation](VALIDATION.md). ## Agreed requirements -- Reuse one compact application across Cortex-M4, Cortex-M7 and Cortex-M33 boards. +- Reuse one compact application across Cortex-M4, Cortex-M7, Cortex-M33 and Cortex-M85 boards. Keep device startup, memory layout and hardware adaptation in local board layers. - Use CMSIS csolution/cproject/clayer, CMSIS-Core and RTX5. Use device Packs for device descriptions, SVDs, Flash algorithms and debug/trace sequences. @@ -29,14 +29,14 @@ hardware results and capture limitations are in [Validation](VALIDATION.md). - Capture SWO through pyOCD and convert RAW to CSV automatically on debug pause or session end in VS Code. Add trace-buffer (TB) scenarios after the required target paths and pyOCD functionality are established; TB is not implemented here. -- Use internal Flash/SRAM and the vendor reset-clock baseline. L552 uses one image +- Use internal Flash or MRAM, SRAM and the vendor reset-clock baseline. L552 uses one image with TrustZone disabled; option-byte provisioning is outside this project. - Prepare for open-source release: preserve source provenance and license notices; exclude build outputs, `.trace/` and machine-specific settings from Git. The board order is MCBSTM32F400, NUCLEO-L552ZE-Q, NUCLEO-F756ZG, STM32F429I-DISCO, NUCLEO-F401RE, STM32H7B3I-DK, STM32F4-DISCO (MB997 B-02), -then NUCLEO-F446RE. +then NUCLEO-F446RE, NUCLEO-G474RE and EK-RA8P1. ## Architecture and ownership @@ -47,7 +47,7 @@ then NUCLEO-F446RE. | `Board//Board.clayer.yml` | Device header/startup/system selection, board `main()`, target adaptation and linker regions | | `Common/App`, `Common/Workloads`, `Common/Trace` | RTX startup, periodic signal generation and nonblocking ITM output | | `Projects/TraceDemo/RTE/CMSIS` | Shared RTX5 component configuration | -| `ThirdParty/ST`, `Board/Support` | Pinned ST CMSIS sources and shared linker template | +| `ThirdParty/ST`, `ThirdParty/Renesas`, `Board/Support` | Pinned CMSIS device sources and shared linker template | | `.cmsis/*.ctrace.yml` | Editable, symbol-based trace sources; pyTS resolves them against the built ELF | | `.cmsis/*.dbgconf` | Pack debug/trace variable configuration | | `out/*.cbuild-run.yml`, `.trace/` | Generated debug/trace runtime files and RAW/CSV captures; excluded from Git | @@ -96,6 +96,12 @@ and would not generate the call to `app_main()`. 5. Separated probe selection and trace traffic settings from the firmware build through [debugger target sets](DEBUG_PROBES.md). +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 board override and preparation +script apply the existing run-description override workflow without changing +installed Packs. See the [board layer](../Board/EK-RA8P1/README.md). + The [board inventory](BOARD_SUPPORT.md) records exact devices and Pack choices; [ThirdParty/README.md](../ThirdParty/README.md) records the imported source subset. diff --git a/docs/TRACE_APP.md b/docs/TRACE_APP.md index fd19f3f..ed50bbc 100644 --- a/docs/TRACE_APP.md +++ b/docs/TRACE_APP.md @@ -151,6 +151,11 @@ Their development status and source/release links are recorded there. watch and its writing-PC output as described above. Start the matching debugger configuration and inspect the resulting capture. +For EK-RA8P1, the solution build automatically runs the CPU0 preparation and +pyTS conversion after linking. After a standalone refresh, manual conversion +or `--context` build, run `ruby Board/EK-RA8P1/prepare_trace.rb` explicitly. +Capture still uses the normal SWO file and automatic CSV workflow. See the [board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation). + Equivalent offline generation with the bundled pyTS executable, for example: ```sh diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index 7b51c62..fa873ea 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -29,6 +29,7 @@ This table covers the regular demo; the StackCorruption experiment has its own s | NUCLEO-F446RE | — | PASS | IDE test pending; command-line server shutdown reported an SWV-reader assertion after the valid capture was flushed | | STM32H7B3I-DK | FAIL | — | ULINK+: incomplete/malformed packets at pause/end | | STM32F4-DISCO (MB997 B-02) | PASS | PASS | ULINK+: unexpected ITM26 records at pause/resume boundaries; incomplete pause/end packets. ST-LINK: pause passes, end incomplete | +| EK-RA8P1 | OPEN | — | Load/debug, RTX and automatic CSV on pause passed 2026-11-17; startup/EOF packet errors | Controlled ULINK+ findings: @@ -222,3 +223,58 @@ checks above. execution, SWO and automatic pause/end CSV conversion. - [ ] Confirm physical board revisions and unresolved connector/variant details listed in the [board references](BOARD_SUPPORT.md). + +## EK-RA8P1 CPU0 — 2026-11-17 + +**Build, Load & Debug, RTX runtime and automatic CSV on pause: PASS. Capture integrity: OPEN.** +`TraceDemo.Debug+EK-RA8P1`, set `ULINKplus`, built through CMSIS Solution using +CMSIS-Toolbox `2.15.0-41-gb69523a` (cbuild `2.15.0-20-g82c1ed2`, csolution +`2.15.1+p60-g84b22690`), GCC `15.3.2`, CMake `3.29.6` and Ninja `1.13.2`. +Dependencies are the unchanged Renesas RA_DFP 6.6.0, CMSIS 6.3.0 and RTX 5.9.0. +The selected tools differ from the historical reference versions in BUILD.md. + +The image links one CMSIS C vector table/reset handler and the shared RTX5 +application in internal MRAM/SRAM0. The 448-byte `__Vectors` table starts at +`0x02000000`; `main` and the RTX SVC handler are linked. ELF totals are about +15,020 bytes ROM and 38,512 bytes RAM including the main stack, within the +layer's 1 MiB MRAM and 512 KiB SRAM0. It retains the 8 MHz MOCO reset clock, +a 4 KiB main stack and the common RTX pool. No existing application source, +RTX configuration, shared linker script or installed pack was changed. + +The board preparation script applied the versioned CPU0/AP0 SWO override and +ran installed pyTS `1.0.1.dev2+ga70bcd1`. Both watched symbols resolved from the +current ELF as signed 32-bit values. The runtime retained the two DWT write +sources, ITM1, 8192-cycle PC sampling, 8 MHz timestamps and 16M DWT sync. +The generated run/runtime descriptions contain no CPU1 register operations. +SWO input/output clocks are both 1 MHz (MOCO /8, 1 Mbaud). +Repeated preparation passed, the ELF stayed unchanged, and wrong-target and +conflicting-sequence inputs were rejected before overwriting those inputs. + +The initial Enter Debug attempt failed before attaching: the ordinary build +replaced the manually prepared run description, removing CPU0/AP0 mapping. +The adapter also generated an empty GDB port without a default port entry. +An additional serializer problem emitted multiline sequence code with a closing +single quote at column zero; CMSIS Solution rejected that output. The target now +has a default GDB port, literal-block YAML output and a target-specific, always-run +post-build preparation step. The installed CMSIS Solution reader accepted the +result and generated port 3333 automatically. + +A subsequent normal `cmsis_action load_and_debug` completed CMSIS Load with exit +0 and reached the board's `main()`. RTX ran the Sine100ms, Noise100ms and +ITM1_200ms threads plus idle/timer. Live inspection reported APP_RUNNING, +`SystemCoreClock = g_app_core_clock_hz = 8000000`, ITM counter 465 and zero +ITM drops. The unrelated thOS debug session was left unchanged. + +SWO used `mode: file` with no trace TCP server. Pausing automatically created +a fresh CSV: 90,735 PC samples, 1,866 DWT records across the two watches and +465 ITM1 records. There were two decoder errors: `Invalid ITM packet sequence` +near startup and `Incomplete ITM packet at EOF` at the pause boundary; no overflow +record was present. Automatic CSV creation is verified, but this capture is not +an integrity PASS. The target was resumed after inspection. + +CPU1/AP2 discovery still reports WAIT ACK, as in the supplied reference project; +CPU0 loading/debugging succeeded. One intermediate direct flash attempt completed +programming but reported an I/O error on exit; the subsequent normal CMSIS +Load & Debug completed successfully. Repeated launch/reset and debug-end capture +integrity remain to be checked. The reference project's 1-GHz ITM0 results do not +apply to this reset-clock image. From 0609756ec8b2d89934d1e66b11a0ec5612accd60 Mon Sep 17 00:00:00 2001 From: Thorsten de Buhr Date: Tue, 17 Nov 2026 14:16:46 +0100 Subject: [PATCH 3/5] Replace Ruby trace preparation with a declarative RA8P1 debug description --- .github/workflows/build.yml | 10 ++ Board/EK-RA8P1/README.md | 64 +++++---- Board/EK-RA8P1/debug-run.yml | 164 ++++++++++++++++++++++ Board/EK-RA8P1/prepare_trace.rb | 123 ---------------- Board/EK-RA8P1/trace-override.yml | 49 ------- Projects/TraceDemo/TraceDemo.cproject.yml | 8 +- README.md | 2 +- ThirdParty/README.md | 2 +- docs/BOARD_SUPPORT.md | 7 +- docs/BUILD.md | 31 ++-- docs/DEBUG_PROBES.md | 21 ++- docs/DESIGN.md | 6 +- docs/TRACE_APP.md | 10 +- docs/VALIDATION.md | 38 +++-- 14 files changed, 279 insertions(+), 256 deletions(-) create mode 100644 Board/EK-RA8P1/debug-run.yml delete mode 100644 Board/EK-RA8P1/prepare_trace.rb delete mode 100644 Board/EK-RA8P1/trace-override.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d2add59..c6727af 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,3 +55,13 @@ jobs: --packs --frozen-packs --update-rte + + - name: Build RA8P1 solution flow + if: matrix.context == 'TraceDemo.Debug+EK-RA8P1' + run: >- + cbuild Trace.csolution.yml + --target all + --active 'EK-RA8P1@ULINKplus' + --packs + --frozen-packs + --update-rte diff --git a/Board/EK-RA8P1/README.md b/Board/EK-RA8P1/README.md index 4bc0829..e978ade 100644 --- a/Board/EK-RA8P1/README.md +++ b/Board/EK-RA8P1/README.md @@ -37,44 +37,46 @@ changes no lifecycle, OTP, option or security configuration. Select **EK-RA8P1 → ULINKplus** in CMSIS Manage Solution Settings and build: ```sh -cbuild Trace.csolution.yml --active 'EK-RA8P1@ULINKplus' --packs --frozen-packs --update-rte +cbuild Trace.csolution.yml --target all --active 'EK-RA8P1@ULINKplus' --packs --frozen-packs --update-rte ``` -The normal solution build automatically runs `PrepareRA8P1Trace` after linking, -including an otherwise up-to-date build. The step locates the installed CMSIS -Debugger's pyTS through `.cmsis/tools-environment.yml`, applies the CPU0 override -and regenerates the current-ELF trace configuration. Ruby with its standard YAML -library is required for this target. **Enter Debug / Load & Debug** then uses the -prepared run description and GDB port 3333. +The normal solution build runs `CopyRA8P1DebugDescription` after linking, +including an otherwise up-to-date build. Use the IDE solution build or the +`--target all` command above to include this step. It uses the existing CMake +`-E copy_if_different` command to copy [debug-run.yml](debug-run.yml) to +`out/Trace+EK-RA8P1.cbuild-run.yml`. No additional interpreter, YAML library or +CMSIS tools export is required by this step. -After a standalone refresh, manual trace conversion or a build with `--context` -(which skips CMSIS Toolbox `executes` steps), prepare the run description with -`ruby Board/EK-RA8P1/prepare_trace.rb`. An optional executable-path argument -selects pyTS when the CMSIS tools environment is unavailable. +Generate the trace runtime from the current ELF through the normal **Trace +Generation** view (or the bundled pyTS), as for the other targets. Then use +**Enter Debug / Load & Debug**. The debugger uses GDB port 3333. + +After a standalone refresh, a `--context` build, or a CLI solution build without +`--target all`, restore the debug description before generating trace: + +```sh +cmake -E copy_if_different Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml +``` Trace uses the normal **file capture → automatic CSV conversion** workflow. -There is no live trace TCP service. Pausing or ending debugging converts the -RAW file to `.trace/Trace+EK-RA8P1@ULINKplus.SWO.csv`; the GDB TCP connection is -only for debugging. +Pausing or ending debugging converts the RAW file to +`.trace/Trace+EK-RA8P1@ULINKplus.SWO.csv`. There is no live trace TCP service. The unmodified DFP supplies no RA8P1 SWO sequences, processor/AP mapping or -`.dbgconf` defaults. [trace-override.yml](trace-override.yml) and -[prepare_trace.rb](prepare_trace.rb) implement the project's -[temporary run-description override workflow](../../docs/TRACE_APP.md#temporary-run-description-overrides): - -- Map CPU0 to AP0 and limit this generated run to the selected CPU0 image. -- Enable P209 SWO output and the trace clock before CoreSight discovery and - after reset. Preserve PRCR access enables while setting TRCKCR to `/8`. -- Retain legacy pyOCD ITM/TPIU setup. Full trace setup is not enabled. -- Generate the runtime profile from the current ELF and omit only inactive - CPU1 disable writes. The supplied reference project reports CPU1/AP2 `WAIT ACK`; - no CPU1 workload or enabled trace source is removed. - -The debugger uses the prepared `out/Trace+EK-RA8P1.cbuild-run.yml`, and trace -uses `.trace/Trace+EK-RA8P1@ULINKplus.ctrace-run.yml`. The filenames and relative -paths stay unchanged. Builds regenerate the run description and then reapply the override; installed -packs and the reference project stay unchanged. A standalone CMSIS refresh -regenerates the vendor-only run description until the next solution build. +`.dbgconf` defaults. The temporary debug description supplies: + +- 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`. +- 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/`. + +This is a maintained description for **RA_DFP 6.6.0**, not a general YAML patcher. +Keep its DFP paths, image paths, transport settings and resources consistent with +the layer and solution. Once the DFP/tool flow provides this behavior natively, +remove the template and copy step together and verify the generated description. +Installed packs and the reference project remain unchanged. 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 diff --git a/Board/EK-RA8P1/debug-run.yml b/Board/EK-RA8P1/debug-run.yml new file mode 100644 index 0000000..935aee0 --- /dev/null +++ b/Board/EK-RA8P1/debug-run.yml @@ -0,0 +1,164 @@ +# SPDX-License-Identifier: Apache-2.0 +# Temporary CPU0-only debug description for the unmodified RA_DFP 6.6.0. +# The solution build copies this file to out/Trace+EK-RA8P1.cbuild-run.yml. +# Relative solution/image paths below are based on that out/ directory. +# Pack paths use the standard CMSIS_PACK_ROOT variable on each host. +# Remove this template and its copy step once the DFP/tool flow supplies +# CPU0/AP0, SWO routing/clock setup and CPU0-only trace operations. +--- +cbuild-run: + generated-by: TraceDemo EK-RA8P1 debug template for RA_DFP 6.6.0 + solution: "../Trace.csolution.yml" + target-type: EK-RA8P1 + target-set: ULINKplus + compiler: GCC + device: Renesas::R7KA8P1KF + device-pack: Renesas::RA_DFP@6.6.0 + device-pack-path: "${CMSIS_PACK_ROOT}/Renesas/RA_DFP/6.6.0" + output: + - file: TraceDemo/EK-RA8P1/Debug/TraceDemo.elf + info: generate by TraceDemo.Debug+EK-RA8P1 + type: elf + project: TraceDemo + load: image+symbols + pname: CPU0 + - file: TraceDemo/EK-RA8P1/Debug/TraceDemo.hex + info: generate by TraceDemo.Debug+EK-RA8P1 + type: hex + project: TraceDemo + load: none + pname: CPU0 + - file: TraceDemo/EK-RA8P1/Debug/TraceDemo.bin + info: generate by TraceDemo.Debug+EK-RA8P1 + type: bin + project: TraceDemo + load: none + pname: CPU0 + system-resources: + memory: + - name: ITCM + access: rwx + start: 0 + size: 131072 + pname: CPU0 + from-pack: Renesas::RA_DFP@6.6.0 + - name: DTCM + access: rw + start: 536870912 + size: 131072 + pname: CPU0 + from-pack: Renesas::RA_DFP@6.6.0 + - name: Flash + access: rx + start: 33554432 + size: 1048576 + default: true + from-pack: Renesas::RA_DFP@6.6.0 + - name: SRAM + access: rwx + start: 570425344 + size: 1703936 + default: true + from-pack: Renesas::RA_DFP@6.6.0 + - name: Config + access: r + start: 46788672 + size: 1984 + from-pack: Renesas::RA_DFP@6.6.0 + - name: OTP_Config + access: r + start: 48264704 + size: 66356 + from-pack: Renesas::RA_DFP@6.6.0 + processors: + - core: Cortex-M85 + revision: r0p0 + pname: CPU0 + endian: little + fpu: dp + mpu: present + dsp: present + trustzone: present + mve: fp + pacbti: present + max-clock: 480000000 + system-descriptions: + - file: "${CMSIS_PACK_ROOT}/Renesas/RA_DFP/6.6.0/SVD/R7KA8P1AD.svd" + type: svd + - file: "${CMSIS_PACK_ROOT}/ARM/CMSIS-RTX/5.9.0/RTX5.scvd" + type: scvd + pname: CPU0 + debugger: + name: ULINKplus@pyOCD + protocol: swd + clock: 10000000 + start-pname: CPU0 + gdbserver: + - port: 3333 + pname: CPU0 + trace: + - swo-uart: + mode: file + input-clock: 1000000 + output-clock: 1000000 + programming: + - algorithm: "${CMSIS_PACK_ROOT}/Renesas/RA_DFP/6.6.0/Flash/RA8P1_1M.FLM" + start: 33554432 + size: 1048576 + ram-start: 570425344 + ram-size: 30720 + - algorithm: "${CMSIS_PACK_ROOT}/Renesas/RA_DFP/6.6.0/Flash/RA8P1_CONF.FLM" + start: 46788672 + size: 1984 + ram-start: 570425344 + ram-size: 30720 + - algorithm: "${CMSIS_PACK_ROOT}/Renesas/RA_DFP/6.6.0/Flash/RA8P1_OTP.FLM" + start: 48264704 + size: 66356 + ram-start: 570425344 + ram-size: 30720 + debug-topology: + debugports: + - dpid: 0 + accessports: + - apid: 0 + index: 0 + processors: + - pname: CPU0 + apid: 0 + trace-sinks: + - serialwire: + debug-sequences: + - name: SetupRA8P1SWO + blocks: + - execute: | + __var saved_ap = __ap; + __ap = 0; + Write32(0x4001B030, 0x00000009); // TRPORTCR: CPU0 SWO on P209. + __var trace_clock = Read8(0x4001E03F); + - if: trace_clock != 0x83 + blocks: + - execute: | + __var saved_prcr = Read16(0x4001E3FA) & 0x000F; + Write16(0x4001E3FA, 0xA501 | saved_prcr); + - if: "(trace_clock & 0x80) != 0" + execute: | + Write8(0x4001E03F, trace_clock & 0x7F); + - execute: | + Write8(0x4001E03F, 0x03); // TRCK=/8 while stopped. + Write8(0x4001E03F, 0x83); // 8 MHz MOCO /8 = 1 MHz trace input. + Write16(0x4001E3FA, 0xA500 | saved_prcr); + - execute: | + __ap = saved_ap; + - name: DebugDeviceUnlock + blocks: + - if: "(__traceout & 1) != 0" + execute: | + // Enable the clock before CoreSight discovers the CPU0 TPIU. + Sequence("SetupRA8P1SWO"); + - name: TraceStart + blocks: + - if: "(__traceout & 1) != 0" + execute: | + // Restore routing after reset, before generic ITM/TPIU setup. + Sequence("SetupRA8P1SWO"); diff --git a/Board/EK-RA8P1/prepare_trace.rb b/Board/EK-RA8P1/prepare_trace.rb deleted file mode 100644 index 38c64fd..0000000 --- a/Board/EK-RA8P1/prepare_trace.rb +++ /dev/null @@ -1,123 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Apply the documented CPU0-only override to the generated run description. -# Ruby's standard YAML library is the only dependency; no board access occurs. -require 'yaml' - -root = File.expand_path('../..', __dir__) -path = File.join(root, 'out/Trace+EK-RA8P1.cbuild-run.yml') -abort 'Usage: ruby Board/EK-RA8P1/prepare_trace.rb [path/to/pyTS]' if ARGV.length > 1 -if ARGV.empty? - environment_path = File.join(root, '.cmsis/tools-environment.yml') - abort 'Missing .cmsis/tools-environment.yml; refresh CMSIS Solution first' unless File.file?(environment_path) - environment = YAML.safe_load(File.read(environment_path)).fetch('cmsis-tools-environment') - debugger = environment.fetch('tools').find { |tool| tool['name'] == 'pyOCD' } - abort 'CMSIS Debugger pyOCD tool not found in the selected environment' unless debugger - directory = File.expand_path('../pyts', debugger.fetch('directory')) - candidates = %w[pyTS pyTS.exe].map { |name| File.join(directory, name) } - pyts = candidates.find { |candidate| File.file?(candidate) && File.executable?(candidate) } - abort 'Bundled pyTS not found; pass its executable path explicitly' unless pyts -else - pyts = File.expand_path(ARGV[0]) -end -abort 'pyTS executable not found' unless File.file?(pyts) && File.executable?(pyts) - -def require_value(condition, message) - abort "RA8P1 trace setup: #{message}" unless condition -end - -# Retain csolution's indentation for image entries. Some build-artifact -# consumers scan these entries line by line instead of parsing the YAML. -def write_yaml(path, document) - # Use literal blocks for sequence code. Psych otherwise emits some - # multiline strings as single quotes ending at column zero, which the - # CMSIS Solution YAML reader rejects. - syntax = Psych.parse_stream(YAML.dump(document)) - literal_strings = lambda do |node| - if node.is_a?(Psych::Nodes::Scalar) && node.value.include?("\n") - node.style = Psych::Nodes::Scalar::LITERAL - end - Array(node.children).each { |child| literal_strings.call(child) } - end - literal_strings.call(syntax) - text = syntax.yaml - if document.key?('cbuild-run') - text.sub!(/(^ output:\n)(.*?)(?=^ [a-z])/m) do - Regexp.last_match(1) + Regexp.last_match(2).lines.map { |line| ' ' + line }.join - end - end - require_value(YAML.safe_load(text) == document, 'YAML round-trip mismatch') - temporary = "#{path}.ra8p1-tmp" - File.write(temporary, text) - File.rename(temporary, path) -end - -begin - document = YAML.safe_load(File.read(path)) - run = document.fetch('cbuild-run') - expected = { - 'target-type' => 'EK-RA8P1', 'target-set' => 'ULINKplus', - 'device' => 'Renesas::R7KA8P1KF', 'device-pack' => 'Renesas::RA_DFP@6.6.0' - } - expected.each { |key, value| require_value(run[key] == value, "unexpected #{key}; rebuild EK-RA8P1@ULINKplus") } - require_value(run.fetch('output').all? { |image| image['pname'] == 'CPU0' }, 'expected CPU0 images only') - debugger = run.fetch('debugger') - require_value(debugger['name'] == 'ULINKplus@pyOCD', 'unexpected debugger') - swo = debugger.fetch('trace').fetch(0) - require_value(swo.key?('swo-uart') && swo['input-clock'] == 1_000_000 && swo['output-clock'] == 1_000_000, - 'expected 1 MHz trace input and 1 Mbaud SWO') - - override = YAML.safe_load(File.read(File.join(__dir__, 'trace-override.yml'))) - sequences = run['debug-sequences'] - require_value(sequences.nil? || sequences == override['debug-sequences'], - 'unexpected debug sequences; review instead of overwriting them') - require_value(!run.key?('debug-sequences-conf'), 'expected legacy trace setup') - topology = run.fetch('debug-topology') - require_value(topology == { 'trace-sinks' => [{ 'serialwire' => nil }, { 'tracebuffer' => nil }] } || - topology == override['debug-topology'], 'unexpected debug topology') - - resources = run.fetch('system-resources') - processors = resources.fetch('processors') - require_value(processors.map { |p| p['pname'] }.sort == %w[CPU0 CPU1] || - processors.map { |p| p['pname'] } == ['CPU0'], 'unexpected processors') - # This run describes the selected CPU0 image. CPU1/AP2 is not available in - # the reference setup; pyTS must not emit disable writes for that processor. - resources['processors'] = processors.select { |p| p['pname'] == 'CPU0' } - resources['memory'].reject! { |m| m['pname'] == 'CPU1' } - debugger['gdbserver'] = debugger.fetch('gdbserver').select { |server| [nil, 'CPU0'].include?(server['pname']) } - debugger['gdbserver'].each { |server| server['pname'] = 'CPU0' } - override.each { |key, value| run[key] = value } - - # Keep the filename and directory so relative ELF/profile paths stay valid. - # Atomic replacement also avoids leaving a partial run description on failure. - write_yaml(path, document) - - source_path = File.join(root, '.cmsis/Trace+EK-RA8P1@ULINKplus.ctrace.yml') - source = YAML.safe_load(File.read(source_path)) - setup = source.fetch('ctrace').fetch('setup') - require_value(setup.select { |entry| entry['pname'] == 'CPU1' }.all? { |entry| entry.key?('disable') }, - 'refusing to remove an enabled CPU1 source profile') - if setup.any? { |entry| entry['pname'] == 'CPU1' } - setup.reject! { |entry| entry['pname'] == 'CPU1' } - write_yaml(source_path, source) - end - abort 'pyTS generation failed' unless system(pyts, path, '--format', 'json') - - runtime_path = File.join(root, '.trace/Trace+EK-RA8P1@ULINKplus.ctrace-run.yml') - runtime = YAML.safe_load(File.read(runtime_path)) - trace = runtime.fetch('ctrace-run') - cpu1 = trace.fetch('ctrace-setup').select { |entry| entry['pname'] == 'CPU1' } - require_value(cpu1.all? { |entry| entry.key?('disable') }, 'refusing to remove an enabled CPU1 source') - require_value(trace.fetch('ctrace-refs').all? { |entry| [nil, 'CPU0'].include?(entry['pname']) && entry.fetch('ref').start_with?('CPU0/') }, - 'expected CPU0 trace sources only') - # Older generated source profiles may retain inactive CPU1 settings. - # Omit only disable accesses; enabled CPU1 sources were rejected above. - %w[ctrace-setup ctrace-disable].each do |key| - trace.fetch(key).reject! { |entry| entry['pname'] == 'CPU1' } - end - require_value(trace.fetch('ctrace-setup').map { |entry| entry['pname'] } == ['CPU0'], - 'unexpected trace processors') - write_yaml(runtime_path, runtime) - puts 'Prepared CPU0/AP0 SWO and generated the trace runtime without CPU1 accesses.' -rescue KeyError, TypeError, NoMethodError, Psych::Exception, SystemCallError => error - abort "RA8P1 trace setup: #{error.message}" -end diff --git a/Board/EK-RA8P1/trace-override.yml b/Board/EK-RA8P1/trace-override.yml deleted file mode 100644 index 81d3e23..0000000 --- a/Board/EK-RA8P1/trace-override.yml +++ /dev/null @@ -1,49 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# CPU0-only SWO adaptation of Renesas_EK-RA8P1's legacy-ra8p1-swo-device.xml. -# RA8P1 hardware manual Rev. 1.30, pp. 144-145, 375-376, 524-526. -# Keep legacy pyOCD ITM/TPIU setup; trace-setup: full would bypass it. -debug-topology: - debugports: - - dpid: 0 - accessports: - - apid: 0 - index: 0 - processors: - - pname: CPU0 - apid: 0 - trace-sinks: - - serialwire: -debug-sequences: - - name: SetupRA8P1SWO - blocks: - - execute: | - __var saved_ap = __ap; - __ap = 0; - Write32(0x4001B030, 0x00000009); // TRPORTCR: CPU0 SWO on P209. - __var trace_clock = Read8(0x4001E03F); - - if: trace_clock != 0x83 - blocks: - - execute: | - __var saved_prcr = Read16(0x4001E3FA) & 0x000F; - Write16(0x4001E3FA, 0xA501 | saved_prcr); - - if: (trace_clock & 0x80) != 0 - execute: | - Write8(0x4001E03F, trace_clock & 0x7F); - - execute: | - Write8(0x4001E03F, 0x03); // TRCK=/8 while stopped. - Write8(0x4001E03F, 0x83); // 8 MHz MOCO /8 = 1 MHz trace input. - Write16(0x4001E3FA, 0xA500 | saved_prcr); - - execute: | - __ap = saved_ap; - - name: DebugDeviceUnlock - blocks: - - if: (__traceout & 1) != 0 - execute: | - // Enable the clock before CoreSight discovers the CPU0 TPIU. - Sequence("SetupRA8P1SWO"); - - name: TraceStart - blocks: - - if: (__traceout & 1) != 0 - execute: | - // Restore routing after reset, before generic ITM/TPIU setup. - Sequence("SetupRA8P1SWO"); diff --git a/Projects/TraceDemo/TraceDemo.cproject.yml b/Projects/TraceDemo/TraceDemo.cproject.yml index d8d66af..e61db27 100644 --- a/Projects/TraceDemo/TraceDemo.cproject.yml +++ b/Projects/TraceDemo/TraceDemo.cproject.yml @@ -38,13 +38,15 @@ project: - file: ../../Common/Include/trace.h executes: - - execute: PrepareRA8P1Trace + - execute: CopyRA8P1DebugDescription for-context: .Debug+EK-RA8P1 - run: ruby "$input(1)$" + run: cmake -E copy_if_different $input(1)$ $output(0)$ always: input: - $elf()$ - - $SolutionDir()$/Board/EK-RA8P1/prepare_trace.rb + - $SolutionDir()$/Board/EK-RA8P1/debug-run.yml + output: + - $SolutionDir()$/out/Trace+EK-RA8P1.cbuild-run.yml layers: - layer: $Board-Layer$ diff --git a/README.md b/README.md index 79237e7..c3d78f4 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Capture-start and pause/end recording issues remain; see [Validation](docs/VALID | [STM32F4-DISCO](Board/STM32F4-DISCO/README.md), MB997 B-02 | Cortex-M4 | `ULINKplus`, `STLink` | | [EK-RA8P1](Board/EK-RA8P1/README.md) | Cortex-M85 CPU0, TrustZone build off | `ULINKplus` | -EK-RA8P1 applies its [CPU0 trace preparation](Board/EK-RA8P1/README.md#debug-and-trace-preparation) automatically during a solution build. +EK-RA8P1 copies its temporary [CPU0 debug description](Board/EK-RA8P1/README.md#debug-and-trace-preparation) during a solution build; trace generation uses the normal tools. Hardware results and open capture issues are listed in [Validation](docs/VALIDATION.md). This project currently implements SWO; diff --git a/ThirdParty/README.md b/ThirdParty/README.md index 386586a..7cfe24d 100644 --- a/ThirdParty/README.md +++ b/ThirdParty/README.md @@ -46,6 +46,6 @@ The CMSIS C startup places `.vectors` at MRAM origin using the shared linker script, initializes data through the CMSIS copy table and lets newlib initialize BSS. The DFP's FSP-generated startup is not selected. Renesas::RA_DFP@6.6.0 supplies device metadata, SVD and programming algorithms from the installed pack; -its contents are unchanged. The board-local trace override adapts the supplied +its contents are unchanged. The board-local debug description adapts the supplied project's historical CPU0 SWO sequence, with the reset-clock frequency and explicit AP preservation. See the [board documentation](../Board/EK-RA8P1/README.md). diff --git a/docs/BOARD_SUPPORT.md b/docs/BOARD_SUPPORT.md index a410539..1da20be 100644 --- a/docs/BOARD_SUPPORT.md +++ b/docs/BOARD_SUPPORT.md @@ -207,8 +207,9 @@ CMSIS-based CPU0 startup and core header, internal code MRAM/SRAM0 and the linker template. The Cortex-M33 CPU1 is not an application target. The original `Renesas::RA_DFP@6.6.0` remains unmodified. A documented local -run-description override supplies missing CPU0/AP0 and SWO setup; a preparation -script generates CPU0-only trace settings from the current ELF. The solution -build runs it automatically; invoke it explicitly after a standalone refresh. No `.dbgconf` defaults exist for this device in that DFP. +CPU0-only debug description supplies the missing CPU0/AP0 and SWO setup. The +solution build copies it with CMake; standard pyTS generates trace settings from +the current ELF. Restore the description after a standalone refresh. No `.dbgconf` +defaults exist for this device in that DFP. The board README records Debug In jumpers, separate power, security prerequisites, manual links and the remaining hardware checks. diff --git a/docs/BUILD.md b/docs/BUILD.md index b72ffca..617d56b 100644 --- a/docs/BUILD.md +++ b/docs/BUILD.md @@ -128,15 +128,22 @@ See [Validation](VALIDATION.md) for hardware checks and results. ## EK-RA8P1 trace setup -Build `EK-RA8P1@ULINKplus` normally with the installed GCC toolchain. The -`PrepareRA8P1Trace` post-build step automatically applies the CPU0-only run -override and invokes the installed pyTS for the current ELF, including no-op -builds. Ruby's standard YAML library and the CMSIS Debugger tools export are -required for this target. Normal Load & Debug then works with file-based SWO -and automatic RAW-to-CSV conversion on pause/end; no trace TCP server is used. - -After a standalone refresh, ordinary manual trace conversion or a `--context` -build (which skips CMSIS `executes`), run -`ruby Board/EK-RA8P1/prepare_trace.rb` explicitly. An optional argument selects -pyTS when the tools export is unavailable. The [board README](../Board/EK-RA8P1/README.md) -explains the DFP gaps, clock baseline and hardware prerequisites. +Build `EK-RA8P1@ULINKplus` with the installed GCC toolchain using the IDE solution +build or `cbuild --target all --active EK-RA8P1@ULINKplus Trace.csolution.yml`. The +`CopyRA8P1DebugDescription` step uses the existing CMake executable to copy the +versioned CPU0-only debug description into `out/`, including no-op builds. +This step needs no additional interpreter or CMSIS Debugger tools export. +Generate the trace runtime from the current ELF with the normal Trace Generation +view or bundled pyTS, then use Load & Debug. SWO is captured to a file and +converted automatically to CSV on pause/end. + +After a standalone refresh, a `--context` build, or a CLI solution build without +`--target all`, copy the description explicitly before trace generation: + +```sh +cmake -E copy_if_different Board/EK-RA8P1/debug-run.yml out/Trace+EK-RA8P1.cbuild-run.yml +``` + +The [board README](../Board/EK-RA8P1/README.md) explains the temporary DFP 6.6.0 +workaround, clock baseline and hardware prerequisites. A clean CI solution build +checks that the copy step works without a local debugger tools export. diff --git a/docs/DEBUG_PROBES.md b/docs/DEBUG_PROBES.md index 064edc8..5ba2516 100644 --- a/docs/DEBUG_PROBES.md +++ b/docs/DEBUG_PROBES.md @@ -68,16 +68,15 @@ The generated `.cbuild-run.yml` represents the active set and is replaced when switching. Source and generated trace profiles include `@` for named sets; see the [file naming table](TRACE_APP.md#configuration-ownership). -## EK-RA8P1 CPU0 preparation +## EK-RA8P1 CPU0 debug description Use `EK-RA8P1@ULINKplus`, 10 MHz SWD, GDB port 3333 and 1 Mbaud SWO. -The target-specific `PrepareRA8P1Trace` step applies the CPU0/AP0 clock/routing -override and generates the runtime profile automatically after a solution build. -Enter Debug uses the prepared run description. SWO uses file capture with -automatic RAW-to-CSV conversion on pause/end; no live trace TCP port is used. - -After a standalone refresh, manual trace conversion or a `--context` build, -run `ruby Board/EK-RA8P1/prepare_trace.rb`. See the -[board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation). -Load/debug, RTX and automatic CSV on pause passed; capture-boundary errors -remain recorded in [Validation](VALIDATION.md#ek-ra8p1-cpu0--2026-11-17). +The target-specific `CopyRA8P1DebugDescription` solution-build step copies the +versioned CPU0/AP0 description using CMake. 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. + +After a standalone refresh or `--context` build, restore the description with the +CMake command in the [board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation). +Load/debug, RTX and automatic CSV on pause passed with the same CPU0 settings; +capture-boundary errors remain in [Validation](VALIDATION.md#ek-ra8p1-cpu0--2026-11-17). diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 8cab991..69ca562 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -98,9 +98,9 @@ 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 board override and preparation -script apply the existing run-description override workflow without changing -installed Packs. See the [board layer](../Board/EK-RA8P1/README.md). +DFP lacks CPU0/AP0 and SWO setup; the versioned CPU0 debug description and a +CMake copy step apply the run-description override workflow without changing +installed Packs or adding an interpreter dependency. See the [board layer](../Board/EK-RA8P1/README.md). The [board inventory](BOARD_SUPPORT.md) records exact devices and Pack choices; [ThirdParty/README.md](../ThirdParty/README.md) records the imported source subset. diff --git a/docs/TRACE_APP.md b/docs/TRACE_APP.md index ed50bbc..3b38ee0 100644 --- a/docs/TRACE_APP.md +++ b/docs/TRACE_APP.md @@ -151,10 +151,12 @@ Their development status and source/release links are recorded there. watch and its writing-PC output as described above. Start the matching debugger configuration and inspect the resulting capture. -For EK-RA8P1, the solution build automatically runs the CPU0 preparation and -pyTS conversion after linking. After a standalone refresh, manual conversion -or `--context` build, run `ruby Board/EK-RA8P1/prepare_trace.rb` explicitly. -Capture still uses the normal SWO file and automatic CSV workflow. See the [board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation). +For EK-RA8P1, the solution build copies the versioned CPU0 debug description +using CMake. Trace generation then uses this description and the current ELF +through the same view or pyTS command as the other targets. After a standalone +refresh or `--context` build, restore the description with the command in the +[board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation). +Capture uses the normal SWO file and automatic CSV workflow. Equivalent offline generation with the bundled pyTS executable, for example: diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index fa873ea..694612f 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -241,23 +241,21 @@ layer's 1 MiB MRAM and 512 KiB SRAM0. It retains the 8 MHz MOCO reset clock, a 4 KiB main stack and the common RTX pool. No existing application source, RTX configuration, shared linker script or installed pack was changed. -The board preparation script applied the versioned CPU0/AP0 SWO override and -ran installed pyTS `1.0.1.dev2+ga70bcd1`. Both watched symbols resolved from the -current ELF as signed 32-bit values. The runtime retained the two DWT write -sources, ITM1, 8192-cycle PC sampling, 8 MHz timestamps and 16M DWT sync. -The generated run/runtime descriptions contain no CPU1 register operations. -SWO input/output clocks are both 1 MHz (MOCO /8, 1 Mbaud). -Repeated preparation passed, the ELF stayed unchanged, and wrong-target and -conflicting-sequence inputs were rejected before overwriting those inputs. +The initial preparation generated a CPU0/AP0 SWO description and ran installed +pyTS `1.0.1.dev2+ga70bcd1`. Both watched symbols resolved from the current ELF as +signed 32-bit values. The runtime retained the two DWT write sources, ITM1, +8192-cycle PC sampling, 8 MHz timestamps and 16M DWT sync. The run/runtime +descriptions contain no CPU1 register operations. SWO input/output clocks are +both 1 MHz (MOCO /8, 1 Mbaud). The initial Enter Debug attempt failed before attaching: the ordinary build -replaced the manually prepared run description, removing CPU0/AP0 mapping. -The adapter also generated an empty GDB port without a default port entry. -An additional serializer problem emitted multiline sequence code with a closing -single quote at column zero; CMSIS Solution rejected that output. The target now -has a default GDB port, literal-block YAML output and a target-specific, always-run -post-build preparation step. The installed CMSIS Solution reader accepted the -result and generated port 3333 automatically. +replaced the prepared run description, removing CPU0/AP0 mapping. The adapter +also generated an empty GDB port without a default port entry. The target now +has a default GDB port and a versioned, CPU0-only `debug-run.yml` description +with literal-block sequence code. A target-specific, always-run CMake copy step +installs it after linking. Trace generation uses the normal view or bundled pyTS. +The description retains the debug topology and sequences used in the hardware +checks below; no YAML serializer or additional interpreter is required. A subsequent normal `cmsis_action load_and_debug` completed CMSIS Load with exit 0 and reached the board's `main()`. RTX ran the Sine100ms, Noise100ms and @@ -278,3 +276,13 @@ programming but reported an I/O error on exit; the subsequent normal CMSIS Load & Debug completed successfully. Repeated launch/reset and debug-end capture integrity remain to be checked. The reference project's 1-GHz ITM0 results do not apply to this reset-clock image. + +**Interpreter-free preparation — 2026-11-17:** the normal CMSIS solution build +passed with the CMake copy step. The copied run description matches the versioned +template, and its CPU0 topology/sequences match the earlier hardware-tested +configuration. A fresh source snapshot in a path containing spaces passed the +`--target all` solution build without `.cmsis/tools-environment.yml` and with +an interpreter shim that rejects any Ruby invocation. The copied run description +matched the template byte for byte. Standard pyTS generated all six CPU0 trace +references; trace register operations matched the existing runtime. The current debug session could not read the core, and its server log reported +`No such device`; no new hardware capture is claimed for this preparation change. From 9c856db5f5103b1f85cf7bcd888c8733d28150a7 Mon Sep 17 00:00:00 2001 From: Thorsten de Buhr Date: Tue, 17 Nov 2026 15:50:55 +0100 Subject: [PATCH 4/5] Move RA8P1 debug preparation into an optional agent skill --- .agents/skills/prepare-ra8p1-trace/SKILL.md | 57 +++++++++++++++++++++ .github/workflows/build.yml | 12 ++--- Board/EK-RA8P1/README.md | 31 ++++++----- Board/EK-RA8P1/debug-run.yml | 4 +- Projects/TraceDemo/TraceDemo.cproject.yml | 11 ---- README.md | 8 ++- docs/BOARD_SUPPORT.md | 4 +- docs/BUILD.md | 24 ++++----- docs/DEBUG_PROBES.md | 13 ++--- docs/DESIGN.md | 5 +- docs/TRACE_APP.md | 11 ++-- docs/VALIDATION.md | 26 ++++++---- 12 files changed, 131 insertions(+), 75 deletions(-) create mode 100644 .agents/skills/prepare-ra8p1-trace/SKILL.md diff --git a/.agents/skills/prepare-ra8p1-trace/SKILL.md b/.agents/skills/prepare-ra8p1-trace/SKILL.md new file mode 100644 index 0000000..a1118dd --- /dev/null +++ b/.agents/skills/prepare-ra8p1-trace/SKILL.md @@ -0,0 +1,57 @@ +--- +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. +--- + +# Prepare RA8P1 trace + +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: + + ```sh + cmake -E copy_if_different 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: + + ```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. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c6727af..37878c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,12 +56,8 @@ jobs: --frozen-packs --update-rte - - name: Build RA8P1 solution flow + - name: Check explicit RA8P1 debug preparation if: matrix.context == 'TraceDemo.Debug+EK-RA8P1' - run: >- - cbuild Trace.csolution.yml - --target all - --active 'EK-RA8P1@ULINKplus' - --packs - --frozen-packs - --update-rte + run: | + cmake -E copy_if_different 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 diff --git a/Board/EK-RA8P1/README.md b/Board/EK-RA8P1/README.md index e978ade..a48a23e 100644 --- a/Board/EK-RA8P1/README.md +++ b/Board/EK-RA8P1/README.md @@ -37,27 +37,29 @@ changes no lifecycle, OTP, option or security configuration. Select **EK-RA8P1 → ULINKplus** in CMSIS Manage Solution Settings and build: ```sh -cbuild Trace.csolution.yml --target all --active 'EK-RA8P1@ULINKplus' --packs --frozen-packs --update-rte +cbuild Trace.csolution.yml --active 'EK-RA8P1@ULINKplus' --packs --frozen-packs --update-rte ``` -The normal solution build runs `CopyRA8P1DebugDescription` after linking, -including an otherwise up-to-date build. Use the IDE solution build or the -`--target all` command above to include this step. It uses the existing CMake -`-E copy_if_different` command to copy [debug-run.yml](debug-run.yml) to -`out/Trace+EK-RA8P1.cbuild-run.yml`. No additional interpreter, YAML library or -CMSIS tools export is required by this step. +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 +and generates the normal trace runtime with the installed pyTS. -Generate the trace runtime from the current ELF through the normal **Trace -Generation** view (or the bundled pyTS), as for the other targets. Then use -**Enter Debug / Load & Debug**. The debugger uses GDB port 3333. - -After a standalone refresh, a `--context` build, or a CLI solution build without -`--target all`, restore the debug description before generating trace: +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 ``` +Then generate the trace runtime from the current ELF through the normal **Trace +Generation** view (or the bundled pyTS), as for the other targets. Use +**Enter Debug / Load & Debug** after generation. The debugger uses GDB port 3333. +A subsequent build, refresh or target change can replace the prepared description; +repeat preparation after that operation. No additional interpreter, YAML library +or CMSIS tools export is required. The skill is optional automation; the commands +also work for a fresh clone with the documented build/debug tools installed. + Trace uses the normal **file capture → automatic CSV conversion** workflow. Pausing or ending debugging converts the RAW file to `.trace/Trace+EK-RA8P1@ULINKplus.SWO.csv`. There is no live trace TCP service. @@ -75,7 +77,8 @@ The unmodified DFP supplies no RA8P1 SWO sequences, processor/AP mapping or This is a maintained description for **RA_DFP 6.6.0**, not a general YAML patcher. Keep its DFP paths, image paths, transport settings and resources consistent with the layer and solution. Once the DFP/tool flow provides this behavior natively, -remove the template and copy step together and verify the generated description. +remove the template and preparation skill together and verify the generated +description. Installed packs and the reference project remain unchanged. SWD is 10 MHz. MOCO `/8` gives a **1 MHz trace input**, serialized at **1 Mbaud**; diff --git a/Board/EK-RA8P1/debug-run.yml b/Board/EK-RA8P1/debug-run.yml index 935aee0..9834d68 100644 --- a/Board/EK-RA8P1/debug-run.yml +++ b/Board/EK-RA8P1/debug-run.yml @@ -1,9 +1,9 @@ # SPDX-License-Identifier: Apache-2.0 # Temporary CPU0-only debug description for the unmodified RA_DFP 6.6.0. -# The solution build copies this file to out/Trace+EK-RA8P1.cbuild-run.yml. +# Apply after build/refresh with the prepare-ra8p1-trace skill or README command. # Relative solution/image paths below are based on that out/ directory. # Pack paths use the standard CMSIS_PACK_ROOT variable on each host. -# Remove this template and its copy step once the DFP/tool flow supplies +# Remove this template and the preparation skill once the DFP/tool flow supplies # CPU0/AP0, SWO routing/clock setup and CPU0-only trace operations. --- cbuild-run: diff --git a/Projects/TraceDemo/TraceDemo.cproject.yml b/Projects/TraceDemo/TraceDemo.cproject.yml index e61db27..8563561 100644 --- a/Projects/TraceDemo/TraceDemo.cproject.yml +++ b/Projects/TraceDemo/TraceDemo.cproject.yml @@ -37,17 +37,6 @@ project: - file: ../../Common/Trace/itm_output.c - file: ../../Common/Include/trace.h - executes: - - execute: CopyRA8P1DebugDescription - for-context: .Debug+EK-RA8P1 - run: cmake -E copy_if_different $input(1)$ $output(0)$ - always: - input: - - $elf()$ - - $SolutionDir()$/Board/EK-RA8P1/debug-run.yml - output: - - $SolutionDir()$/out/Trace+EK-RA8P1.cbuild-run.yml - layers: - layer: $Board-Layer$ type: Board diff --git a/README.md b/README.md index c3d78f4..4a8d83f 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,8 @@ Capture-start and pause/end recording issues remain; see [Validation](docs/VALID | [STM32F4-DISCO](Board/STM32F4-DISCO/README.md), MB997 B-02 | Cortex-M4 | `ULINKplus`, `STLink` | | [EK-RA8P1](Board/EK-RA8P1/README.md) | Cortex-M85 CPU0, TrustZone build off | `ULINKplus` | -EK-RA8P1 copies its temporary [CPU0 debug description](Board/EK-RA8P1/README.md#debug-and-trace-preparation) during a solution build; trace generation uses the normal tools. +EK-RA8P1 needs an explicit [CPU0 debug preparation](Board/EK-RA8P1/README.md#debug-and-trace-preparation) +after build/refresh, using a repository skill or the documented shell command. Hardware results and open capture issues are listed in [Validation](docs/VALIDATION.md). This project currently implements SWO; @@ -58,7 +59,10 @@ Missing CMSIS packs are installed by `cbuild --packs` using the pinned dependenc L552-only `ULINKplus StackCorruption`). Sets use automatic probe selection; select the intended probe locally when several are connected. Check the board README linked above and the [ST board wiring notes](docs/ST_BOARD_BRINGUP.md). -3. Build the selected target. Enable `vscode-cmsis-debugger.enableTraceGenerationView` +3. Build the selected target. For EK-RA8P1, apply its [debug description](Board/EK-RA8P1/README.md#debug-and-trace-preparation) + after the build, or invoke `Use $prepare-ra8p1-trace` to prepare it and generate + trace through the [repository skill](.agents/skills/prepare-ra8p1-trace/SKILL.md). + Enable `vscode-cmsis-debugger.enableTraceGenerationView` in local VS Code settings. In the CMSIS Debugger **Trace Generation** view, review its `.ctrace.yml` profile and run **Convert *.ctrace.yml to *.ctrace-run.yml**. Repeat conversion after rebuilding or changing the profile so DWT addresses diff --git a/docs/BOARD_SUPPORT.md b/docs/BOARD_SUPPORT.md index 1da20be..5948b7b 100644 --- a/docs/BOARD_SUPPORT.md +++ b/docs/BOARD_SUPPORT.md @@ -208,8 +208,8 @@ 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 -solution build copies it with CMake; standard pyTS generates trace settings from -the current ELF. Restore the description after a standalone refresh. No `.dbgconf` +explicit preparation skill or documented CMake 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, manual links and the remaining hardware checks. diff --git a/docs/BUILD.md b/docs/BUILD.md index 617d56b..488b57f 100644 --- a/docs/BUILD.md +++ b/docs/BUILD.md @@ -129,21 +129,21 @@ See [Validation](VALIDATION.md) for hardware checks and results. ## EK-RA8P1 trace setup Build `EK-RA8P1@ULINKplus` with the installed GCC toolchain using the IDE solution -build or `cbuild --target all --active EK-RA8P1@ULINKplus Trace.csolution.yml`. The -`CopyRA8P1DebugDescription` step uses the existing CMake executable to copy the -versioned CPU0-only debug description into `out/`, including no-op builds. -This step needs no additional interpreter or CMSIS Debugger tools export. -Generate the trace runtime from the current ELF with the normal Trace Generation -view or bundled pyTS, then use Load & Debug. SWO is captured to a file and -converted automatically to CSV on pause/end. - -After a standalone refresh, a `--context` build, or a CLI solution build without -`--target all`, copy the description explicitly before trace generation: +build or `cbuild --active EK-RA8P1@ULINKplus Trace.csolution.yml`. The firmware +build has no custom preparation step. After the final build/refresh, invoke +`Use $prepare-ra8p1-trace` with the +[repository skill](../.agents/skills/prepare-ra8p1-trace/SKILL.md), or copy the +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 ``` +Generate the trace runtime from the current ELF with the normal Trace Generation +view or bundled pyTS, then use Load & Debug. Repeat preparation after a subsequent +build/refresh or target change. SWO is captured to a file and converted automatically +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. A clean CI solution build -checks that the copy step works without a local debugger tools export. +workaround, clock baseline and hardware prerequisites. CI builds the firmware and +checks the explicit CMake copy separately; it does not require an AI agent. diff --git a/docs/DEBUG_PROBES.md b/docs/DEBUG_PROBES.md index 5ba2516..666d60a 100644 --- a/docs/DEBUG_PROBES.md +++ b/docs/DEBUG_PROBES.md @@ -71,12 +71,13 @@ see the [file naming table](TRACE_APP.md#configuration-ownership). ## EK-RA8P1 CPU0 debug description Use `EK-RA8P1@ULINKplus`, 10 MHz SWD, GDB port 3333 and 1 Mbaud SWO. -The target-specific `CopyRA8P1DebugDescription` solution-build step copies the -versioned CPU0/AP0 description using CMake. 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. - -After a standalone refresh or `--context` build, restore the description with the +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). +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. + +Repeat preparation after a later build, refresh or target change. Load/debug, RTX and automatic CSV on pause passed with the same CPU0 settings; capture-boundary errors remain in [Validation](VALIDATION.md#ek-ra8p1-cpu0--2026-11-17). diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 69ca562..3a75f1c 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -99,8 +99,9 @@ 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 -CMake copy step apply the run-description override workflow without changing -installed Packs or adding an interpreter dependency. See the [board layer](../Board/EK-RA8P1/README.md). +preparation skill with an explicit CMake 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). The [board inventory](BOARD_SUPPORT.md) records exact devices and Pack choices; [ThirdParty/README.md](../ThirdParty/README.md) records the imported source subset. diff --git a/docs/TRACE_APP.md b/docs/TRACE_APP.md index 3b38ee0..fd6d4b1 100644 --- a/docs/TRACE_APP.md +++ b/docs/TRACE_APP.md @@ -151,11 +151,12 @@ Their development status and source/release links are recorded there. watch and its writing-PC output as described above. Start the matching debugger configuration and inspect the resulting capture. -For EK-RA8P1, the solution build copies the versioned CPU0 debug description -using CMake. Trace generation then uses this description and the current ELF -through the same view or pyTS command as the other targets. After a standalone -refresh or `--context` build, restore the description with the command in the -[board procedure](../Board/EK-RA8P1/README.md#debug-and-trace-preparation). +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). +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. Equivalent offline generation with the bundled pyTS executable, for example: diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index 694612f..266811e 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -252,8 +252,9 @@ The initial Enter Debug attempt failed before attaching: the ordinary build replaced the prepared run description, removing CPU0/AP0 mapping. The adapter also generated an empty GDB port without a default port entry. The target now has a default GDB port and a versioned, CPU0-only `debug-run.yml` description -with literal-block sequence code. A target-specific, always-run CMake copy step -installs it after linking. Trace generation uses the normal view or bundled pyTS. +with literal-block sequence code. Apply it after build/refresh using the +preparation skill or explicit CMake command in the board procedure. +Trace generation uses the normal view or bundled pyTS. The description retains the debug topology and sequences used in the hardware checks below; no YAML serializer or additional interpreter is required. @@ -277,12 +278,15 @@ Load & Debug completed successfully. Repeated launch/reset and debug-end capture integrity remain to be checked. The reference project's 1-GHz ITM0 results do not apply to this reset-clock image. -**Interpreter-free preparation — 2026-11-17:** the normal CMSIS solution build -passed with the CMake copy step. The copied run description matches the versioned -template, and its CPU0 topology/sequences match the earlier hardware-tested -configuration. A fresh source snapshot in a path containing spaces passed the -`--target all` solution build without `.cmsis/tools-environment.yml` and with -an interpreter shim that rejects any Ruby invocation. The copied run description -matched the template byte for byte. Standard pyTS generated all six CPU0 trace -references; trace register operations matched the existing runtime. The current debug session could not read the core, and its server log reported -`No such device`; no new hardware capture is claimed for this preparation change. +**Skill/shell preparation — 2026-11-17:** a fresh source snapshot in a path +containing spaces passed the normal `cbuild --active EK-RA8P1@ULINKplus` build +without a custom build hook, `.cmsis/tools-environment.yml` or Ruby (a shim rejects +Ruby invocations). The build retained its ordinary generated run description. +The explicit CMake command then copied the versioned template byte for byte; +standard pyTS generated all six CPU0 trace references without missing symbols. +Trace register operations match the previously validated runtime, and the +template's CPU0 topology/sequences are unchanged. YAML, skill frontmatter, +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. From c8254fab5f9587b80ea651f963be4ec43eedbfd1 Mon Sep 17 00:00:00 2001 From: Thorsten de Buhr Date: Tue, 17 Nov 2026 16:05:11 +0100 Subject: [PATCH 5/5] Clarify RA8P1 skill and shell preparation in README --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4a8d83f..a34e1f2 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,11 @@ Capture-start and pause/end recording issues remain; see [Validation](docs/VALID | [STM32F4-DISCO](Board/STM32F4-DISCO/README.md), MB997 B-02 | Cortex-M4 | `ULINKplus`, `STLink` | | [EK-RA8P1](Board/EK-RA8P1/README.md) | Cortex-M85 CPU0, TrustZone build off | `ULINKplus` | -EK-RA8P1 needs an explicit [CPU0 debug preparation](Board/EK-RA8P1/README.md#debug-and-trace-preparation) -after build/refresh, using a repository skill or the documented shell command. +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 +hook or extra interpreter. SWO uses the standard automatic CSV workflow. Hardware results and open capture issues are listed in [Validation](docs/VALIDATION.md). This project currently implements SWO;