Skip to content

A1248924 mirror input - #160

Open
a1248924 wants to merge 2 commits into
mainfrom
a1248924_mirror_input
Open

a1248924 wants to merge 2 commits into
mainfrom
a1248924_mirror_input

Conversation

@a1248924

@a1248924 a1248924 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

signed off by Ayushman a-ayushman@ti.com
@qodo-code-review

qodo-code-review Bot commented Aug 5, 2026

Copy link
Copy Markdown

PR Summary by Qodo

Add AM263Px input mirroring and AM243x PRU eQEP examples

✨ Enhancement 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Adds deterministic AM263Px PRU input mirroring with measured 30 ns latency.
• Adds six-channel AM243x PRU quadrature decoding, speed, position, and phase diagnostics.
• Provides firmware, FreeRTOS hosts, build configurations, and hardware validation guidance.
Diagram

graph TD
  ENC["Encoder A/B"] --> CORES["Six PRU cores"] --> DMEM["Timestamp buffers"] --> R5["R5F diagnostics"] --> UART["UART status"]
  EPWM["EPWM edge"] --> MIRROR["Mirror PRU"] --> ICL["ICL output"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Split examples into separate PRs
  • ➕ Keeps unrelated AM263Px and AM243x features independently reviewable
  • ➕ Allows hardware validation and release decisions per example
  • ➕ Reduces the configuration volume reviewers must assess at once
  • ➖ Requires coordinating two integrations
  • ➖ Duplicates some repository-level review and CI work
2. Use hardware eQEP peripherals
  • ➕ Uses a dedicated peripheral with established position and capture semantics
  • ➕ Reduces custom assembly and shared-memory maintenance
  • ➖ Does not provide the same six-channel scalability on available hardware
  • ➖ Offers less flexibility for custom diagnostics and channel mapping
3. Use R5F interrupt-driven consumption
  • ➕ Avoids continuous polling and lowers host CPU usage
  • ➕ Processes channel updates close to PRU notification time
  • ➖ Adds six interrupt contexts and ISR synchronization complexity
  • ➖ Makes debugging and cross-channel processing less deterministic

Recommendation: Split the two examples into separate PRs because they target different SoCs and have independent firmware, host, build, and documentation stacks. Within the eQEP example, the six-core PRU implementation and polling host are reasonable for channel scalability and debugging simplicity; hardware eQEP or interrupt consumption should be selected only when channel count or R5F utilization requirements differ.

Files changed (60) +5466 / -1

Enhancement (9) +1450 / -0
main.asmImplement edge-triggered input mirroring +62/-0

Implement edge-triggered input mirroring

• Waits for each EPWM transition, samples CMP GPI0, and drives its state onto GPO1 with a constant instruction path.

examples/mirror_input/firmware/main.asm

main.cAdd the mirror FreeRTOS entry point +84/-0

Add the mirror FreeRTOS entry point

• Initializes the system and board, creates the static main task, and invokes the example loader.

examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/main.c

empty_example.cLoad and start mirror PRU firmware +100/-0

Load and start mirror PRU firmware

• Opens board and PRUICSS drivers, initializes PRU memories, loads PRU0 firmware, and keeps the host task alive.

examples/mirror_input/mcuplus/empty_example.c

macros.incAdd PRU cycle-counter helpers +54/-0

Add PRU cycle-counter helpers

• Defines assembly macros to enable, reset, and read core-local cycle counters for timestamp capture.

examples/pru_eqep/firmware/include/macros.inc

memory.incDefine six-channel eQEP memory and pin mappings +177/-0

Define six-channel eQEP memory and pin mappings

• Assigns registers, GPI masks, per-core channel buffers, shared-state offsets, interrupt events, and phase-error counters.

examples/pru_eqep/firmware/include/memory.inc

main.asmImplement PRU quadrature decoding +180/-0

Implement PRU quadrature decoding

• Polls A/B/Z edges, captures timestamps, updates circular buffers and position through a transition LUT, and records invalid phase transitions.

examples/pru_eqep/firmware/main.asm

main.cAdd the eQEP FreeRTOS entry point +84/-0

Add the eQEP FreeRTOS entry point

• Initializes the platform, starts a static high-priority task, and invokes the PRU eQEP application.

examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/main.c

eqep_diagnostic.hDefine eQEP channel diagnostic state +145/-0

Define eQEP channel diagnostic state

• Adds transition states and per-channel handles for buffers, timestamps, position, direction, speed, and phase-error tracking.

examples/pru_eqep/mcuplus/eqep_diagnostic.h

pru_eqep_example.cImplement the six-channel R5F eQEP host +564/-0

Implement the six-channel R5F eQEP host

• Loads all six firmware images, enables TX_PRU load sharing, initializes the transition LUT, polls shared channel state, and reports speed, position, direction, and phase errors. Position direction uses wrap-safe signed differences, while speed processing is threshold-gated.

examples/pru_eqep/mcuplus/pru_eqep_example.c

Documentation (7) +402 / -0
TIMING_ANALYSIS.mdDocument mirror-path timing +92/-0

Document mirror-path timing

• Explains the fixed three-cycle firmware path and attributes the measured 30 ns latency between firmware and hardware delays.

examples/mirror_input/TIMING_ANALYSIS.md

flow_diagram_mirror_input.pngAdd the mirror firmware flow image +0/-0

Add the mirror firmware flow image

• Provides the rendered control-flow diagram referenced by the timing analysis.

examples/mirror_input/images/flow_diagram_mirror_input.png

mirror_input_flow.drawioAdd editable mirror flow diagram +90/-0

Add editable mirror flow diagram

• Defines the startup, EPWM waits, CMP decisions, output writes, and repeating loop.

examples/mirror_input/images/mirror_input_flow.drawio

time_diff_between_signals.pngAdd mirror latency capture +0/-0

Add mirror latency capture

• Provides the logic-analyzer capture supporting the documented 30 ns edge-to-output measurement.

examples/mirror_input/images/time_diff_between_signals.png

readme.mdDocument the mirror input example +30/-0

Document the mirror input example

• Introduces the example, supported-platform guidance, and basic build and debug references.

examples/mirror_input/readme.md

A_B_signal.pngAdd quadrature signal capture +0/-0

Add quadrature signal capture

• Shows the validated A/B waveform and phase relationship used during hardware testing.

examples/pru_eqep/images/A_B_signal.png

readme.mdDocument eQEP validation and operation +190/-0

Document eQEP validation and operation

• Describes hardware validation, wiring, architecture, firmware and host flows, pin assignments, diagnostics, known limitations, and configuration procedures.

examples/pru_eqep/readme.md

Other (44) +3614 / -1
makefileRegister the PRU eQEP example +1/-1

Register the PRU eQEP example

• Adds 'pru_eqep' to the top-level example build list.

examples/makefile

example.projectspecDefine the AM263Px mirror firmware CCS project +82/-0

Define the AM263Px mirror firmware CCS project

• Configures the PRU0 assembly project, compiler settings, source imports, and firmware-header generation.

examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec

linker.cmdMap AM263Px PRU0 firmware memory +43/-0

Map AM263Px PRU0 firmware memory

• Defines PRU instruction, local data, peer data, and shared-memory regions for the mirror firmware.

examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd

makefileBuild the AM263Px mirror firmware +48/-0

Build the AM263Px mirror firmware

• Adds PRU-CGT settings and generated-header output rules for the PRU0 mirror image.

examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile

makefile_projectspecAutomate mirror firmware CCS projects +16/-0

Automate mirror firmware CCS projects

• Adds CCS project export, build, and clean commands.

examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile_projectspec

pru0_load_bin.hEmbed the mirror PRU0 firmware image +14/-0

Embed the mirror PRU0 firmware image

• Provides the generated PRU instruction array consumed by the R5F loader.

examples/mirror_input/firmware/pru0_load_bin.h

makefileOrchestrate mirror firmware and host builds +179/-0

Orchestrate mirror firmware and host builds

• Adds device checks and PRU-before-host build targets, including the AM263Px LaunchPad projects used by this example.

examples/mirror_input/makefile

example.syscfgConfigure AM263Px mirror peripherals and pinmux +366/-0

Configure AM263Px mirror peripherals and pinmux

• Configures PRUICSS, GPI/GPO pins, board support, UART logging, MPU regions, and linker memory for the R5F host.

examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/example.syscfg

example.projectspecDefine the mirror R5F CCS project +116/-0

Define the mirror R5F CCS project

• Configures the AM263Px FreeRTOS project, SysConfig integration, PRU firmware include path, libraries, and boot-image generation.

examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec

makefileBuild and package the mirror R5F application +352/-0

Build and package the mirror R5F application

• Adds compilation, SysConfig generation, linking, coverage, multicore ELF packaging, and secure-image signing rules.

examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile

makefile_ccs_bootimage_genGenerate mirror boot images from CCS +112/-0

Generate mirror boot images from CCS

• Creates and optionally signs the AM263Px multicore ELF image after a CCS build.

examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen

makefile_projectspecAutomate mirror R5F CCS projects +16/-0

Automate mirror R5F CCS projects

• Adds CCS export, build, and clean targets for the host project.

examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec

syscfg_c.rov.xsEnable FreeRTOS runtime inspection +12/-0

Enable FreeRTOS runtime inspection

• Registers the FreeRTOS Runtime Object View scripts for CCS and Theia.

examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs

example.projectspecDefine the PRU0 eQEP CCS project +84/-0

Define the PRU0 eQEP CCS project

• Targets ICSSG PRU0 and generates its firmware header from the shared eQEP assembly.

examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/example.projectspec

linker.cmdMap PRU0 eQEP firmware memory +52/-0

Map PRU0 eQEP firmware memory

• Allocates PRU0 instruction memory and its slice-local portion of ICSSG data RAM.

examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/linker.cmd

makefileBuild PRU0 eQEP firmware +48/-0

Build PRU0 eQEP firmware

• Configures PRU0 definitions, shared includes, and generated firmware-header output.

examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile

makefile_projectspecAutomate the PRU0 eQEP CCS project +16/-0

Automate the PRU0 eQEP CCS project

• Adds project export, build, and clean commands for PRU0.

examples/pru_eqep/firmware/am243x-lp/icss_g0_pru0_fw/ti-pru-cgt/makefile_projectspec

example.projectspecDefine the PRU1 eQEP CCS project +84/-0

Define the PRU1 eQEP CCS project

• Targets ICSSG PRU1 and generates its core-specific firmware header.

examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/example.projectspec

linker.cmdMap PRU1 eQEP firmware memory +52/-0

Map PRU1 eQEP firmware memory

• Allocates PRU1 instruction memory and the slice-one data-memory layout.

examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/linker.cmd

makefileBuild PRU1 eQEP firmware +49/-0

Build PRU1 eQEP firmware

• Configures PRU1 definitions, shared includes, and generated firmware-header output.

examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile

makefile_projectspecAutomate the PRU1 eQEP CCS project +16/-0

Automate the PRU1 eQEP CCS project

• Adds project export, build, and clean commands for PRU1.

examples/pru_eqep/firmware/am243x-lp/icss_g0_pru1_fw/ti-pru-cgt/makefile_projectspec

example.projectspecDefine the RTU_PRU0 eQEP CCS project +84/-0

Define the RTU_PRU0 eQEP CCS project

• Targets slice-zero RTU_PRU and emits its embedded firmware header.

examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/example.projectspec

linker.cmdMap RTU_PRU0 eQEP firmware memory +52/-0

Map RTU_PRU0 eQEP firmware memory

• Allocates RTU instruction memory and the RTU0 partition of slice-zero data RAM.

examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/linker.cmd

makefileBuild RTU_PRU0 eQEP firmware +49/-0

Build RTU_PRU0 eQEP firmware

• Configures RTU_PRU0 definitions, shared includes, and generated-header output.

examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/makefile

makefile_projectspecAutomate the RTU_PRU0 CCS project +16/-0

Automate the RTU_PRU0 CCS project

• Adds project export, build, and clean commands for RTU_PRU0.

examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru0_fw/ti-pru-cgt/makefile_projectspec

example.projectspecDefine the RTU_PRU1 eQEP CCS project +84/-0

Define the RTU_PRU1 eQEP CCS project

• Targets slice-one RTU_PRU and emits its embedded firmware header.

examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/example.projectspec

linker.cmdMap RTU_PRU1 eQEP firmware memory +52/-0

Map RTU_PRU1 eQEP firmware memory

• Allocates RTU instruction memory and the RTU1 partition of slice-one data RAM.

examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/linker.cmd

makefileBuild RTU_PRU1 eQEP firmware +49/-0

Build RTU_PRU1 eQEP firmware

• Configures RTU_PRU1 definitions, shared includes, and generated-header output.

examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/makefile

makefile_projectspecAutomate the RTU_PRU1 CCS project +16/-0

Automate the RTU_PRU1 CCS project

• Adds project export, build, and clean commands for RTU_PRU1.

examples/pru_eqep/firmware/am243x-lp/icss_g0_rtu_pru1_fw/ti-pru-cgt/makefile_projectspec

example.projectspecDefine the TX_PRU0 eQEP CCS project +84/-0

Define the TX_PRU0 eQEP CCS project

• Targets slice-zero TX_PRU and emits its embedded firmware header.

examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/example.projectspec

linker.cmdMap TX_PRU0 eQEP firmware memory +52/-0

Map TX_PRU0 eQEP firmware memory

• Allocates TX_PRU instruction memory and its load-shared slice-zero data partition.

examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/linker.cmd

makefileBuild TX_PRU0 eQEP firmware +49/-0

Build TX_PRU0 eQEP firmware

• Configures TX_PRU0 definitions, shared includes, and generated-header output.

examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/makefile

makefile_projectspecAutomate the TX_PRU0 CCS project +16/-0

Automate the TX_PRU0 CCS project

• Adds project export, build, and clean commands for TX_PRU0.

examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru0_fw/ti-pru-cgt/makefile_projectspec

example.projectspecDefine the TX_PRU1 eQEP CCS project +84/-0

Define the TX_PRU1 eQEP CCS project

• Targets slice-one TX_PRU and emits its embedded firmware header.

examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/example.projectspec

linker.cmdMap TX_PRU1 eQEP firmware memory +52/-0

Map TX_PRU1 eQEP firmware memory

• Allocates TX_PRU instruction memory and its load-shared slice-one data partition.

examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/linker.cmd

makefileBuild TX_PRU1 eQEP firmware +49/-0

Build TX_PRU1 eQEP firmware

• Configures TX_PRU1 definitions, shared includes, and generated-header output.

examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/makefile

makefile_projectspecAutomate the TX_PRU1 CCS project +16/-0

Automate the TX_PRU1 CCS project

• Adds project export, build, and clean commands for TX_PRU1.

examples/pru_eqep/firmware/am243x-lp/icss_g0_tx_pru1_fw/ti-pru-cgt/makefile_projectspec

makefileOrchestrate six eQEP firmware builds +110/-0

Orchestrate six eQEP firmware builds

• Builds all PRU, RTU_PRU, and TX_PRU images before the AM243x FreeRTOS host application.

examples/pru_eqep/makefile

example.syscfgConfigure AM243x eQEP resources +323/-0

Configure AM243x eQEP resources

• Sets ICSSG clocks, six-channel GPI pinmux, interrupt mappings, UART logging, MPU regions, and R5F linker memory.

examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/example.syscfg

example.projectspecDefine the eQEP R5F CCS project +123/-0

Define the eQEP R5F CCS project

• Configures the AM243x FreeRTOS host with six generated firmware dependencies, SysConfig, libraries, and boot-image generation.

examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec

makefileBuild and package the eQEP host +355/-0

Build and package the eQEP host

• Adds host compilation, SysConfig generation, linking, coverage, OptiShare, boot-image conversion, XIP generation, and signing rules.

examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile

makefile_ccs_bootimage_genGenerate eQEP boot images from CCS +113/-0

Generate eQEP boot images from CCS

• Converts the host ELF into RPRC and appimage outputs with XIP and secure-device signing support.

examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen

makefile_projectspecAutomate the eQEP R5F CCS project +16/-0

Automate the eQEP R5F CCS project

• Adds CCS project export, build, and clean commands for the host.

examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec

syscfg_c.rov.xsEnable eQEP FreeRTOS runtime inspection +12/-0

Enable eQEP FreeRTOS runtime inspection

• Registers the FreeRTOS Runtime Object View scripts for CCS and Theia.

examples/pru_eqep/mcuplus/am243x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs

@qodo-code-review

qodo-code-review Bot commented Aug 5, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (9) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Input changes are not mirrored live 🐞 Bug ≡ Correctness
Description
main waits for each EPWM edge before reading CMP_SIGNAL and updating ICL_SIGNAL, then blocks
waiting for the opposite edge. When the comparator input changes while EPWM remains at one level,
the output retains its previous value until the next transition, contrary to the example's stated
input-mirroring behavior.
Code

examples/mirror_input/firmware/main.asm[R43-45]

+    wbs r31, EPWM_SIGNAL
+    ; move CMP input to ICL output 
+    qbbs bit_set0, r31,CMP_SIGNAL
Evidence
The README states that the example mirrors input signals to an output pin, while wbs and wbc
block execution until EPWM transitions and the comparator is read only after each wait. Thus
comparator changes between those transitions cannot reach the output.

examples/mirror_input/readme.md[3-5]
examples/mirror_input/firmware/main.asm[41-62]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PRU firmware samples the comparator input only once per EPWM edge, so changes occurring between EPWM transitions are not propagated to the output.

## Fix Focus Areas
- examples/mirror_input/firmware/main.asm[41-62]

## Recommended Fix
Replace the EPWM-edge-blocking control flow with a continuous loop that reads `CMP_SIGNAL` and immediately sets or clears `ICL_SIGNAL`. If EPWM-gated sampling is actually required, rename and document the example as an edge-sampling example instead of describing it as live input mirroring.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Wrong wrap-around branch 🐞 Bug ≡ Correctness
Description
In examples/pru_eqep/firmware/main.asm, the pre-write wrap check branches to write_in_bounds
only when buffer_addr > buffer_size, so in-bounds values reset to 0 and the ring buffer
effectively never advances (overwriting the first entry repeatedly).
Code

examples/pru_eqep/firmware/main.asm[R103-106]

+    ; Handle buffer wrap-around before writing, so buffer_addr stays in bounds
+    qbgt    write_in_bounds, buffer_addr, buffer_size
+    ldi     buffer_addr, 0
+    ldi     READ_POS_BUFF, 0
Evidence
The code comment says it is keeping buffer_addr in bounds, but the `qbgt write_in_bounds,
buffer_addr, buffer_size makes the reset path execute for all buffer_addr` values that are not
strictly greater than buffer_size, preventing normal pointer progression.

examples/pru_eqep/firmware/main.asm[103-112]
examples/pru_eqep/firmware/include/memory.inc[41-44]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The ring-buffer bounds checks around `buffer_addr` are inverted. The code currently resets `buffer_addr`/`READ_POS_BUFF` when `buffer_addr <= buffer_size` and proceeds to write when `buffer_addr > buffer_size`, which defeats the intent of keeping writes in-bounds.

### Issue Context
This logic sits directly before the `sbbo` timestamp write and `WRITE_PTR_OFFSET` update.

### Fix Focus Areas
- examples/pru_eqep/firmware/main.asm[103-112]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Broken mirror_input targets 🐞 Bug ≡ Correctness
Description
examples/mirror_input/makefile invokes PRU firmware subdirectories (e.g., am263px-lp pru1 and
am263px-cc) that are not provided by this example, so make for those targets will fail when it
hits the missing -C directories.
Code

examples/mirror_input/makefile[R134-137]

+	$(MAKE) -C firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU)
+	$(MAKE) -C firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU)
+# am263px-cc
+	$(MAKE) -C firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU)
Evidence
The mirror_input top-level makefile tries to build am263px pru1/cc firmware directories. However,
the only mirror_input firmware makefile added/configured is for am263px-lp PRU0 (it outputs
pru0_load_bin.h), and the MCU+ app only references PRU0 firmware—indicating the pru1/cc directories
are not part of this example, so the make -C calls will fail.

