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.

@qodo-code-review

qodo-code-review Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Add mirror_input PRU example for AM263Px

✨ Enhancement ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Adds a new mirror_input example that copies a PRU GPI input (CMP) to a GPO output on each EPWM
 edge.
• Adds PRU0 assembly firmware, R5F FreeRTOS host app loading it via PRUICSS, and SysConfig pin/MPU
 setup.
• Adds CCS projectspecs, makefiles, readme with timing analysis, flow diagram, and registers the
 example in the examples index.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The PRU loop, GPIO configuration, R5F firmware loader, generated firmware header, and build/boot-image rules all contribute to one bounded outcome: mirroring CMP to ICL at EPWM transitions.
  • They are technical hops of one integration, not independent end-to-end capabilities.
Sources

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

main:
    ; check GPI00 and set/clear GPO1 based on it 
    ; EPWM signal is coming on GPI2
    ; clear r30 also so PRU0 GPO0 always starts at low 
    zero &r0,124
high_pulse:
    ; when EPWM becomes high, copy input -> output 
    wbs r31, EPWM_SIGNAL
    ; move CMP input to ICL output 
    qbbs bit_set0, r31,CMP_SIGNAL
bit_clear0:
    clr  r30, r30, ICL_SIGNAL
    qba  low_pulse

examples/mirror_input/firmware/main.asm[53-63]

low_pulse:
    ; when EPWM becomes low, again copy input -> output
    wbc r31, EPWM_SIGNAL
    ; move CMP input to ICL output 
    qbbs bit_set1, r31,CMP_SIGNAL
bit_clear1:
    clr  r30, r30, ICL_SIGNAL
    qba  high_pulse
bit_set1:
    set  r30, r30, ICL_SIGNAL
    qba high_pulse

examples/mirror_input/mcuplus/mirror_input_example.c[54-71]

void mirror_input_example_main(void *args)
{
     Drivers_open(); // check return status

     int status;
     status = Board_driversOpen();
     DebugP_assert(SystemP_SUCCESS == status);

     gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0);

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

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

     status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_PRU0, PRU0Firmware_0, sizeof(PRU0Firmware_0));
     DebugP_assert(SystemP_SUCCESS == status);
Behavioral complexity 🟡 Medium 🧩 Interacting branches

  • Before: the base repository had no mirror-input behavior in this example.
  • After: PRU0 alternates between EPWM-high and EPWM-low wait states, samples CMP in each state, and sets or clears ICL.
  • New correctness condition: both alternating states must preserve the same CMP-to-ICL mapping and return to the opposite wait state without skipping or duplicating an EPWM transition.
  • The branches are deterministic and small, but their repeated state interaction is material.
Sources

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

main:
    ; check GPI00 and set/clear GPO1 based on it 
    ; EPWM signal is coming on GPI2
    ; clear r30 also so PRU0 GPO0 always starts at low 
    zero &r0,124
high_pulse:
    ; when EPWM becomes high, copy input -> output 
    wbs r31, EPWM_SIGNAL
    ; move CMP input to ICL output 
    qbbs bit_set0, r31,CMP_SIGNAL
bit_clear0:
    clr  r30, r30, ICL_SIGNAL
    qba  low_pulse

examples/mirror_input/firmware/main.asm[53-63]

low_pulse:
    ; when EPWM becomes low, again copy input -> output
    wbc r31, EPWM_SIGNAL
    ; move CMP input to ICL output 
    qbbs bit_set1, r31,CMP_SIGNAL
bit_clear1:
    clr  r30, r30, ICL_SIGNAL
    qba  high_pulse
bit_set1:
    set  r30, r30, ICL_SIGNAL
    qba high_pulse
Potential damage 🟡 Medium 🩹 Incorrect results

  • If the firmware loop, pin mapping, build artifact, or host load path regresses, ICL may remain stale, reflect the wrong CMP sample, or fail to mirror the configured input.
  • The evidence shows no persistent application data or external service state; the impact is confined to this manually activated example signal path.
  • Correcting the source and rebuilding the PRU and R5F artifacts, then reloading the device, restores the intended future signal behavior.
  • Source rollback alone does not alter firmware already loaded on a device.
