Skip to content

Spi driver demo - #161

Open
a1248924 wants to merge 2 commits into
mainfrom
SPI_driver_demo
Open

Spi driver demo#161
a1248924 wants to merge 2 commits into
mainfrom
SPI_driver_demo

Conversation

@a1248924

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 12, 2026

Copy link
Copy Markdown

PR Summary by Qodo

Add AM243x PRU eQEP and AM261x SPI driver demos

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

Grey Divider

AI Description

• Adds six-channel PRU eQEP capture and R5F diagnostics for AM243x.
• Adds AM261x PRU SPI master/slave demo with five-word full-duplex bursts.
• Provides CCS, make, SysConfig, boot-image, wiring, and validation documentation.
Diagram

graph TD
  ENC["Encoder Inputs"] -->|A/B edges| EQPRU["Six PRU Cores"] -->|timestamps and position| EQMEM["EQEP DMEM"] -->|polled state| EQR5["R5F EQEP App"]
  SPIR5["R5F SPI App"] -->|commands and trigger| SPIMEM["SPI DMEM"] -->|transaction request| MASTER["PRU0 Master"] -->|SPI burst| SLAVE["PRU1 Slave"]
  SLAVE -->|fixed responses| MASTER
  MASTER -->|results and completion| SPIMEM
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use hardware eQEP and SPI peripherals
  • ➕ Provides mature error handling and established SDK drivers.
  • ➕ Reduces custom timing-sensitive assembly and shared-memory synchronization.
  • ➕ Offers a clearer path toward production qualification.
  • ➖ May not provide the required six encoder channels or flexible pin placement.
  • ➖ Cannot demonstrate PRU-based protocol implementation and deterministic customization.
  • ➖ Limits experimentation with custom SPI timing and framing.
2. Use PRU interrupts instead of polling
  • ➕ Reduces continuous R5F polling and CPU consumption.
  • ➕ Provides prompt completion and encoder-update notifications.
  • ➖ Adds interrupt-controller configuration and six-channel ISR concurrency.
  • ➖ Makes the examples harder to debug and increases synchronization complexity.
  • ➖ Shared-memory polling is simpler for prototype and diagnostic workloads.

Recommendation: Keep the PRU-based design because the examples specifically demonstrate flexible, deterministic PRU implementations and multi-channel operation beyond conventional peripheral usage. The direct DMEM protocol is appropriate for these prototypes; hardware peripherals or interrupt-driven coordination should be preferred if these examples evolve into production drivers.

Files changed (63) +7430 / -1

Enhancement (13) +3305 / -0
macros.incAdd PRU cycle-counter helpers +54/-0

Add PRU cycle-counter helpers

• Defines macros to enable, reset, and read the cycle counter used for edge timestamps.

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, DMEM regions, write-pointer offsets, positions, and phase-error counters for all six cores.

examples/pru_eqep/firmware/include/memory.inc

main.asmImplement PRU quadrature capture firmware +180/-0

Implement PRU quadrature capture firmware

• Polls A/B/Z inputs, timestamps transitions, updates position through a lookup table, records phase errors, and maintains per-channel ring buffers.

examples/pru_eqep/firmware/main.asm

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

Add the eQEP FreeRTOS entry point

• Initializes the platform and launches the eQEP application in a statically allocated high-priority task.

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

• Introduces the six-channel configuration structure, transition states, ring-buffer fields, position data, and phase-error tracking.

examples/pru_eqep/mcuplus/eqep_diagnostic.h

pru_eqep_example.cImplement the R5F eQEP controller +564/-0

Implement the R5F eQEP controller

• Loads six firmware images, initializes shared memory and transition tables, polls channel data, calculates speed and direction, and reports diagnostics.

examples/pru_eqep/mcuplus/pru_eqep_example.c

main.asmImplement the persistent PRU SPI master +442/-0

Implement the persistent PRU SPI master

• Selects among eight runtime mode/bit-order paths and executes triggered five-word, full-duplex bursts under one chip-select assertion.

examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/main.asm

main.asmImplement the PRU SPI slave responder +158/-0

Implement the PRU SPI slave responder

• Waits for chip select, performs five MODE3/MSB full-duplex transfers, returns fixed words, and records received commands in DMEM1.

examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/main.asm

spi_master_macros.incAdd PRU SPI master bit-bang macros +569/-0

Add PRU SPI master bit-bang macros

• Implements read, write, and full-duplex packet transfers for all SPI modes and both bit orders, with configurable timing compensation.

examples/spi_driver/firmware/am261x-lp/spi_master_macros.inc

spi_slave_macros.incAdd PRU SPI slave bit-bang macros +511/-0

Add PRU SPI slave bit-bang macros

• Implements edge-waiting read, write, and full-duplex slave transfers across SPI modes and bit orders.

examples/spi_driver/firmware/am261x-lp/spi_slave_macros.inc

time_macros.incAdd deterministic PRU delay macros +87/-0

Add deterministic PRU delay macros

• Provides cycle-based and nanosecond-based waits used to control SPI timing.

examples/spi_driver/firmware/am261x-lp/time_macros.inc

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

Add the SPI demo FreeRTOS entry point

• Initializes the AM261x platform and runs the SPI application in a static high-priority task.

examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/main.c

empty_example.cImplement the R5F SPI demo controller +250/-0

Implement the R5F SPI demo controller