examples/mirror_input/makefile[132-138]
examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[4-10]
examples/mirror_input/mcuplus/empty_example.c[40-41]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`examples/mirror_input/makefile` defines build targets for multiple PRU cores/boards (e.g., am263px pru1, am263px-cc) that are not present in this example’s directory structure. This causes deterministic build failures when the `am263px` (and other listed) targets are selected.

### Issue Context
The example appears to only provide PRU0 firmware output (`pru0_load_bin.h`) and the MCU+ app only includes/loads PRU0 firmware.

### Fix Focus Areas
- examples/mirror_input/makefile[132-144]
- examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[4-10]
- examples/mirror_input/mcuplus/empty_example.c[40-41]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

4. Host-only builds cannot compile 🐞 Bug ≡ Correctness ⭐ New
Description
INCLUDES_common searches firmware/am263px-lp, but the only checked-in pru0_load_bin.h is in
the parent firmware directory. When make host is invoked on a clean checkout without first
generating the platform-specific header, compilation of empty_example.c stops at its firmware
include.
Code

examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile[72]

+	-I${OPEN_PRU_PATH}/examples/mirror_input/firmware/am263px-lp \
Evidence
The host source includes <pru0_load_bin.h>, and its makefile searches the platform directory. The
PRU makefile generates the header into that platform directory, but the repository currently
contains it only one directory higher; meanwhile, the top-level makefile explicitly exposes host
as an independent target.