Sources

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

main:
    ; check GPI00 and set/clear GPO1 based on it 
    ; EPWM signal is coming on GPI2
    ; clear r30 also so PRU0 GPO0 always starts at low 
    zero &r0,124
high_pulse:
    ; when EPWM becomes high, copy input -> output 
    wbs r31, EPWM_SIGNAL
    ; move CMP input to ICL output 
    qbbs bit_set0, r31,CMP_SIGNAL
bit_clear0:
    clr  r30, r30, ICL_SIGNAL
    qba  low_pulse

examples/mirror_input/firmware/main.asm[53-63]

low_pulse:
    ; when EPWM becomes low, again copy input -> output
    wbc r31, EPWM_SIGNAL
    ; move CMP input to ICL output 
    qbbs bit_set1, r31,CMP_SIGNAL
bit_clear1:
    clr  r30, r30, ICL_SIGNAL
    qba  high_pulse
bit_set1:
    set  r30, r30, ICL_SIGNAL
    qba high_pulse

examples/mirror_input/mcuplus/mirror_input_example.c[54-71]

void mirror_input_example_main(void *args)
{
     Drivers_open(); // check return status

     int status;
     status = Board_driversOpen();
     DebugP_assert(SystemP_SUCCESS == status);

     gPruIcss0Handle = PRUICSS_open(CONFIG_PRU_ICSS0);

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

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

     status = PRUICSS_loadFirmware(gPruIcss0Handle, PRUICSS_PRU0, PRU0Firmware_0, sizeof(PRU0Firmware_0));
     DebugP_assert(SystemP_SUCCESS == status);

examples/mirror_input/makefile[60-74]

ifeq ($(BUILD_PROJECT),y)
# "make" or "make all" builds projects that match $(DEVICE) set in imports.mak
# "make" builds PRU firmware first, then host (non-PRU) code
all: MESSAGE = "Building $(PROJECT_NAME) for $(DEVICE)"
all: pre_build_message
	$(MAKE) pru
	$(MAKE) host

# "make pru" builds only PRU firmware for $(DEVICE)
pru: ARGUMENTS_PRU = all
pru: $(DEVICE)

# "make host" builds only host (non-PRU) code for $(DEVICE)
host: ARGUMENTS_MCUPLUS = all
host: $(DEVICE_NON_PRU)
Assessed commit c5a2e3d
Diagram

graph TD
    R5F["R5F host app"] -->|loads firmware image| PRU0["PRU0 firmware"]
    EPWM["EPWM on GPI2"] --> PRU0
    CMP["CMP on GPI0"] --> PRU0
    PRU0 --> ICL["ICL output on GPO1"]
Loading
High-Level Assessment

Keep the polling design (wbs/wbc on r31 followed by qbbs and set/clr). On PRU the single-issue core already gives the lowest-latency path, and an interrupt would add more cycles than it saves. Driving the output from the R5F instead would add far more latency than this approach. The readme should say the latency is edge-sampled and data-dependent, not constant, so the examples index entry matches the timing analysis.

Files changed (21) +1696 / -1

Enhancement (3) +240 / -0
main.asmPRU0 assembly that mirrors CMP to ICL on EPWM edges +63/-0

PRU0 assembly that mirrors CMP to ICL on EPWM edges

• Polls the EPWM input on GPI2 with wbs/wbc and, on each edge, sets or clears GPO1 based on the CMP input on GPI0. The core runs in a tight loop with no interrupts.

examples/mirror_input/firmware/main.asm

mirror_input_example.cR5F app that loads PRU0 firmware through PRUICSS +93/-0

R5F app that loads PRU0 firmware through PRUICSS

• Opens PRUICSS and initializes PRU0/PRU1 data RAM, loads the PRU0 firmware array from the generated header, and then idles in a loop. Some asserts appear inverted and cleanup after the loop is unreachable.

examples/mirror_input/mcuplus/mirror_input_example.c

main.cFreeRTOS main creates a static task that runs the example +84/-0

FreeRTOS main creates a static task that runs the example

• Initializes SoC and board, creates a static highest-priority task that calls mirror_input_example_main, and starts the scheduler. The header is copied from another example and still shows 2022-23 copyright.

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

Documentation (6) +227 / -0
readme.mdAdd mirror_input to examples index and support table +4/-0

Add mirror_input to examples index and support table

• Adds a one-line description of mirror_input and a supported-processor row for it in the examples readme table.

examples/readme.md

readme.mdReadme with overview, timing analysis, and run steps +133/-0

Readme with overview, timing analysis, and run steps

• Describes the edge-sampled mirror, the validated HW/SW versions, the instruction-level timing analysis, and the CCS steps to build and run. The 'constant latency' claim in the examples index conflicts with the data-dependent timing described here.

examples/mirror_input/readme.md

mirror_input_flow.drawioEditable flowchart of the PRU firmware loop +90/-0

Editable flowchart of the PRU firmware loop

• Draws the wait-for-EPWM, sample-CMP, and drive-ICL states for both edges as an editable diagram source.

examples/mirror_input/images/mirror_input_flow.drawio

flow_diagram_mirror_input.pngRendered firmware flow diagram +0/-0

Rendered firmware flow diagram

• Rendered PNG of the firmware flow, referenced from the readme. Binary asset, no text diff.

examples/mirror_input/images/flow_diagram_mirror_input.png

time_diff_between_signals.pngSaleae capture showing 30 ns EPWM-to-ICL delay +0/-0

Saleae capture showing 30 ns EPWM-to-ICL delay

• Measured waveform capture referenced from the readme timing section. Binary asset, no text diff.

examples/mirror_input/images/time_diff_between_signals.png

truth_table.pngTruth table for mirror logic +0/-0

Truth table for mirror logic

• Truth-table image referenced from the run steps in the readme. Binary asset, no text diff.

examples/mirror_input/images/truth_table.png

Other (12) +1229 / -1
makefileRegister mirror_input in examples SUBDIRS +1/-1

Register mirror_input in examples SUBDIRS

• Adds mirror_input to the SUBDIRS list so the top-level examples build includes it.

examples/makefile

linker.cmdPRU0 linker memory map for AM263Px +43/-0

PRU0 linker memory map for AM263Px

• Defines PRU instruction RAM, data RAM 0/1, and shared RAM regions, and places all sections into PRU0 data RAM.

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

makefilePRU0 build makefile using shared PRU rules +48/-0

PRU0 build makefile using shared PRU rules

• Sets the output name, source search paths, linker command file, and PRU version 3 settings, then includes pru_rules.mak. It also derives the hex header output path.

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

makefile_projectspecCCS project build/clean/export wrapper for PRU0 project +16/-0

CCS project build/clean/export wrapper for PRU0 project

• Wraps CCS headless build, clean, and project export commands for the PRU0 projectspec.

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

example.projectspecCCS projectspec for PRU0 assembly firmware +80/-0

CCS projectspec for PRU0 assembly firmware

• Defines the AM263Px PRU0 project with CGT 2.3.3, compiler and linker options, a postBuildStep that runs hexpru to produce pru0_load_bin.h, and copies main.asm and linker.cmd.

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

example.syscfgSysConfig for PRU-ICSS pins, UART log, I2C IO expander, and memory map +328/-0

SysConfig for PRU-ICSS pins, UART log, I2C IO expander, and memory map

• Configures PRU0 GPIO0/1/2 pins, the TCA6416 IO expander, UART log, MPU regions, and memory sections for the R5F and PRU shared buffers.

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

example.projectspecCCS projectspec for R5F FreeRTOS app with TI ARM Clang +116/-0

CCS projectspec for R5F FreeRTOS app with TI ARM Clang

• Defines the AM263Px R5F project with compiler, linker, and SysConfig options. Adds a post-build step that generates the boot image and copies the sources.

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

makefileAuto-generated R5F build makefile with SysConfig and boot image rules +352/-0

Auto-generated R5F build makefile with SysConfig and boot image rules

• Builds the R5F ELF from the generated SysConfig and app sources, and adds targets for MCELF and signed boot images and coverage. Its include path points to the PRU header directory.

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

makefile_ccs_bootimage_genCCS post-build makefile that generates MCELF and signed images +112/-0

CCS post-build makefile that generates MCELF and signed images

• Generates the multicore ELF from the built .out and signs it for HS devices when a secure build is used.

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

makefile_projectspecCCS project build/clean/export wrapper for R5F project +16/-0

CCS project build/clean/export wrapper for R5F project

• Wraps CCS headless build, clean, and project export commands for the R5F projectspec.

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

syscfg_c.rov.xsROV file list for FreeRTOS debug views +12/-0

ROV file list for FreeRTOS debug views

• Lists the FreeRTOS ROV and Theia files so the CCS runtime object viewer can read them.

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

makefileTop-level mirror_input makefile with prebuild checks +105/-0

Top-level mirror_input makefile with prebuild checks

• Gates the build on the device and MCU+ SDK dependency, then builds PRU firmware before host code. Maps am263px and am263px_mcuplus targets to their sub-makefiles.

examples/mirror_input/makefile

@qodo-code-review

qodo-code-review Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Code Review by Qodo


View medium (9)
Remediation recommended
1. PRU timing-critical loop lacks a worst-case cycle comment 📘
Description
The labels high_pulse, low_pulse and the bit_set/bit_clear branch targets in main.asm
implement a timing-critical edge-to-output mirror, yet none has an adjacent WCET or peak-cycle
comment; the only timing analysis lives in readme.md, away from the code. Because the mirror path
differs between the bit_set and bit_clear branches, a later change to either path (for example
adding an instruction) can silently invalidate the documented latency with nothing in the assembly
to update.
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 `main.asm` has labeled, timing-critical blocks (`main`, `high_pulse`, `low_pulse`, `bit_set*`, `bit_clear*`) with no adjacent worst-case execution time comment. The only timing analysis is in `readme.md`, which is not next to the code and can drift out of sync with the assembly.

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

## Recommended Fix
Above `high_pulse:` and `low_pulse:` add a comment block such as `; WCET: N cycles @200MHz (N * 5 ns)` that states the worst-case cycle count per branch path (the `bit_set` and `bit_clear` paths differ in instruction count) and the assumptions used, and note that the readme timing section must be updated together with any change to these blocks.

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

Dismiss ↗ | View ↗

2. Config pads assignments with space runs 📘
Description
The pruicss1 PRU-ICSS settings are aligned with long runs of spaces before the = sign, for
example pruicss1.$name followed by dozens of spaces, and the same padding appears on the PruGPIO
lines. The whitespace rule permits only single spaces in non-markdown source, so every aligned line
in the added block violates it. The file is SysConfig-generated, which explains the padding, but the
rule has no generated-file exemption, and any later hand edit that copies this style propagates the
padding.
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 new `example.syscfg` assigns PRU-ICSS settings with long runs of alignment spaces before `=`, which violates the rule that source files use only single spaces.

Fix Focus Areas
- examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/example.syscfg[67-83]

Recommended Fix
Replace each run of two or more spaces in the `pruicss1` assignment lines with exactly one space, keeping `=` and the values unchanged. If the SysConfig tool regenerates this file with padding, either regenerate with a formatter that emits single spaces or record a documented exception for generated SysConfig output.

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

Dismiss ↗ | View ↗

3. PRU firmware lacks register usage notes 📘
Description
The main routine in main.asm writes to r0, reads r31 and writes r30, but there is no
register-usage comment block above the main: label. Readers cannot tell which registers are
inputs, outputs, clobbered or preserved, which matters for a firmware entry point that is reused or
extended.
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 `main` entry in `main.asm` uses `r0` (zeroed), `r30` (GPO) and `r31` (GPI) with no register-usage block above it.

## Fix Focus Areas
- examples/mirror_input/firmware/main.asm[37-40]

## Recommended Fix
Add a comment block directly above `main:` listing inputs (`r31` GPI bits), outputs (`r30` GPO bit ICL_SIGNAL), clobbers (`r0`, which is zeroed at boot), and preserved registers, using the format shown in the rule.

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

Dismiss ↗ | View ↗

4. R5F main loop spins with no exit path 📘
Description
mirror_input_example_main ends in an unmarked while (1) loop that calls only ClockP_usleep(1),
with no stop condition or timeout. When the task runs at configMAX_PRIORITIES-1, it wakes every
microsecond indefinitely, potentially starving lower-priority work such as the shared-memory log
reader, while Board_driversClose() and Drivers_close() remain unreachable.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
After loading the PRU firmware, `mirror_input_example_main` loops indefinitely with a 1 µs sleep in a top-priority task. The loop does not declare that it is intentionally unbounded, and the cleanup calls after it are unreachable.

## Fix Focus Areas
- examples/mirror_input/mcuplus/mirror_input_example.c[86-92]

## Recommended Fix
If the loop must keep the example running to hold the PRU firmware loaded, add `// INTENTIONALLY_UNBOUNDED_LOOP: keeps the example running to hold the PRU firmware loaded` directly above it and replace the 1 µs delay with a longer sleep such as `ClockP_sleep(1)`. If the task should stop instead, provide a documented shutdown path that runs the cleanup, or return so that `freertos_main` deletes the task. Also remove the dead `#if defined(SOC_AM64X)` block and the commented-out PRU1 load.

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

Dismiss ↗ | View ↗

5. Project readme uses lowercase filename 📘
Description
The project documentation is named readme.md, but the rule requires the exact, case-sensitive name
README.md in each new project directory. A tool or reviewer that looks for README.md will not
find this file on a case-sensitive filesystem.
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 new project directory `examples/mirror_input/` has `readme.md` in lowercase, but the rule requires the case-sensitive filename `README.md`.

## Fix Focus Areas
- examples/mirror_input/readme.md[1-3]

## Recommended Fix
Rename `examples/mirror_input/readme.md` to `examples/mirror_input/README.md` and update any links that point to the old name, including the link in the mirror_input readme itself.

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

Dismiss ↗ | View ↗

6. Assembly operands misaligned 📘
Description
Instructions in main.asm use the wrong gap after the mnemonic: clr, qba, and set have two
spaces, and wbs/wbc have one, while the rule requires five spaces after 3-letter mnemonics and
four after 4-letter ones. The operand column therefore does not line up across the block.
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 instructions in the new `main.asm` do not use the mandated spacing after mnemonics: 3-letter mnemonics (`clr`, `qba`, `set`, `wbs`, `wbc`) are followed by one or two spaces, not five, and 4-letter mnemonics (`zero`, `qbbs`) are followed by one space, not four.

Fix Focus Areas
- examples/mirror_input/firmware/main.asm[40-61]

Recommended Fix
Pad each instruction so that exactly five spaces follow 3-letter mnemonics and exactly four spaces follow 4-letter mnemonics, using spaces only, then re-verify the block with a grep for the mnemonic-to-operand gap.

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

Dismiss ↗ | View ↗

7. Assembly labels are lowercase 📘
Description
The labels main:, high_pulse:, low_pulse:, and the bit_* labels in main.asm are lowercase.
The label convention requires uppercase underscore_case, so they diverge from the uppercase
EPWM_SIGNAL and CMP_SIGNAL constants defined in the same file.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

Issue description
Labels in the new `main.asm` (`main`, `high_pulse`, `low_pulse`, `bit_clear0`, `bit_set0`, `bit_clear1`, `bit_set1`) are lowercase, violating the requirement that assembly labels be uppercase underscore_case.

Fix Focus Areas
- examples/mirror_input/firmware/main.asm[37-61]

Recommended Fix
Rename each label to uppercase (for example `MAIN`, `HIGH_PULSE`, `LOW_PULSE`, `BIT_CLEAR0`, `BIT_SET0`, `BIT_CLEAR1`, `BIT_SET1`), update every branch that references them (`qba`, `qbbs`), and keep the `.global` entry symbol consistent with the linker `--entry_point` and the projectspec.

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

Dismiss ↗ | View ↗

8. Driver init failures go unnoticed 📘
Description
Drivers_open() is called with its return value discarded, even though the comment next to it says
check return status. PRUICSS_open() assigns gPruIcss0Handle with no NULL check before later
PRUICSS_* calls use it. A failed init then carries on silently, and the first symptom is a driver
call failing later on an invalid handle.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`Drivers_open()` returns a status that is ignored despite a comment saying it should be checked. `PRUICSS_open()` returns a handle that is used with no NULL check. The `DebugP_assert(status != 0)` after `PRUICSS_initMemory` looks inverted.

## Fix Focus Areas
- examples/mirror_input/mcuplus/mirror_input_example.c[56-66]

## Recommended Fix
Store the result of `Drivers_open()` and assert or return on failure. Check `gPruIcss0Handle` against NULL right after `PRUICSS_open` and fail fast. Verify the `PRUICSS_initMemory` assert polarity against the driver's success value.

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

Dismiss ↗ | View ↗

9. Host-only builds cannot compile 🐞
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.
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

Dismiss ↗ | View ↗


View low (4)
Informational
10. C source header omits its file name 📘
Description
The first comment block of mirror_input_example.c is the TI license text and never names the file.
The file-name header requirement applies to every new source file, so a reader cannot confirm the
file identity from its header.
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 new `mirror_input_example.c` starts with a license block that does not name the file, violating the requirement that every source file carry a file-name header comment.

Fix Focus Areas
- examples/mirror_input/mcuplus/mirror_input_example.c[1-2]

Recommended Fix
Add a first-line comment `/* mirror_input_example.c */` (or `// mirror_input_example.c`) above the existing license block, so the file name appears before any code or includes.

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

Dismiss ↗ | View ↗

11. Linker header names another file 📘
Description
The header comment in linker.cmd reads AM263Px_PRU0.cmd, which is not the file's name on disk. A
reader searching by name or copying the header to another file will be misled about which file this
is.
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 header comment in `linker.cmd` names `AM263Px_PRU0.cmd`, which does not match the actual file name, so the file-name header rule is violated.

Fix Focus Areas
- examples/mirror_input/firmware/am263px-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd[1-6]

Recommended Fix
Change the header line ` * AM263Px_PRU0.cmd` to ` * linker.cmd` (or the agreed exact file name), keeping it as the first comment line.

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

Dismiss ↗ | View ↗

12. Makefile recipe line runs past 128 📘
Description
The syscfg recipe at line 261 is far longer than 128 characters, and the syscfg-gui and
boot-image signing recipes are also long. The hard 128-character limit applies to non-markdown
source files, which includes this makefile, so these lines fail the check.
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 new makefile contains recipe lines longer than 128 characters (for example the `syscfg` command at line 261), violating the hard line-length limit for non-markdown source files.

Fix Focus Areas
- examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile[261-261]
- examples/mirror_input/mcuplus/am263px-lp/r5fss0-0_freertos/ti-arm-clang/makefile[311-311]

Recommended Fix
Split each over-long recipe with backslash line continuations or move repeated variables into make variables so that every line stays within 128 characters.

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

Dismiss ↗ | View ↗

13. PRU firmware loop has no exit or marker 📘
Description
The high_pulse and low_pulse loops in main run by branching back with qba and only leave
through wbs/wbc on the EPWM pin, with no iteration limit and no stop condition. The loop has no
INTENTIONALLY_UNBOUNDED_LOOP comment, so the intent to run forever is undocumented. A stalled or
missing EPWM input would also leave the firmware blocked in the wait instruction with no timeout.
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 `high_pulse`/`low_pulse` loop in `main.asm` never exits, and it has no comment declaring it intentionally unbounded. It only waits on the EPWM pin with no timeout.

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

## Recommended Fix
Add a comment such as `; INTENTIONALLY_UNBOUNDED_LOOP: real-time mirror loop runs until the PRU is halted` above `high_pulse:`. State in the comment that the loop is only left by a PRU reset or halt.

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

Dismiss ↗ | View ↗


Comment thread examples/mirror_input/makefile Resolved
Comment thread examples/pru_eqep/firmware/main.asm Resolved
Comment thread examples/mirror_input/readme.md Resolved
@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from 0df4aed to ff14d4c Compare August 7, 2026 05:48
Comment thread examples/mirror_input/makefile Resolved
@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
@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 thread examples/mirror_input/firmware/main.asm Resolved
@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 thread examples/mirror_input/readme.md Resolved
@qodo-code-review

Copy link
Copy Markdown

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

@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from 854597b to 2e08a95 Compare September 11, 2026 06:40
@qodo-code-review

Copy link
Copy Markdown

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

@pratheesh pratheesh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the example. The PRU firmware is sound: it assembles cleanly with clpru 2.3.3 and the result is bit-for-bit identical to the committed array. The R5F app also builds clean locally with -Wall -Werror (SDK 11.00.00.19; I don't have the 26.00.00.06 SDK that CI uses). A few things need fixing before merge, and the first two must go in together.

Branch. 7f40a0a3 (PRU-EQEP) is already on main as 36ad4709, and git diff origin/main HEAD -- examples/pru_eqep is empty. Please rebase onto main and drop that commit, so the PR is just the mirror_input change. As it stands, the diff against main also reverts four unrelated files that landed on main after you branched.

Must fix

  1. CI root cause: examples/makefile:4-7 doesn't list mirror_input in SUBDIRS. Top-level make never goes into the example, so no .out is produced. The "Verify all makefiles were built" step (.github/workflows/makefile.yml:179-205) then reports both core makefiles as "never built". The CCS builds pass because they import the projectspecs directly.
  2. examples/mirror_input/makefile is an unedited copy of examples/empty's. It still has PROJECT_NAME := empty and SUPPORTED_PROCESSORS := am243x am261x am263px am263x am62x am64x, and the targets call 13 core directories, of which only 2 exist. If you fix (1) on its own, CI fails in a different way. I reproduced that locally:
    gmake[1]: *** firmware/am263px-lp/icss_m0_pru1_fw/ti-pru-cgt: No such file or directory.  Stop.
    gmake: *** [makefile:135: am263px] Error 2
    
    Fix: set PROJECT_NAME := mirror_input and SUPPORTED_PROCESSORS := am263px, keep only the am263px-lp PRU0 and R5F lines, and delete the other SoC targets.
  3. firmware/pru0_load_bin.h is a committed hexpru output. No other example commits one. It has no license header (best_practices.md:402, :612), and the make flow never reads it because it isn't on any include path. The PRU projectspec does copy it into the CCS project, though (example.projectspec:78, an entry empty doesn't have), and that is exactly the folder the R5F project includes. So in CCS, building only the R5F project after editing main.asm silently runs the committed array. It matches today, so nothing is broken yet. Please delete the file and that <file> entry.

Should fix

  1. TIMING_ANALYSIS.md:42-74. After wbs sees the edge, two more instructions run before R30 is written, so execution adds 2 cycles (10 ns), not 3. wbs also samples R31 once per cycle, which adds 0–5 ns of sampling jitter, so the firmware term is 10–15 ns and not constant. The derived "15 ns hardware delay" therefore becomes 15–20 ns. Please also cite the source for the 200 MHz PRU clock, since every number in the file scales with it.
  2. readme.md is still the template. The title is "Empty Project", the HW/SW table at line 19 says FIXME, and examples/readme.md has no mirror_input row even though the readme points readers to it. There is also no pin or wiring table: EPWM goes on PR0_PRU0_GPIO2, the comparator on PR0_PRU0_GPIO0, and the output comes out on PR0_PRU0_GPIO1.
  3. Name and semantics. The loop samples CMP once per EPWM edge (main.asm:37-62), so a CMP change between edges isn't propagated until the next edge. For an inrush-current-limit gate that's probably what you want, but it isn't a "mirror". Either rename the example or state the edge-sampled behaviour clearly in the readme. That covers qodo's "not mirrored live" finding, which I'd treat as a naming/doc issue rather than a firmware bug.
  4. example.syscfg carries an unrelated 10BASE-T1S/PLCA setup. That includes the ETHPHY, I2C, PLCA_DEBUG_GPO on EPWM8_B, WAKE_PIN, iepSyncMode, an IEP EDIO pin, and several PRU GPIOs the firmware never uses (PR0_PRU0_GPIO4 is configured as an output). The three pins the firmware does use are configured correctly. Please strip it down to what the example needs, and keep the IO-expander mux only if it's required (and say why).

Nits

  • main.asm:1-20: the header is still the empty template ("halt instruction", gmake -all). Line 38's comment says GPI00 and doesn't mention the GPI2 gate.
  • main.asm:40: zero &r0, 124 also clears R30, which drives every PRU0 GPO low. That's fine here, but worth a comment; 120 would leave R30 alone.
  • mcuplus/empty_example.c and empty_example_main: consider renaming to match the example.
  • PR title and body: the title is the branch name and the body is empty. The sign-off is free text rather than a Signed-off-by: trailer.

qodo findings

  • Agree with: broken makefile targets, stale header copied into CCS (I'd rate this one higher), missing supported-hardware row, placeholder readme, project-name string (same root cause as item 2), pin comments (the bot misquoted the lines, but the point stands).
  • Partly agree with "host-only builds cannot compile". That's true of every example, and the fix is to delete the committed header, not move it.
  • PRUICSS_open() handle unchecked: valid, but inherited unchanged from examples/empty, so not a blocker here.
  • The pru_eqep finding is out of scope; that code is already on main.

signed off by: Ayushman  <a-ayushman@ti.com>
@a1248924
a1248924 force-pushed the a1248924_mirror_input branch 2 times, most recently from 4fede67 to de768e1 Compare December 4, 2026 07:26
Comment thread examples/mirror_input/firmware/main.asm Resolved
Comment thread examples/mirror_input/firmware/main.asm Resolved
Comment thread examples/mirror_input/readme.md Resolved
Comment thread examples/mirror_input/firmware/main.asm Resolved
Comment thread examples/mirror_input/readme.md Resolved
@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from de768e1 to 6541783 Compare December 4, 2026 07:52
@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from 6541783 to ddc7f20 Compare December 4, 2026 08:42
Comment thread examples/mirror_input/firmware/main.asm Resolved
Comment thread examples/mirror_input/readme.md Resolved
@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from ddc7f20 to f6990c4 Compare December 4, 2026 08:46
-> fix build failures
-> follow rules from docs_ai/task_create_project.md

Signed-off-by: Ayushman <a-ayushman@ti.com>
@a1248924
a1248924 force-pushed the a1248924_mirror_input branch from f6990c4 to c5a2e3d Compare December 4, 2026 08:48
@a1248924
a1248924 requested review from nsaulnier-ti and pratheesh and removed request for pratheesh December 4, 2026 10:03
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.

2 participants