• Loads both PRUs, submits validated five-word commands through DMEM, waits with a timeout, and prints the fixed responses.

examples/spi_driver/mcuplus/empty_example.c

Documentation (3) +443 / -0
A_B_signal.pngAdd captured quadrature waveform +0/-0

Add captured quadrature waveform

• Provides the logic-analyzer image referenced by the eQEP validation documentation.

examples/pru_eqep/images/A_B_signal.png

readme.mdDocument the AM243x PRU eQEP example +190/-0

Document the AM243x PRU eQEP example

• Documents validation coverage, wiring, architecture, pin mappings, limitations, debugging guidance, and configuration procedures.

examples/pru_eqep/readme.md

readme.mdDocument the AM261x PRU SPI driver demo +253/-0

Document the AM261x PRU SPI driver demo

• Explains the DMEM API, supported runtime settings, timing choices, persistent firmware flow, limitations, pin assignments, and wiring.

examples/spi_driver/readme.md

Other (47) +3682 / -1
makefileRegister the PRU eQEP example +1/-1

Register the PRU eQEP example

• Adds 'pru_eqep' to the repository-wide example build list.

examples/makefile

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

Define the AM243x PRU0 CCS firmware project

• Configures the PRU0 target, core-specific symbols, shared sources, and firmware-header generation.

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

• Defines PRU0 instruction memory and the custom per-core ICSSG data-RAM partition.

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

makefileBuild the PRU0 eQEP firmware +48/-0

Build the PRU0 eQEP firmware

• Builds the shared assembly with 'PRU0' definitions and emits the R5F-loadable firmware header.

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

makefile_projectspecAutomate PRU0 CCS project operations +16/-0

Automate PRU0 CCS project operations

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

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

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

Define the AM243x PRU1 CCS firmware project

• Configures the PRU1 target, slice definitions, shared sources, and firmware-header generation.

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

• Defines PRU1 instruction memory and slice-one data-RAM allocations.

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

makefileBuild the PRU1 eQEP firmware +49/-0

Build the PRU1 eQEP firmware

• Builds the shared eQEP assembly for PRU1 and generates its load header.

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

makefile_projectspecAutomate PRU1 CCS project operations +16/-0

Automate PRU1 CCS project operations

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

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

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

Define the AM243x RTU_PRU0 CCS project

• Targets RTU_PRU0 with the correct symbol and generates an R5F-loadable firmware array.

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

• Assigns RTU instruction RAM and its reserved slice-zero data-RAM region.

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

makefileBuild the RTU_PRU0 eQEP firmware +49/-0

Build the RTU_PRU0 eQEP firmware

• Compiles the common firmware for RTU_PRU0 and exports its binary header.

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

makefile_projectspecAutomate RTU_PRU0 CCS project operations +16/-0

Automate RTU_PRU0 CCS project operations

• Provides CCS 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 AM243x RTU_PRU1 CCS project +84/-0

Define the AM243x RTU_PRU1 CCS project

• Targets RTU_PRU1 with slice-one symbols and firmware-array generation.

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

• Assigns RTU instruction RAM and its reserved slice-one data-RAM region.

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

makefileBuild the RTU_PRU1 eQEP firmware +49/-0

Build the RTU_PRU1 eQEP firmware

• Compiles the common firmware for RTU_PRU1 and exports its load header.

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

makefile_projectspecAutomate RTU_PRU1 CCS project operations +16/-0

Automate RTU_PRU1 CCS project operations

• Provides CCS 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 AM243x TX_PRU0 CCS project +84/-0

Define the AM243x TX_PRU0 CCS project

• Targets TX_PRU0, includes shared eQEP sources, and generates its firmware array.

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

• Assigns TX_PRU instruction RAM and the reserved slice-zero TX data region.

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

makefileBuild the TX_PRU0 eQEP firmware +49/-0

Build the TX_PRU0 eQEP firmware

• Builds the common firmware with 'TX_PRU0' definitions and emits its load header.

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

makefile_projectspecAutomate TX_PRU0 CCS project operations +16/-0

Automate TX_PRU0 CCS project operations

• Provides CCS 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 AM243x TX_PRU1 CCS project +84/-0

Define the AM243x TX_PRU1 CCS project

• Targets TX_PRU1, includes shared sources, and generates its R5F firmware array.

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

• Assigns TX_PRU instruction RAM and the reserved slice-one TX data region.

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

makefileBuild the TX_PRU1 eQEP firmware +49/-0

Build the TX_PRU1 eQEP firmware

• Builds the common firmware with 'TX_PRU1' definitions and emits its load header.

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

makefile_projectspecAutomate TX_PRU1 CCS project operations +16/-0

Automate TX_PRU1 CCS project operations

• Provides CCS 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 AM243x eQEP builds +110/-0

Orchestrate AM243x eQEP builds

• Builds six PRU firmware targets before the MCU+ R5F application and supports component-specific clean targets.

examples/pru_eqep/makefile

example.syscfgConfigure AM243x eQEP pins and PRUICSS +323/-0

Configure AM243x eQEP pins and PRUICSS

• Configures ICSSG0 clocks, six-channel GPI pinmux, interrupt mappings, UART logging, MPU regions, and linker memory.

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

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

Define the AM243x eQEP R5F CCS project

• Configures FreeRTOS, SysConfig, generated firmware headers, SDK libraries, and boot-image post-processing.

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