examples/mirror_input/mcuplus/empty_example.c[40-40]
examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile[64-73]
examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[7-10]
examples/mirror_input/makefile[68-74]
examples/mirror_input/firmware/pru0_load_bin.h[1-14]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The host-only build searches for `pru0_load_bin.h` under `firmware/am263px-lp`, while the seed header is checked in under `firmware`. Consequently, the documented `make host` target cannot compile from a clean checkout unless a PRU build has already generated another copy.

## Fix Focus Areas
- examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile[72-72]
- examples/mirror_input/firmware/pru0_load_bin.h[1-14]
- examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[7-10]

## Recommended Fix
Place the checked-in seed firmware header in `examples/mirror_input/firmware/am263px-lp/pru0_load_bin.h`, matching both the host include path and `MCU_HEX_PATH`. Ensure subsequent PRU builds overwrite that same platform-specific header.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Users cannot find supported hardware 🐞 Bug ≡ Correctness
Description
The mirror-input README directs users to the repository-wide supported-processors table, but that
table has no entry for this project. This leaves the required AM263Px configuration undiscoverable
through the documented route even though the checked-in host and firmware builds are
AM263Px-specific.
Code

examples/mirror_input/readme.md[R9-11]

+Refer to open-pru/examples/readme.md > Supported processors per-project
+for the list of processors that support building this project, and information
+about porting this project to other processors.
Evidence
The referenced table contains project rows but omits mirror_input, while the new SysConfig, host
makefile, and PRU makefile explicitly target AM263Px.

examples/readme.md[80-93]
examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/example.syscfg[1-4]
examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile[75-78]
examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[18-20]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The mirror-input README refers users to the repository-wide supported-processors table, but that table has no mirror-input row. Users therefore cannot determine from the referenced documentation that the supplied project supports AM263Px.

## Fix Focus Areas
- examples/mirror_input/readme.md[9-11]
- examples/readme.md[80-93]

## Recommended Fix
Add `mirror_input` to the repository-wide supported-processors table with support matching the configurations actually provided, and make the local README clearly identify the currently supported AM263Px board configuration.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Copied stale PRU header 🐞 Bug ☼ Reliability
Description
The PRU CCS projectspec copies a checked-in pru0_load_bin.h into the PRU project, so CCS builds that
compile the R5F app without first rebuilding the PRU project can embed and load an outdated firmware
image. This makes PRU firmware changes appear ineffective and is inconsistent with the other
examples’ CCS workflow.
Code

examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[R75-78]

+        <file path="../../../main.asm" openOnCreation="false" excludeFromBuild="false" action="copy">
+        </file>
+        <file path="../../../pru0_load_bin.h" openOnCreation="false" excludeFromBuild="false" action="copy">
+        </file>
Evidence
The mirror_input PRU projectspec explicitly copies a pre-existing firmware header into the CCS
project, and that header contains a hardcoded instruction array. The reference empty example’s PRU
projectspec does not copy any load_bin header, demonstrating the intended workflow is to generate
the header via post-build in the workspace.

examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[74-80]
examples/mirror_input/firmware/pru0_load_bin.h[1-6]
examples/empty/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[74-78]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`example.projectspec` for the PRU firmware project copies a repository `pru0_load_bin.h` into the CCS project. This allows the downstream R5F project to compile against a fixed, checked-in firmware array when the PRU project (and its post-build header generation) hasn’t been run.

### Issue Context
Other examples (e.g. `examples/empty/...`) do **not** copy `*_load_bin.h` into the PRU project; they rely on the PRU build post-step to generate the header in the workspace.

### Fix Focus Areas
- examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[74-79]
- examples/mirror_input/firmware/pru0_load_bin.h[1-7]

### Suggested fix
- Remove the `<file ... pru0_load_bin.h ... action="copy">` entry from the PRU firmware `example.projectspec`.
- Prefer not to check in `examples/mirror_input/firmware/pru0_load_bin.h` at all; instead, let it be generated by the PRU build (matching the pattern used by `examples/empty`). If a placeholder is required, ensure the R5F project has an explicit build dependency on the PRU firmware project so the generated header is always produced before compiling the R5F sources.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View medium (2)
7. Unchecked PRUICSS handle 🐞 Bug ☼ Reliability
Description
examples/mirror_input/mcuplus/empty_example.c uses the result of PRUICSS_open() without checking
for NULL, so an open failure can cause subsequent PRUICSS_* calls to crash or assert inside the
driver. This new example should fail fast (assert/log/return) on a NULL handle to avoid
hard-to-debug startup failures.
Code

examples/mirror_input/mcuplus/empty_example.c[R69-72]

+     gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0);
+
+     status = PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRUICSS_PRU0));
+     DebugP_assert(status != 0);
Evidence
The new example assigns gPruIcss0Handle from PRUICSS_open() and uses it immediately without
validation. In contrast, another in-repo PRUICSS user explicitly checks for NULL and returns an
error, showing NULL is a handled/expected failure mode.