makefileBuild and package the eQEP R5F application +355/-0

Build and package the eQEP R5F application

• Adds SysConfig generation, TI ARM Clang compilation, linking, boot-image signing, cleanup, and coverage targets.

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 R5F ELF to RPRC/appimage outputs and applies device-specific signing.

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

makefile_projectspecAutomate eQEP R5F CCS project operations +16/-0

Automate eQEP R5F CCS project operations

• Provides CCS export, build, and clean commands for the R5F application.

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

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

Enable FreeRTOS runtime views

• Registers FreeRTOS ROV viewers for CCS and Theia debugging.

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

example.projectspecDefine the AM261x SPI master CCS project +84/-0

Define the AM261x SPI master CCS project

• Configures PRU0 compilation, SPI macro sources, linking, and firmware-header generation.

examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/example.projectspec

linker.cmdMap the AM261x PRU0 SPI firmware +43/-0

Map the AM261x PRU0 SPI firmware

• Defines PRU0 instruction memory, local data RAM, peer data RAM, and shared RAM.

examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/linker.cmd

makefileBuild the PRU0 SPI master firmware +48/-0

Build the PRU0 SPI master firmware

• Builds the AM261x PRU0 image and emits the firmware header consumed by R5F.

examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/makefile

makefile_projectspecAutomate SPI master CCS project operations +16/-0

Automate SPI master CCS project operations

• Adds CCS export, build, and clean targets for the PRU0 firmware.

examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/ti-pru-cgt/makefile_projectspec

example.projectspecDefine the AM261x SPI slave CCS project +84/-0

Define the AM261x SPI slave CCS project

• Configures PRU1 compilation, slave macro sources, linking, and firmware-header generation.

examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/example.projectspec

linker.cmdMap the AM261x PRU1 SPI firmware +43/-0

Map the AM261x PRU1 SPI firmware

• Defines PRU1 instruction memory, local data RAM, peer data RAM, and shared RAM.

examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/linker.cmd

makefileBuild the PRU1 SPI slave firmware +48/-0

Build the PRU1 SPI slave firmware

• Builds the AM261x PRU1 responder and emits its R5F-loadable firmware header.

examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/makefile

makefile_projectspecAutomate SPI slave CCS project operations +16/-0

Automate SPI slave CCS project operations

• Adds CCS export, build, and clean targets for the PRU1 firmware.

examples/spi_driver/firmware/am261x-lp/icss_m1_pru1_fw/ti-pru-cgt/makefile_projectspec

makefileOrchestrate AM261x SPI demo builds +106/-0

Orchestrate AM261x SPI demo builds

• Builds the PRU master and slave images before the MCU+ R5F application.

examples/spi_driver/makefile

example.syscfgConfigure AM261x SPI demo hardware +327/-0

Configure AM261x SPI demo hardware

• Configures ICSS_M1 pinmux, LaunchPad I/O expansion, UART, MPU regions, shared memory, and linker sections.

examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/example.syscfg

example.projectspecDefine the AM261x SPI R5F CCS project +117/-0

Define the AM261x SPI R5F CCS project

• Configures FreeRTOS, SysConfig, generated PRU headers, SDK libraries, and boot-image generation.

examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/example.projectspec

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

Build and package the SPI R5F application

• Adds SysConfig generation, compilation, linking, multicore ELF packaging, signing, cleanup, and coverage targets.

examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile

makefile_ccs_bootimage_genGenerate SPI demo boot images from CCS +112/-0

Generate SPI demo boot images from CCS

• Packages the CCS R5F output as a multicore ELF and optionally signs secure-device images.

examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_ccs_bootimage_gen

makefile_projectspecAutomate SPI R5F CCS project operations +16/-0

Automate SPI R5F CCS project operations

• Provides CCS export, build, and clean commands for the SPI application.

examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile_projectspec

syscfg_c.rov.xsEnable SPI demo FreeRTOS runtime views +12/-0

Enable SPI demo FreeRTOS runtime views

• Registers FreeRTOS ROV viewers for CCS and Theia debugging.

examples/spi_driver/mcuplus/am261x-lp/r5fss0-0_freertos/ti-arm-clang/syscfg_c.rov.xs

@qodo-code-review

qodo-code-review Bot commented Aug 12, 2026

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Project skipped by root builds 🐞 Bug ⚙ Maintainability
Description
The new spi_driver project is not registered in examples/makefile, so repository-wide make,
make pru, make host, and make clean silently skip it. This also prevents normal aggregate
builds from detecting regressions in the new firmware and host application.
Code

examples/spi_driver/makefile[R7-8]

+PROJECT_NAME := spi_driver
+SUPPORTED_PROCESSORS := am261x
Evidence
The SPI makefile declares a standalone AM261x project and defines its firmware and MCU+ targets, but
the parent makefile's exhaustive SUBDIRS list omits spi_driver; all parent targets recurse
exclusively through that list.

examples/spi_driver/makefile[7-12]
examples/spi_driver/makefile[60-80]
examples/spi_driver/makefile[94-103]
examples/makefile[3-7]
examples/makefile[9-24]

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 newly added `spi_driver` project has its own build targets but is absent from the parent examples directory list, so aggregate repository builds never invoke it.