examples/mirror_input/mcuplus/empty_example.c[69-75]
examples/pru_emif/pru_emif_app/pruemif16.c[79-84]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`examples/mirror_input/mcuplus/empty_example.c` calls `PRUICSS_open(CONFIG_PRU_ICSS0)` and immediately uses the returned handle without validating it. If the open fails (returns NULL), later calls like `PRUICSS_initMemory()` / `PRUICSS_loadFirmware()` will operate on an invalid handle and can crash or assert.

### Issue Context
Other code in this repo treats a NULL return from `PRUICSS_open()` as a failure case and aborts initialization.

### Fix Focus Areas
- examples/mirror_input/mcuplus/empty_example.c[69-75]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. Placeholder README content 🐞 Bug ⚙ Maintainability
Description
examples/mirror_input/readme.md still uses the template title “Empty Project” and includes FIXME
placeholders in the validated HW/SW table, making the new example documentation
inaccurate/incomplete.
Code

examples/mirror_input/readme.md[R17-20]

+| Processor | Hardware   | Software                   |
+| --------- | ---------- | -------------------------- |
+| AM263Px   | FIXME       | FIXME                       |
+
Evidence
The README explicitly titles the project as “Empty Project” and the validation table contains
FIXME values, which do not match the example’s intent/name and leaves the document incomplete.

examples/mirror_input/readme.md[1-6]
examples/mirror_input/readme.md[17-20]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The mirror_input README appears to be copied from a template and still contains placeholder content (title and validation table).

### Issue Context
This is a new example; the README is the primary entry point for users.

### Fix Focus Areas
- examples/mirror_input/readme.md[1-5]
- examples/mirror_input/readme.md[17-20]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

9. Misleading PRU pin comments ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
In main.asm the comments describe mirroring “GPI01” to “GPO4”, but the code actually mirrors r31
bit0 to r30 bit1. This mismatch can lead users to wire/configure the wrong GPIOs when adapting the
example.
Code

examples/mirror_input/firmware/main.asm[R34-37]

+    ; check GPI01 and set/clear GPO4 based on it 
+    ; to change the input and output, we need to change the bit number used here 
+    ; example : to give input to GPI2 , in line use qbbs bit_set,r31,2 
+    ; example : to take output from GPI2, in line 45,48 use set/clr r30,r30,2
Evidence
The asm file’s comment states different pins than the r31/r30 bit indices used in the loop, while
SysConfig shows GPIO0/GPIO1 are the used PRU pins for this example.

examples/mirror_input/firmware/main.asm[33-45]
examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/example.syscfg[94-100]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The assembly comment block in `main.asm` references different GPIO bits than the instructions actually use.

### Issue Context
The implementation branches on `r31, 0` and sets/clears `r30, 1`. SysConfig enables/uses PRU0 GPIO0 and GPIO1, so the comments should match that mapping.

### Fix Focus Areas
- examples/mirror_input/firmware/main.asm[34-41]

### Suggested fix
Update the comments to reflect the actual mapping (input bit 0 / output bit 1), and optionally mention the corresponding PRU GPIO names (e.g., PR0_PRU0_GPIO0 -> PR0_PRU0_GPIO1) to reduce wiring/config mistakes.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


10. Wrong project name string 🐞 Bug ⚙ Maintainability
Description
examples/mirror_input/makefile sets PROJECT_NAME := empty, so build/clean messages and any
project-name-based checks refer to the wrong project. This is inconsistent with the rest of the
mirror_input project metadata and should be renamed to mirror_input.
Code

examples/mirror_input/makefile[R7-8]

+PROJECT_NAME := empty
+SUPPORTED_PROCESSORS := am243x am261x am263px am263x am62x am64x
Evidence
The mirror_input makefile declares the project as "empty", while the example’s firmware build
artifacts are named with the mirror_input prefix, demonstrating the mismatch.

examples/mirror_input/makefile[7-12]
examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[4-10]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The mirror_input top-level makefile declares `PROJECT_NAME := empty`, which is inconsistent with the example name and causes misleading build output.

### Issue Context
The PRU firmware makefile for this example uses `mirror_input_*` output naming, indicating the intended project name.

### Fix Focus Areas
- examples/mirror_input/makefile[7-8]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: ⚖️ Balanced: Comparison failure: full PR diff.

Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 2e08a95 ⚖️ Balanced

Results up to commit 0df4aed ⚖️ Balanced


🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Action required
1. Broken mirror_input targets 🐞 Bug ≡ Correctness
Description
examples/mirror_input/makefile invokes PRU firmware subdirectories (e.g., am263px-lp pru1 and
am263px-cc) that are not provided by this example, so make for those targets will fail when it
hits the missing -C directories.
Code

examples/mirror_input/makefile[R134-137]

+	$(MAKE) -C firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU)
+	$(MAKE) -C firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU)
+# am263px-cc
+	$(MAKE) -C firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU)
Evidence
The mirror_input top-level makefile tries to build am263px pru1/cc firmware directories. However,
the only mirror_input firmware makefile added/configured is for am263px-lp PRU0 (it outputs
pru0_load_bin.h), and the MCU+ app only references PRU0 firmware—indicating the pru1/cc directories
are not part of this example, so the make -C calls will fail.

examples/mirror_input/makefile[132-138]
examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[4-10]
examples/mirror_input/mcuplus/empty_example.c[40-41]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`examples/mirror_input/makefile` defines build targets for multiple PRU cores/boards (e.g., am263px pru1, am263px-cc) that are not present in this example’s directory structure. This causes deterministic build failures when the `am263px` (and other listed) targets are selected.

### Issue Context
The example appears to only provide PRU0 firmware output (`pru0_load_bin.h`) and the MCU+ app only includes/loads PRU0 firmware.

### Fix Focus Areas
- examples/mirror_input/makefile[132-144]
- examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[4-10]
- examples/mirror_input/mcuplus/empty_example.c[40-41]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Wrong wrap-around branch 🐞 Bug ≡ Correctness
Description
In examples/pru_eqep/firmware/main.asm, the pre-write wrap check branches to write_in_bounds
only when buffer_addr > buffer_size, so in-bounds values reset to 0 and the ring buffer
effectively never advances (overwriting the first entry repeatedly).
Code

examples/pru_eqep/firmware/main.asm[R103-106]

+    ; Handle buffer wrap-around before writing, so buffer_addr stays in bounds
+    qbgt    write_in_bounds, buffer_addr, buffer_size
+    ldi     buffer_addr, 0
+    ldi     READ_POS_BUFF, 0
Evidence
The code comment says it is keeping buffer_addr in bounds, but the `qbgt write_in_bounds,
buffer_addr, buffer_size makes the reset path execute for all buffer_addr` values that are not
strictly greater than buffer_size, preventing normal pointer progression.

examples/pru_eqep/firmware/main.asm[103-112]
examples/pru_eqep/firmware/include/memory.inc[41-44]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The ring-buffer bounds checks around `buffer_addr` are inverted. The code currently resets `buffer_addr`/`READ_POS_BUFF` when `buffer_addr <= buffer_size` and proceeds to write when `buffer_addr > buffer_size`, which defeats the intent of keeping writes in-bounds.

### Issue Context
This logic sits directly before the `sbbo` timestamp write and `WRITE_PTR_OFFSET` update.

### Fix Focus Areas
- examples/pru_eqep/firmware/main.asm[103-112]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
3. Placeholder README content 🐞 Bug ⚙ Maintainability
Description
examples/mirror_input/readme.md still uses the template title “Empty Project” and includes FIXME
placeholders in the validated HW/SW table, making the new example documentation
inaccurate/incomplete.
Code

examples/mirror_input/readme.md[R17-20]

+| Processor | Hardware   | Software                   |
+| --------- | ---------- | -------------------------- |
+| AM263Px   | FIXME       | FIXME                       |
+
Evidence
The README explicitly titles the project as “Empty Project” and the validation table contains
FIXME values, which do not match the example’s intent/name and leaves the document incomplete.

examples/mirror_input/readme.md[1-6]
examples/mirror_input/readme.md[17-20]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The mirror_input README appears to be copied from a template and still contains placeholder content (title and validation table).

### Issue Context
This is a new example; the README is the primary entry point for users.

### Fix Focus Areas
- examples/mirror_input/readme.md[1-5]
- examples/mirror_input/readme.md[17-20]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit ff14d4c ⚖️ Balanced


🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Unchecked PRUICSS handle 🐞 Bug ☼ Reliability
Description
examples/mirror_input/mcuplus/empty_example.c uses the result of PRUICSS_open() without checking
for NULL, so an open failure can cause subsequent PRUICSS_* calls to crash or assert inside the
driver. This new example should fail fast (assert/log/return) on a NULL handle to avoid
hard-to-debug startup failures.
Code

examples/mirror_input/mcuplus/empty_example.c[R69-72]

+     gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0);
+
+     status = PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRUICSS_PRU0));
+     DebugP_assert(status != 0);
Evidence
The new example assigns gPruIcss0Handle from PRUICSS_open() and uses it immediately without
validation. In contrast, another in-repo PRUICSS user explicitly checks for NULL and returns an
error, showing NULL is a handled/expected failure mode.

examples/mirror_input/mcuplus/empty_example.c[69-75]
examples/pru_emif/pru_emif_app/pruemif16.c[79-84]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`examples/mirror_input/mcuplus/empty_example.c` calls `PRUICSS_open(CONFIG_PRU_ICSS0)` and immediately uses the returned handle without validating it. If the open fails (returns NULL), later calls like `PRUICSS_initMemory()` / `PRUICSS_loadFirmware()` will operate on an invalid handle and can crash or assert.

### Issue Context
Other code in this repo treats a NULL return from `PRUICSS_open()` as a failure case and aborts initialization.

### Fix Focus Areas
- examples/mirror_input/mcuplus/empty_example.c[69-75]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational
2. Wrong project name string 🐞 Bug ⚙ Maintainability
Description
examples/mirror_input/makefile sets PROJECT_NAME := empty, so build/clean messages and any
project-name-based checks refer to the wrong project. This is inconsistent with the rest of the
mirror_input project metadata and should be renamed to mirror_input.
Code

examples/mirror_input/makefile[R7-8]

+PROJECT_NAME := empty
+SUPPORTED_PROCESSORS := am243x am261x am263px am263x am62x am64x
Evidence
The mirror_input makefile declares the project as "empty", while the example’s firmware build
artifacts are named with the mirror_input prefix, demonstrating the mismatch.

examples/mirror_input/makefile[7-12]
examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[4-10]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The mirror_input top-level makefile declares `PROJECT_NAME := empty`, which is inconsistent with the example name and causes misleading build output.

### Issue Context
The PRU firmware makefile for this example uses `mirror_input_*` output naming, indicating the intended project name.

### Fix Focus Areas
- examples/mirror_input/makefile[7-8]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit d93c48d ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Copied stale PRU header 🐞 Bug ☼ Reliability
Description
The PRU CCS projectspec copies a checked-in pru0_load_bin.h into the PRU project, so CCS builds that
compile the R5F app without first rebuilding the PRU project can embed and load an outdated firmware
image. This makes PRU firmware changes appear ineffective and is inconsistent with the other
examples’ CCS workflow.
Code

examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[R75-78]

+        <file path="../../../main.asm" openOnCreation="false" excludeFromBuild="false" action="copy">
+        </file>
+        <file path="../../../pru0_load_bin.h" openOnCreation="false" excludeFromBuild="false" action="copy">
+        </file>
Evidence
The mirror_input PRU projectspec explicitly copies a pre-existing firmware header into the CCS
project, and that header contains a hardcoded instruction array. The reference empty example’s PRU
projectspec does not copy any load_bin header, demonstrating the intended workflow is to generate
the header via post-build in the workspace.

examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[74-80]
examples/mirror_input/firmware/pru0_load_bin.h[1-6]
examples/empty/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[74-78]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`example.projectspec` for the PRU firmware project copies a repository `pru0_load_bin.h` into the CCS project. This allows the downstream R5F project to compile against a fixed, checked-in firmware array when the PRU project (and its post-build header generation) hasn’t been run.

### Issue Context
Other examples (e.g. `examples/empty/...`) do **not** copy `*_load_bin.h` into the PRU project; they rely on the PRU build post-step to generate the header in the workspace.

### Fix Focus Areas
- examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[74-79]
- examples/mirror_input/firmware/pru0_load_bin.h[1-7]

### Suggested fix
- Remove the `<file ... pru0_load_bin.h ... action="copy">` entry from the PRU firmware `example.projectspec`.
- Prefer not to check in `examples/mirror_input/firmware/pru0_load_bin.h` at all; instead, let it be generated by the PRU build (matching the pattern used by `examples/empty`). If a placeholder is required, ensure the R5F project has an explicit build dependency on the PRU firmware project so the generated header is always produced before compiling the R5F sources.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational
2. Misleading PRU pin comments ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
In main.asm the comments describe mirroring “GPI01” to “GPO4”, but the code actually mirrors r31
bit0 to r30 bit1. This mismatch can lead users to wire/configure the wrong GPIOs when adapting the
example.
Code

examples/mirror_input/firmware/main.asm[R34-37]

+    ; check GPI01 and set/clear GPO4 based on it 
+    ; to change the input and output, we need to change the bit number used here 
+    ; example : to give input to GPI2 , in line use qbbs bit_set,r31,2 
+    ; example : to take output from GPI2, in line 45,48 use set/clr r30,r30,2
Evidence
The asm file’s comment states different pins than the r31/r30 bit indices used in the loop, while
SysConfig shows GPIO0/GPIO1 are the used PRU pins for this example.