## Issue Context
The root build delegates to `examples/makefile`, whose recursive targets process only entries in `SUBDIRS`. Add `spi_driver` to that list and ensure aggregate clean, PRU, and host targets reach the project.

## Fix Focus Areas
- examples/makefile[3-7]
- examples/spi_driver/makefile[7-12]
- examples/spi_driver/makefile[60-80]

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


2. Wrong DMEM base channels 🐞 Bug ≡ Correctness
Description
In pru_eqep_example_main(), ABZHandle[i]->baseMemAddr0 is computed from pru0DramBase for all 6
channels, but the PRU1-side firmware channels (RTU_PRU1/PRU1/TX_PRU1) place their buffers in the
PRU1 DRAM bank. This causes channels 3–5 to read stale/incorrect ring-buffer data and report wrong
speed/position/phase-error results.
Code

examples/pru_eqep/mcuplus/pru_eqep_example.c[R243-246]

+        ABZHandle[i]->baseMemAddr0 = (uint32_t *)(
+            ((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->pru0DramBase +
+            DMEM_OFFSETS[i]
+        );
Evidence
The host code always uses hwAttrs->pru0DramBase for baseMemAddr0, even though it labels channels 3–5
as PRU1-bank channels; the firmware explicitly places PRU1-core DMEM bases at 0x2C00/0x3000/0x3400
(i.e., PRU1-bank region). Existing code in the repo treats pru0DramBase and pru1DramBase as distinct
banks selected per core, so using pru0DramBase for PRU1 channels is inconsistent with the expected
memory map.

examples/pru_eqep/mcuplus/pru_eqep_example.c[238-258]
examples/pru_eqep/firmware/include/memory.inc[120-161]
examples/pru_emif/pru_emif_app/pruemif16.c[241-245]

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

## Issue description
`pru_eqep_example_main()` initializes each channel’s `baseMemAddr0` using `hwAttrs->pru0DramBase` unconditionally. However, the PRU firmware assigns distinct DMEM base offsets for PRU1-side cores (RTU_PRU1/PRU1/TX_PRU1), which correspond to the PRU1 DRAM bank. As a result, channels 3–5 (PRU1-side) will read from the PRU0 DRAM bank instead of PRU1, producing incorrect diagnostics.

## Issue Context
- Channels 0–2 correspond to PRU0-side cores; channels 3–5 correspond to PRU1-side cores.
- Firmware memory layout shows PRU1-side cores use DMEM offsets in the PRU1 region (e.g., 0x2C00/0x3000/0x3400), which conceptually is `PRU1_DRAM_BASE + {0x0C00,0x1000,0x1400}`.

## Fix
- Compute `baseMemAddr0` with `pru0DramBase` for channels 0–2 and `pru1DramBase` for channels 3–5.
- Keep `DMEM_OFFSETS[i]` as-is (since offsets 3–5 are already the per-bank offsets), but switch the base pointer depending on `i`.

## Fix Focus Areas
- examples/pru_eqep/mcuplus/pru_eqep_example.c[238-259]

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



Remediation recommended

3. Decimal input parsed hexadecimal 🐞 Bug ≡ Correctness
Description
The prompt requests decimal command words, but DebugP_scanf("%x", &input) parses them as
hexadecimal. For example, entering decimal 10 sends 0x10 (16), causing the SPI transaction to
use a different command than the user requested.
Code

examples/spi_driver/mcuplus/empty_example.c[220]

+            DebugP_scanf("%x", &input);
Evidence
The application tells users to enter decimal values at line 215, then reads each value with the
hexadecimal %x conversion at line 220. The parsed value is assigned directly to commandWords[i]
at line 228 and subsequently transmitted.

examples/spi_driver/mcuplus/empty_example.c[215-228]

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 console requests decimal command words but parses input using the hexadecimal `%x` conversion, so digit-only values can be transmitted with the wrong numeric value.

## Issue Context
Either parse decimal input with `%u`, or explicitly change the prompt and validation messages to request hexadecimal input.

## Fix Focus Areas
- examples/spi_driver/mcuplus/empty_example.c[215-224]

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


4. Timeout desynchronizes transactions 🐞 Bug ☼ Reliability
Description
PRU_SPI_runTransaction5 returns on timeout while leaving the outstanding trigger active, and the
caller immediately permits another transaction. If the timed-out PRU operation later clears that
shared trigger after the retry sets it, the retry reports success and reads responses from the
previous transaction.
Code

examples/spi_driver/mcuplus/empty_example.c[R161-164]

+        if (elapsed >= TRIGGER_POLL_TIMEOUT_US)
+        {
+            return 0;
+        }
Evidence
The host returns immediately when its 5 ms poll expires without cancelling or resetting the
outstanding request, then the caller continues the main loop. PRU0 independently publishes responses
and clears DMEM_CFG_TRIGGER at the end of a burst, so a delayed clear can be mistaken for completion
of a later request using that same one-bit trigger.

examples/spi_driver/mcuplus/empty_example.c[154-172]
examples/spi_driver/mcuplus/empty_example.c[232-243]
examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/main.asm[365-375]

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

## Issue description
A timed-out SPI transaction remains active because the shared trigger is left set. A late PRU completion can clear the trigger belonging to a subsequent retry, causing stale responses to be accepted as current.

## Issue Context
The PRU clears the same trigger only after publishing its responses, while the application continues its input loop after a timeout. Recovery must not simply clear the trigger while the PRU may still be processing; either stop/reinitialize the PRU transaction state or terminate further transactions, or introduce a sequence-based handshake that distinguishes completions.

## Fix Focus Areas
- examples/spi_driver/mcuplus/empty_example.c[156-172]
- examples/spi_driver/mcuplus/empty_example.c[232-235]
- examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/main.asm[365-375]

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


5. Failed input reuses command 🐞 Bug ≡ Correctness
Description
empty_example_main ignores whether DebugP_scanf successfully parsed a value and then validates
and dispatches the uninitialized or previously retained input. Malformed or unavailable console
input can therefore trigger an unintended SPI transaction, and an unconsumed invalid token can
repeat this behavior.
Code

examples/spi_driver/mcuplus/empty_example.c[R169-170]

+        DebugP_log("\r\nEnter command (0-3): ");
+        DebugP_scanf("%d", &input);
Evidence
input is declared without initialization, the scan result is discarded, and the following code
reads that value to select and execute one of four command words regardless of whether parsing
succeeded.

examples/spi_driver/mcuplus/empty_example.c[129-133]
examples/spi_driver/mcuplus/empty_example.c[167-180]
examples/spi_driver/mcuplus/empty_example.c[182-189]

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 command loop uses `input` even when console parsing fails, allowing an indeterminate or stale command to be sent.

## Issue Context
Initialize the input variable, check the `DebugP_scanf` result before range validation, and consume or otherwise handle invalid input so the same malformed token does not repeatedly fail.

## Fix Focus Areas
- examples/spi_driver/mcuplus/empty_example.c[131-133]
- examples/spi_driver/mcuplus/empty_example.c[167-180]
- examples/spi_driver/mcuplus/empty_example.c[182-189]

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


View medium (1)
6. Header missing guards 🐞 Bug ⚙ Maintainability
Description
eqep_diagnostic.h has no include guard and does not include the headers that define types it uses
(e.g., uint8_t/uint32_t, PRUICSS_Handle), making it dependent on include order and susceptible to
redefinition errors if included multiple times. This can cause brittle build failures as the example
evolves or headers are reorganized.
Code

examples/pru_eqep/mcuplus/eqep_diagnostic.h[R33-34]

+// Typedef for ABZ handle
+typedef struct ABZ_Config_s *ABZ_Handle;
Evidence
The header begins immediately with comments and then type declarations (no guard macros visible at
the start), and it uses fixed-width integer types and PRUICSS_Handle without including their
definitions, meaning it relies on other headers being included first.

examples/pru_eqep/mcuplus/eqep_diagnostic.h[1-20]
examples/pru_eqep/mcuplus/eqep_diagnostic.h[33-72]

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

## Issue description
`eqep_diagnostic.h` declares public types using `uint8_t`, `uint32_t`, and `PRUICSS_Handle` but does not include headers that define these types, and it lacks an include guard. This makes compilation depend on transitive includes and include order, and can cause redefinition errors if the header is included more than once.

## Issue Context
This header is intended to define shared types (`ABZ_Config`, `ABZ_Handle`) used by the PRU EQEP MCU+ example.

## Fix
- Add an include guard (`#ifndef / #define / #endif`) or `#pragma once`.
- Include required headers directly (at minimum `<stdint.h>`; and whichever project header provides `PRUICSS_Handle`, typically `<drivers/pruicss.h>` in this repo’s examples).

## Fix Focus Areas
- examples/pru_eqep/mcuplus/eqep_diagnostic.h[1-20]
- examples/pru_eqep/mcuplus/eqep_diagnostic.h[33-75]

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


Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 41a382f ⚖️ Balanced

Results up to commit 45b14ca ⚖️ Balanced


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


Action required
1. Wrong DMEM base channels 🐞 Bug ≡ Correctness
Description
In pru_eqep_example_main(), ABZHandle[i]->baseMemAddr0 is computed from pru0DramBase for all 6
channels, but the PRU1-side firmware channels (RTU_PRU1/PRU1/TX_PRU1) place their buffers in the
PRU1 DRAM bank. This causes channels 3–5 to read stale/incorrect ring-buffer data and report wrong
speed/position/phase-error results.
Code

examples/pru_eqep/mcuplus/pru_eqep_example.c[R243-246]

+        ABZHandle[i]->baseMemAddr0 = (uint32_t *)(
+            ((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->pru0DramBase +
+            DMEM_OFFSETS[i]
+        );
Evidence
The host code always uses hwAttrs->pru0DramBase for baseMemAddr0, even though it labels channels 3–5
as PRU1-bank channels; the firmware explicitly places PRU1-core DMEM bases at 0x2C00/0x3000/0x3400
(i.e., PRU1-bank region). Existing code in the repo treats pru0DramBase and pru1DramBase as distinct
banks selected per core, so using pru0DramBase for PRU1 channels is inconsistent with the expected
memory map.

examples/pru_eqep/mcuplus/pru_eqep_example.c[238-258]
examples/pru_eqep/firmware/include/memory.inc[120-161]
examples/pru_emif/pru_emif_app/pruemif16.c[241-245]

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

## Issue description
`pru_eqep_example_main()` initializes each channel’s `baseMemAddr0` using `hwAttrs->pru0DramBase` unconditionally. However, the PRU firmware assigns distinct DMEM base offsets for PRU1-side cores (RTU_PRU1/PRU1/TX_PRU1), which correspond to the PRU1 DRAM bank. As a result, channels 3–5 (PRU1-side) will read from the PRU0 DRAM bank instead of PRU1, producing incorrect diagnostics.

## Issue Context
- Channels 0–2 correspond to PRU0-side cores; channels 3–5 correspond to PRU1-side cores.
- Firmware memory layout shows PRU1-side cores use DMEM offsets in the PRU1 region (e.g., 0x2C00/0x3000/0x3400), which conceptually is `PRU1_DRAM_BASE + {0x0C00,0x1000,0x1400}`.

## Fix
- Compute `baseMemAddr0` with `pru0DramBase` for channels 0–2 and `pru1DramBase` for channels 3–5.
- Keep `DMEM_OFFSETS[i]` as-is (since offsets 3–5 are already the per-bank offsets), but switch the base pointer depending on `i`.

## Fix Focus Areas
- examples/pru_eqep/mcuplus/pru_eqep_example.c[238-259]

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



Remediation recommended
2. Header missing guards 🐞 Bug ⚙ Maintainability
Description
eqep_diagnostic.h has no include guard and does not include the headers that define types it uses
(e.g., uint8_t/uint32_t, PRUICSS_Handle), making it dependent on include order and susceptible to
redefinition errors if included multiple times. This can cause brittle build failures as the example
evolves or headers are reorganized.
Code

examples/pru_eqep/mcuplus/eqep_diagnostic.h[R33-34]

+// Typedef for ABZ handle
+typedef struct ABZ_Config_s *ABZ_Handle;
Evidence
The header begins immediately with comments and then type declarations (no guard macros visible at
the start), and it uses fixed-width integer types and PRUICSS_Handle without including their
definitions, meaning it relies on other headers being included first.

examples/pru_eqep/mcuplus/eqep_diagnostic.h[1-20]
examples/pru_eqep/mcuplus/eqep_diagnostic.h[33-72]

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

## Issue description
`eqep_diagnostic.h` declares public types using `uint8_t`, `uint32_t`, and `PRUICSS_Handle` but does not include headers that define these types, and it lacks an include guard. This makes compilation depend on transitive includes and include order, and can cause redefinition errors if the header is included more than once.

## Issue Context
This header is intended to define shared types (`ABZ_Config`, `ABZ_Handle`) used by the PRU EQEP MCU+ example.

## Fix
- Add an include guard (`#ifndef / #define / #endif`) or `#pragma once`.
- Include required headers directly (at minimum `<stdint.h>`; and whichever project header provides `PRUICSS_Handle`, typically `<drivers/pruicss.h>` in this repo’s examples).

## Fix Focus Areas
- examples/pru_eqep/mcuplus/eqep_diagnostic.h[1-20]
- examples/pru_eqep/mcuplus/eqep_diagnostic.h[33-75]

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


Results up to commit c7b425c ⚖️ Balanced


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


Action required
1. Project skipped by root builds 🐞 Bug ⚙ Maintainability
Description
The new spi_driver project is not registered in examples/makefile, so repository-wide make,
make pru, make host, and make clean silently skip it. This also prevents normal aggregate
builds from detecting regressions in the new firmware and host application.
Code

examples/spi_driver/makefile[R7-8]

+PROJECT_NAME := spi_driver
+SUPPORTED_PROCESSORS := am261x
Evidence
The SPI makefile declares a standalone AM261x project and defines its firmware and MCU+ targets, but
the parent makefile's exhaustive SUBDIRS list omits spi_driver; all parent targets recurse
exclusively through that list.

examples/spi_driver/makefile[7-12]
examples/spi_driver/makefile[60-80]
examples/spi_driver/makefile[94-103]
examples/makefile[3-7]
examples/makefile[9-24]

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 newly added `spi_driver` project has its own build targets but is absent from the parent examples directory list, so aggregate repository builds never invoke it.

## Issue Context
The root build delegates to `examples/makefile`, whose recursive targets process only entries in `SUBDIRS`. Add `spi_driver` to that list and ensure aggregate clean, PRU, and host targets reach the project.

## Fix Focus Areas
- examples/makefile[3-7]
- examples/spi_driver/makefile[7-12]
- examples/spi_driver/makefile[60-80]

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



Remediation recommended
2. Failed input reuses command 🐞 Bug ≡ Correctness
Description
empty_example_main ignores whether DebugP_scanf successfully parsed a value and then validates
and dispatches the uninitialized or previously retained input. Malformed or unavailable console
input can therefore trigger an unintended SPI transaction, and an unconsumed invalid token can
repeat this behavior.
Code

examples/spi_driver/mcuplus/empty_example.c[R169-170]

+        DebugP_log("\r\nEnter command (0-3): ");
+        DebugP_scanf("%d", &input);
Evidence
input is declared without initialization, the scan result is discarded, and the following code
reads that value to select and execute one of four command words regardless of whether parsing
succeeded.

examples/spi_driver/mcuplus/empty_example.c[129-133]
examples/spi_driver/mcuplus/empty_example.c[167-180]
examples/spi_driver/mcuplus/empty_example.c[182-189]

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 command loop uses `input` even when console parsing fails, allowing an indeterminate or stale command to be sent.

## Issue Context
Initialize the input variable, check the `DebugP_scanf` result before range validation, and consume or otherwise handle invalid input so the same malformed token does not repeatedly fail.

## Fix Focus Areas
- examples/spi_driver/mcuplus/empty_example.c[131-133]
- examples/spi_driver/mcuplus/empty_example.c[167-180]
- examples/spi_driver/mcuplus/empty_example.c[182-189]

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


Results up to commit a278e17 ⚖️ Balanced


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


Remediation recommended
1. Timeout desynchronizes transactions 🐞 Bug ☼ Reliability
Description
PRU_SPI_runTransaction5 returns on timeout while leaving the outstanding trigger active, and the
caller immediately permits another transaction. If the timed-out PRU operation later clears that
shared trigger after the retry sets it, the retry reports success and reads responses from the
previous transaction.
Code

examples/spi_driver/mcuplus/empty_example.c[R161-164]

+        if (elapsed >= TRIGGER_POLL_TIMEOUT_US)
+        {
+            return 0;
+        }
Evidence
The host returns immediately when its 5 ms poll expires without cancelling or resetting the
outstanding request, then the caller continues the main loop. PRU0 independently publishes responses
and clears DMEM_CFG_TRIGGER at the end of a burst, so a delayed clear can be mistaken for completion
of a later request using that same one-bit trigger.

examples/spi_driver/mcuplus/empty_example.c[154-172]
examples/spi_driver/mcuplus/empty_example.c[232-243]
examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/main.asm[365-375]

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

## Issue description
A timed-out SPI transaction remains active because the shared trigger is left set. A late PRU completion can clear the trigger belonging to a subsequent retry, causing stale responses to be accepted as current.

## Issue Context
The PRU clears the same trigger only after publishing its responses, while the application continues its input loop after a timeout. Recovery must not simply clear the trigger while the PRU may still be processing; either stop/reinitialize the PRU transaction state or terminate further transactions, or introduce a sequence-based handshake that distinguishes completions.

## Fix Focus Areas
- examples/spi_driver/mcuplus/empty_example.c[156-172]
- examples/spi_driver/mcuplus/empty_example.c[232-235]
- examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/main.asm[365-375]

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


Results up to commit dc18a4d ⚖️ Balanced


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


Remediation recommended
1. Decimal input parsed hexadecimal 🐞 Bug ≡ Correctness
Description
The prompt requests decimal command words, but DebugP_scanf("%x", &input) parses them as
hexadecimal. For example, entering decimal 10 sends 0x10 (16), causing the SPI transaction to
use a different command than the user requested.
Code

examples/spi_driver/mcuplus/empty_example.c[220]

+            DebugP_scanf("%x", &input);
Evidence
The application tells users to enter decimal values at line 215, then reads each value with the
hexadecimal %x conversion at line 220. The parsed value is assigned directly to commandWords[i]
at line 228 and subsequently transmitted.

examples/spi_driver/mcuplus/empty_example.c[215-228]

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 console requests decimal command words but parses input using the hexadecimal `%x` conversion, so digit-only values can be transmitted with the wrong numeric value.

## Issue Context
Either parse decimal input with `%u`, or explicitly change the prompt and validation messages to request hexadecimal input.

## Fix Focus Areas
- examples/spi_driver/mcuplus/empty_example.c[215-224]

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


Grey Divider

Qodo Logo

Comment on lines +243 to +246
ABZHandle[i]->baseMemAddr0 = (uint32_t *)(
((PRUICSS_HwAttrs *)(gPruIcssXHandle->hwAttrs))->pru0DramBase +
DMEM_OFFSETS[i]
);

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. Wrong dmem base channels 🐞 Bug ≡ Correctness

In pru_eqep_example_main(), ABZHandle[i]->baseMemAddr0 is computed from pru0DramBase for all 6
channels, but the PRU1-side firmware channels (RTU_PRU1/PRU1/TX_PRU1) place their buffers in the
PRU1 DRAM bank. This causes channels 3–5 to read stale/incorrect ring-buffer data and report wrong
speed/position/phase-error results.
Agent Prompt
## Issue description
`pru_eqep_example_main()` initializes each channel’s `baseMemAddr0` using `hwAttrs->pru0DramBase` unconditionally. However, the PRU firmware assigns distinct DMEM base offsets for PRU1-side cores (RTU_PRU1/PRU1/TX_PRU1), which correspond to the PRU1 DRAM bank. As a result, channels 3–5 (PRU1-side) will read from the PRU0 DRAM bank instead of PRU1, producing incorrect diagnostics.

## Issue Context
- Channels 0–2 correspond to PRU0-side cores; channels 3–5 correspond to PRU1-side cores.
- Firmware memory layout shows PRU1-side cores use DMEM offsets in the PRU1 region (e.g., 0x2C00/0x3000/0x3400), which conceptually is `PRU1_DRAM_BASE + {0x0C00,0x1000,0x1400}`.

## Fix
- Compute `baseMemAddr0` with `pru0DramBase` for channels 0–2 and `pru1DramBase` for channels 3–5.
- Keep `DMEM_OFFSETS[i]` as-is (since offsets 3–5 are already the per-bank offsets), but switch the base pointer depending on `i`.

## Fix Focus Areas
- examples/pru_eqep/mcuplus/pru_eqep_example.c[238-259]

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

Comment on lines +33 to +34
// Typedef for ABZ handle
typedef struct ABZ_Config_s *ABZ_Handle;

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

2. Header missing guards 🐞 Bug ⚙ Maintainability

eqep_diagnostic.h has no include guard and does not include the headers that define types it uses
(e.g., uint8_t/uint32_t, PRUICSS_Handle), making it dependent on include order and susceptible to
redefinition errors if included multiple times. This can cause brittle build failures as the example
evolves or headers are reorganized.
Agent Prompt
## Issue description
`eqep_diagnostic.h` declares public types using `uint8_t`, `uint32_t`, and `PRUICSS_Handle` but does not include headers that define these types, and it lacks an include guard. This makes compilation depend on transitive includes and include order, and can cause redefinition errors if the header is included more than once.

## Issue Context
This header is intended to define shared types (`ABZ_Config`, `ABZ_Handle`) used by the PRU EQEP MCU+ example.

## Fix
- Add an include guard (`#ifndef / #define / #endif`) or `#pragma once`.
- Include required headers directly (at minimum `<stdint.h>`; and whichever project header provides `PRUICSS_Handle`, typically `<drivers/pruicss.h>` in this repo’s examples).

## Fix Focus Areas
- examples/pru_eqep/mcuplus/eqep_diagnostic.h[1-20]
- examples/pru_eqep/mcuplus/eqep_diagnostic.h[33-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 := spi_driver
SUPPORTED_PROCESSORS := am261x

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. Project skipped by root builds 🐞 Bug ⚙ Maintainability

The new spi_driver project is not registered in examples/makefile, so repository-wide make,
make pru, make host, and make clean silently skip it. This also prevents normal aggregate
builds from detecting regressions in the new firmware and host application.
Agent Prompt
## Issue description
The newly added `spi_driver` project has its own build targets but is absent from the parent examples directory list, so aggregate repository builds never invoke it.

## Issue Context
The root build delegates to `examples/makefile`, whose recursive targets process only entries in `SUBDIRS`. Add `spi_driver` to that list and ensure aggregate clean, PRU, and host targets reach the project.

## Fix Focus Areas
- examples/makefile[3-7]
- examples/spi_driver/makefile[7-12]
- examples/spi_driver/makefile[60-80]

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

Comment on lines +169 to +170
DebugP_log("\r\nEnter command (0-3): ");
DebugP_scanf("%d", &input);

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

2. Failed input reuses command 🐞 Bug ≡ Correctness

empty_example_main ignores whether DebugP_scanf successfully parsed a value and then validates
and dispatches the uninitialized or previously retained input. Malformed or unavailable console
input can therefore trigger an unintended SPI transaction, and an unconsumed invalid token can
repeat this behavior.
Agent Prompt
## Issue description
The command loop uses `input` even when console parsing fails, allowing an indeterminate or stale command to be sent.

## Issue Context
Initialize the input variable, check the `DebugP_scanf` result before range validation, and consume or otherwise handle invalid input so the same malformed token does not repeatedly fail.

## Fix Focus Areas
- examples/spi_driver/mcuplus/empty_example.c[131-133]
- examples/spi_driver/mcuplus/empty_example.c[167-180]
- examples/spi_driver/mcuplus/empty_example.c[182-189]

ⓘ 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 c7b425c

Comment on lines +161 to +164
if (elapsed >= TRIGGER_POLL_TIMEOUT_US)
{
return 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. Timeout desynchronizes transactions 🐞 Bug ☼ Reliability

PRU_SPI_runTransaction5 returns on timeout while leaving the outstanding trigger active, and the
caller immediately permits another transaction. If the timed-out PRU operation later clears that
shared trigger after the retry sets it, the retry reports success and reads responses from the
previous transaction.
Agent Prompt
## Issue description
A timed-out SPI transaction remains active because the shared trigger is left set. A late PRU completion can clear the trigger belonging to a subsequent retry, causing stale responses to be accepted as current.

## Issue Context
The PRU clears the same trigger only after publishing its responses, while the application continues its input loop after a timeout. Recovery must not simply clear the trigger while the PRU may still be processing; either stop/reinitialize the PRU transaction state or terminate further transactions, or introduce a sequence-based handshake that distinguishes completions.

## Fix Focus Areas
- examples/spi_driver/mcuplus/empty_example.c[156-172]
- examples/spi_driver/mcuplus/empty_example.c[232-235]
- examples/spi_driver/firmware/am261x-lp/icss_m1_pru0_fw/main.asm[365-375]

ⓘ 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 a278e17

while (i < 5U)
{
DebugP_log(" cmd[%u]: ", i);
DebugP_scanf("%x", &input);

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. Decimal input parsed hexadecimal 🐞 Bug ≡ Correctness

The prompt requests decimal command words, but DebugP_scanf("%x", &input) parses them as
hexadecimal. For example, entering decimal 10 sends 0x10 (16), causing the SPI transaction to
use a different command than the user requested.
Agent Prompt
## Issue description
The console requests decimal command words but parses input using the hexadecimal `%x` conversion, so digit-only values can be transmitted with the wrong numeric value.

## Issue Context
Either parse decimal input with `%u`, or explicitly change the prompt and validation messages to request hexadecimal input.

## Fix Focus Areas
- examples/spi_driver/mcuplus/empty_example.c[215-224]

ⓘ 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 dc18a4d

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 41a382f

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