examples/mirror_input/firmware/main.asm[33-45]
examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/example.syscfg[94-100]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The assembly comment block in `main.asm` references different GPIO bits than the instructions actually use.

### Issue Context
The implementation branches on `r31, 0` and sets/clears `r30, 1`. SysConfig enables/uses PRU0 GPIO0 and GPIO1, so the comments should match that mapping.

### Fix Focus Areas
- examples/mirror_input/firmware/main.asm[34-41]

### Suggested fix
Update the comments to reflect the actual mapping (input bit 0 / output bit 1), and optionally mention the corresponding PRU GPIO names (e.g., PR0_PRU0_GPIO0 -> PR0_PRU0_GPIO1) to reduce wiring/config mistakes.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit 46898dd ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Action required
1. Input changes are not mirrored live 🐞 Bug ≡ Correctness
Description
main waits for each EPWM edge before reading CMP_SIGNAL and updating ICL_SIGNAL, then blocks
waiting for the opposite edge. When the comparator input changes while EPWM remains at one level,
the output retains its previous value until the next transition, contrary to the example's stated
input-mirroring behavior.
Code

examples/mirror_input/firmware/main.asm[R43-45]

+    wbs r31, EPWM_SIGNAL
+    ; move CMP input to ICL output 
+    qbbs bit_set0, r31,CMP_SIGNAL
Evidence
The README states that the example mirrors input signals to an output pin, while wbs and wbc
block execution until EPWM transitions and the comparator is read only after each wait. Thus
comparator changes between those transitions cannot reach the output.

examples/mirror_input/readme.md[3-5]
examples/mirror_input/firmware/main.asm[41-62]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PRU firmware samples the comparator input only once per EPWM edge, so changes occurring between EPWM transitions are not propagated to the output.

## Fix Focus Areas
- examples/mirror_input/firmware/main.asm[41-62]

## Recommended Fix
Replace the EPWM-edge-blocking control flow with a continuous loop that reads `CMP_SIGNAL` and immediately sets or clears `ICL_SIGNAL`. If EPWM-gated sampling is actually required, rename and document the example as an edge-sampling example instead of describing it as live input mirroring.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit 854597b ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Users cannot find supported hardware 🐞 Bug ≡ Correctness
Description
The mirror-input README directs users to the repository-wide supported-processors table, but that
table has no entry for this project. This leaves the required AM263Px configuration undiscoverable
through the documented route even though the checked-in host and firmware builds are
AM263Px-specific.
Code

examples/mirror_input/readme.md[R9-11]

+Refer to open-pru/examples/readme.md > Supported processors per-project
+for the list of processors that support building this project, and information
+about porting this project to other processors.
Evidence
The referenced table contains project rows but omits mirror_input, while the new SysConfig, host
makefile, and PRU makefile explicitly target AM263Px.

examples/readme.md[80-93]
examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/example.syscfg[1-4]
examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile[75-78]
examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[18-20]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The mirror-input README refers users to the repository-wide supported-processors table, but that table has no mirror-input row. Users therefore cannot determine from the referenced documentation that the supplied project supports AM263Px.

## Fix Focus Areas
- examples/mirror_input/readme.md[9-11]
- examples/readme.md[80-93]

## Recommended Fix
Add `mirror_input` to the repository-wide supported-processors table with support matching the configurations actually provided, and make the local README clearly identify the currently supported AM263Px board configuration.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment on lines +134 to +137
$(MAKE) -C firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU)
$(MAKE) -C firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU)
# am263px-cc
$(MAKE) -C firmware/am263px-cc/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Broken mirror_input targets 🐞 Bug ≡ Correctness

examples/mirror_input/makefile invokes PRU firmware subdirectories (e.g., am263px-lp pru1 and
am263px-cc) that are not provided by this example, so make for those targets will fail when it
hits the missing -C directories.
Agent Prompt
### Issue description
`examples/mirror_input/makefile` defines build targets for multiple PRU cores/boards (e.g., am263px pru1, am263px-cc) that are not present in this example’s directory structure. This causes deterministic build failures when the `am263px` (and other listed) targets are selected.

### Issue Context
The example appears to only provide PRU0 firmware output (`pru0_load_bin.h`) and the MCU+ app only includes/loads PRU0 firmware.

### Fix Focus Areas
- examples/mirror_input/makefile[132-144]
- examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[4-10]
- examples/mirror_input/mcuplus/empty_example.c[40-41]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +103 to +106
; Handle buffer wrap-around before writing, so buffer_addr stays in bounds
qbgt write_in_bounds, buffer_addr, buffer_size
ldi buffer_addr, 0
ldi READ_POS_BUFF, 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. Wrong wrap-around branch 🐞 Bug ≡ Correctness

In examples/pru_eqep/firmware/main.asm, the pre-write wrap check branches to write_in_bounds
only when buffer_addr > buffer_size, so in-bounds values reset to 0 and the ring buffer
effectively never advances (overwriting the first entry repeatedly).
Agent Prompt
### Issue description
The ring-buffer bounds checks around `buffer_addr` are inverted. The code currently resets `buffer_addr`/`READ_POS_BUFF` when `buffer_addr <= buffer_size` and proceeds to write when `buffer_addr > buffer_size`, which defeats the intent of keeping writes in-bounds.

### Issue Context
This logic sits directly before the `sbbo` timestamp write and `WRITE_PTR_OFFSET` update.

### Fix Focus Areas
- examples/pru_eqep/firmware/main.asm[103-112]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +17 to +20
| Processor | Hardware | Software |
| --------- | ---------- | -------------------------- |
| AM263Px | FIXME | FIXME |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

3. Placeholder readme content 🐞 Bug ⚙ Maintainability

examples/mirror_input/readme.md still uses the template title “Empty Project” and includes FIXME
placeholders in the validated HW/SW table, making the new example documentation
inaccurate/incomplete.
Agent Prompt
### Issue description
The mirror_input README appears to be copied from a template and still contains placeholder content (title and validation table).

### Issue Context
This is a new example; the README is the primary entry point for users.

### Fix Focus Areas
- examples/mirror_input/readme.md[1-5]
- examples/mirror_input/readme.md[17-20]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from 0df4aed to ff14d4c Compare August 7, 2026 05:48
Comment on lines +69 to +72
gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0);

status = PRUICSS_initMemory(gPruIcss0Handle, PRUICSS_DATARAM(PRUICSS_PRU0));
DebugP_assert(status != 0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Unchecked pruicss handle 🐞 Bug ☼ Reliability

examples/mirror_input/mcuplus/empty_example.c uses the result of PRUICSS_open() without checking
for NULL, so an open failure can cause subsequent PRUICSS_* calls to crash or assert inside the
driver. This new example should fail fast (assert/log/return) on a NULL handle to avoid
hard-to-debug startup failures.
Agent Prompt
### Issue description
`examples/mirror_input/mcuplus/empty_example.c` calls `PRUICSS_open(CONFIG_PRU_ICSS0)` and immediately uses the returned handle without validating it. If the open fails (returns NULL), later calls like `PRUICSS_initMemory()` / `PRUICSS_loadFirmware()` will operate on an invalid handle and can crash or assert.

### Issue Context
Other code in this repo treats a NULL return from `PRUICSS_open()` as a failure case and aborts initialization.

### Fix Focus Areas
- examples/mirror_input/mcuplus/empty_example.c[69-75]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +7 to +8
PROJECT_NAME := empty
SUPPORTED_PROCESSORS := am243x am261x am263px am263x am62x am64x

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational

2. Wrong project name string 🐞 Bug ⚙ Maintainability

examples/mirror_input/makefile sets PROJECT_NAME := empty, so build/clean messages and any
project-name-based checks refer to the wrong project. This is inconsistent with the rest of the
mirror_input project metadata and should be renamed to mirror_input.
Agent Prompt
### Issue description
The mirror_input top-level makefile declares `PROJECT_NAME := empty`, which is inconsistent with the example name and causes misleading build output.

### Issue Context
The PRU firmware makefile for this example uses `mirror_input_*` output naming, indicating the intended project name.

### Fix Focus Areas
- examples/mirror_input/makefile[7-8]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit ff14d4c

@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from ff14d4c to d93c48d Compare August 7, 2026 06:35
Comment on lines +75 to +78
<file path="../../../main.asm" openOnCreation="false" excludeFromBuild="false" action="copy">
</file>
<file path="../../../pru0_load_bin.h" openOnCreation="false" excludeFromBuild="false" action="copy">
</file>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Copied stale pru header 🐞 Bug ☼ Reliability

The PRU CCS projectspec copies a checked-in pru0_load_bin.h into the PRU project, so CCS builds that
compile the R5F app without first rebuilding the PRU project can embed and load an outdated firmware
image. This makes PRU firmware changes appear ineffective and is inconsistent with the other
examples’ CCS workflow.
Agent Prompt
### Issue description
`example.projectspec` for the PRU firmware project copies a repository `pru0_load_bin.h` into the CCS project. This allows the downstream R5F project to compile against a fixed, checked-in firmware array when the PRU project (and its post-build header generation) hasn’t been run.

### Issue Context
Other examples (e.g. `examples/empty/...`) do **not** copy `*_load_bin.h` into the PRU project; they rely on the PRU build post-step to generate the header in the workspace.

### Fix Focus Areas
- examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[74-79]
- examples/mirror_input/firmware/pru0_load_bin.h[1-7]

### Suggested fix
- Remove the `<file ... pru0_load_bin.h ... action="copy">` entry from the PRU firmware `example.projectspec`.
- Prefer not to check in `examples/mirror_input/firmware/pru0_load_bin.h` at all; instead, let it be generated by the PRU build (matching the pattern used by `examples/empty`). If a placeholder is required, ensure the R5F project has an explicit build dependency on the PRU firmware project so the generated header is always produced before compiling the R5F sources.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread examples/mirror_input/firmware/main.asm Outdated
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d93c48d

@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from d93c48d to 46898dd Compare September 10, 2026 13:41
Comment on lines +43 to +45
wbs r31, EPWM_SIGNAL
; move CMP input to ICL output
qbbs bit_set0, r31,CMP_SIGNAL

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Input changes are not mirrored live 🐞 Bug ≡ Correctness

main waits for each EPWM edge before reading CMP_SIGNAL and updating ICL_SIGNAL, then blocks
waiting for the opposite edge. When the comparator input changes while EPWM remains at one level,
the output retains its previous value until the next transition, contrary to the example's stated
input-mirroring behavior.
Agent Prompt
## Issue description
The PRU firmware samples the comparator input only once per EPWM edge, so changes occurring between EPWM transitions are not propagated to the output.

## Fix Focus Areas
- examples/mirror_input/firmware/main.asm[41-62]

## Recommended Fix
Replace the EPWM-edge-blocking control flow with a continuous loop that reads `CMP_SIGNAL` and immediately sets or clears `ICL_SIGNAL`. If EPWM-gated sampling is actually required, rename and document the example as an edge-sampling example instead of describing it as live input mirroring.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 46898dd

@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from 46898dd to 854597b Compare September 11, 2026 06:33
Comment on lines +9 to +11
Refer to open-pru/examples/readme.md > Supported processors per-project
for the list of processors that support building this project, and information
about porting this project to other processors.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

4. Users cannot find supported hardware 🐞 Bug ≡ Correctness

The mirror-input README directs users to the repository-wide supported-processors table, but that
table has no entry for this project. This leaves the required AM263Px configuration undiscoverable
through the documented route even though the checked-in host and firmware builds are
AM263Px-specific.
Agent Prompt
## Issue description
The mirror-input README refers users to the repository-wide supported-processors table, but that table has no mirror-input row. Users therefore cannot determine from the referenced documentation that the supplied project supports AM263Px.

## Fix Focus Areas
- examples/mirror_input/readme.md[9-11]
- examples/readme.md[80-93]

## Recommended Fix
Add `mirror_input` to the repository-wide supported-processors table with support matching the configurations actually provided, and make the local README clearly identify the currently supported AM263Px board configuration.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 854597b

signed off by: Ayushman  <a-ayushman@ti.com>
@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from 854597b to 2e08a95 Compare September 11, 2026 06:40
-I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/portable/TI_ARM_CLANG/ARM_CR5F \
-I${MCU_PLUS_SDK_PATH}/source/kernel/freertos/config/am263px/r5f \
-I${MCU_PLUS_SDK_PATH}/source/pru_io/driver \
-I${OPEN_PRU_PATH}/examples/mirror_input/firmware/am263px-lp \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

4. Host-only builds cannot compile 🐞 Bug ≡ Correctness

INCLUDES_common searches firmware/am263px-lp, but the only checked-in pru0_load_bin.h is in
the parent firmware directory. When make host is invoked on a clean checkout without first
generating the platform-specific header, compilation of empty_example.c stops at its firmware
include.
Agent Prompt
## Issue description
The host-only build searches for `pru0_load_bin.h` under `firmware/am263px-lp`, while the seed header is checked in under `firmware`. Consequently, the documented `make host` target cannot compile from a clean checkout unless a PRU build has already generated another copy.

## Fix Focus Areas
- examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile[72-72]
- examples/mirror_input/firmware/pru0_load_bin.h[1-14]
- examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[7-10]

## Recommended Fix
Place the checked-in seed firmware header in `examples/mirror_input/firmware/am263px-lp/pru0_load_bin.h`, matching both the host include path and `MCU_HEX_PATH`. Ensure subsequent PRU builds overwrite that same platform-specific header.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2e08a95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant