Skip to content

[WIP]am261x: pru i2c: Add PRU I2C Master firmware and R5F example - #137

Closed
achala-ti wants to merge 4 commits into
mainfrom
a0502729_PRU_I2C
Closed

achala-ti wants to merge 4 commits into
mainfrom
a0502729_PRU_I2C

Conversation

@achala-ti

Copy link
Copy Markdown
Collaborator
  • Add I2C firmware files
  • Create PRU0/PRU1 build projects for ICSS_M0
  • Add R5F example

@qodo-code-review

qodo-code-review Bot commented May 4, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Add AM261x PRU I2C master firmware and dual-core builds

✨ Enhancement ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Adds timer-driven PRU I2C master firmware with shared-memory commands and host completion
 interrupts.
• Provides AM261x PRU0 and PRU1 builds, linker layouts, and firmware arrays.
• Wires both builds into top-level make; no R5F example appears in this diff.
Merge Risk 🟡 Medium

Blast radius 🟡 Medium 💥 2 capabilities

  • 2 affected capabilities within one bounded functional scope: AM261x PRU I2C firmware integration.
  • The timer scheduler, PRU firmware image, shared IEP configuration, and host-visible I2C memory map together implement one end-to-end I2C transaction behavior.
  • PRU0 and PRU1 are core-specific instances of that same bounded integration, not independent functional scopes.
  • SMBus quick, byte, word, and block operations are distinct host-visible operations within the same bounded PRU I2C integration.
  • They share the command-memory contract and scheduler, but their user/system outcome is specifically SMBus command execution rather than ordinary I2C read/write transactions.
Sources

examples/pru_i2c/firmware/pru_i2c_macro.h[787-800]

    SBCO    &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, PRU0_IEP_CMP_REG, 8

    ;Enable compare events
    .if $defined("PRU0")
    ZERO    &TEMP_REG1, 4
    SET     TEMP_REG1, TEMP_REG1, PRU0_IEP_CMP_ENABLE_BIT
    SBCO    &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4
    .endif  ;PRU0

    .if $defined("PRU1")
    ZERO    &TEMP_REG1, 4
    SET     TEMP_REG1, TEMP_REG1, PRU1_IEP_CMP_ENABLE_BIT
    SBCO    &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4
    .endif  ;PRU1

examples/pru_i2c/firmware/pru_i2c_main.asm[625-655]

ICSS_I2C_TX_CMD_CHECK:
    LBBO    &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4
    
    ;debug code 
    .if $defined("DEBUG_CODE")
    LDI  TEMP_REG4.w2, ICSS_I2C_TX_CMD
    .endif

    QBNE    ICSS_I2C_TX_CMD_CHECK_RETURN, TEMP_REG4.w2, ICSS_I2C_TX_CMD
    UPDATE_NEXT_LOCAL_STATE TX_MODE
    STATE_TASK_OVER

ICSS_I2C_TX_CMD_CHECK_RETURN:
    UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_QUICK_CHECK
    STATE_TASK_OVER


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  checks if the smbus Quick command has been passed.
;  if Quick command is passed then start Quick data procedure
;  else check for another command
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ICSS_SMBUS_QUICK_CHECK:
    LBBO    &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 4
    QBNE    ICSS_SMBUS_QUICK_CMD_CHECK_NEXT, TEMP_REG4.w2, ICSS_SMBUS_QUICK_CMD
   ;;;; UPDATE_NEXT_LOCAL_STATE QUICK_CMD_MODE
    STATE_TASK_OVER
    
ICSS_SMBUS_QUICK_CMD_CHECK_NEXT:
   ;;;; UPDATE_NEXT_LOCAL_STATE ICSS_SMBUS_SEND_BYTE
    STATE_TASK_OVER
Behavioral complexity 🔴 High 🧩 Concurrent ordering, State transitions

  • Before, the new firmware did not provide this AM261x PRU I2C timer/state-machine integration.
  • After, both PRU cores initialize and use a shared IEP timer with core-specific compare channels and status bits.
  • The new correctness condition is that each core must program, enable, clear, and wait on its own compare channel without overwriting the other core's timing state.
  • The changed code introduces a coordinated two-core ordering/resource invariant; the failure is not merely routine use of a timer helper.
Sources

examples/pru_i2c/firmware/pru_i2c_macro.h[787-800]

    SBCO    &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, PRU0_IEP_CMP_REG, 8

    ;Enable compare events
    .if $defined("PRU0")
    ZERO    &TEMP_REG1, 4
    SET     TEMP_REG1, TEMP_REG1, PRU0_IEP_CMP_ENABLE_BIT
    SBCO    &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4
    .endif  ;PRU0

    .if $defined("PRU1")
    ZERO    &TEMP_REG1, 4
    SET     TEMP_REG1, TEMP_REG1, PRU1_IEP_CMP_ENABLE_BIT
    SBCO    &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4
    .endif  ;PRU1
Potential damage 🟡 Medium 🩹 Temporary loss

  • An affected PRU1 instance can stop advancing before servicing I2C commands, making transactions unavailable.
  • A simultaneous PRU0 instance may experience incorrect timing because PRU1 writes the PRU0 compare register, but the evidence does not establish corruption of persistent state or an external transaction after the scheduler fault.
  • Reverting or replacing the firmware and resetting both PRU cores can restore operation.
  • A code rollback alone does not repair a currently running core; it must be reloaded/reset.
  • No automatic repair worker or retry path is present in the inspected firmware.
Sources

examples/pru_i2c/firmware/pru_i2c_macro.h[787-800]

    SBCO    &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, PRU0_IEP_CMP_REG, 8

    ;Enable compare events
    .if $defined("PRU0")
    ZERO    &TEMP_REG1, 4
    SET     TEMP_REG1, TEMP_REG1, PRU0_IEP_CMP_ENABLE_BIT
    SBCO    &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4
    .endif  ;PRU0

    .if $defined("PRU1")
    ZERO    &TEMP_REG1, 4
    SET     TEMP_REG1, TEMP_REG1, PRU1_IEP_CMP_ENABLE_BIT
    SBCO    &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_CFG_REG, 4
    .endif  ;PRU1
Assessed commit 533f890
Diagram

graph TD
  Host["Host controller"] --> Mem["Shared memory"] --> Scheduler["PRU scheduler"] --> Dispatch{"Command ready?"} --> Transfer["I2C transfer"] --> Bus["I2C bus"]
  Timer["IEP timer"] --> Scheduler
  Transfer -->|status| Mem
  Transfer -->|interrupt| Host
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use a hardware I2C controller
  • ➕ Avoids maintaining timing-sensitive software I2C states.
  • ➕ Can rely on established controller behavior.
  • ➖ Does not provide a PRU-based I2C master.
  • ➖ May not meet the intended pin or PRU-control requirements.

Recommendation: Keep the PRU firmware approach if PRU-controlled I2C is the requirement; a hardware controller would solve a different problem. Before treating this as a complete host example, add the stated R5F consumer and hardware validation of transfers, timing, and error responses.

Files changed (14) +5008 / -1

Enhancement (6) +4569 / -0
pru0_load_bin.hProvide a PRU0 firmware load array +956/-0

Provide a PRU0 firmware load array

• Adds the PRU0Firmware_0 instruction array for a host to load onto a PRU.

examples/pru_i2c/firmware/am261x-lp/pru0_load_bin.h

pru1_load_bin.hProvide a PRU1 firmware load array +956/-0

Provide a PRU1 firmware load array

• Adds the PRU1Firmware_0 instruction array for a host to load onto a PRU.

examples/pru_i2c/firmware/am261x-lp/pru1_load_bin.h

pru_i2c_firmware_version.hDefine firmware version constants +54/-0

Define firmware version constants

• Adds assembly constants and an encoded I2C firmware version value.

examples/pru_i2c/firmware/pru_i2c_firmware_version.h

pru_i2c_interface.hDefine the PRU I2C host interface +214/-0

Define the PRU I2C host interface

• Defines shared-memory addresses, register fields, commands, responses, frequency settings, and interrupt values used by the firmware.

examples/pru_i2c/firmware/pru_i2c_interface.h

pru_i2c_macro.hAdd timing, pin, and transfer assembly macros +1000/-0

Add timing, pin, and transfer assembly macros

• Adds macros for IEP scheduling, state transitions, host notifications, pin direction, and byte transmit and receive sequences.

examples/pru_i2c/firmware/pru_i2c_macro.h

pru_i2c_main.asmImplement the PRU I2C master state machine +1389/-0

Implement the PRU I2C master state machine

• Adds timer-paced setup, command dispatch, master transmit and receive, ACK handling, completion reporting, SCL inspection, slave reset, and loopback states. Several SMBus command checks are present without active transitions to implementations.

examples/pru_i2c/firmware/pru_i2c_main.asm

Other (8) +439 / -1
makefileInclude PRU I2C in top-level example builds +1/-1

Include PRU I2C in top-level example builds

• Adds pru_i2c to the example subdirectories so top-level make reaches its firmware builds.

examples/makefile

example.projectspecDefine the AM261x PRU0 CCS project +81/-0

Define the AM261x PRU0 CCS project

• Adds a PRU0 assembly project with AM261x compiler settings and a post-build firmware-array export.

examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec

linker.cmdMap PRU0 firmware into ICSS memory +43/-0

Map PRU0 firmware into ICSS memory

• Places instructions in PRU instruction RAM and data sections in PRU0 data RAM.

examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/linker.cmd

makefileBuild and export PRU0 firmware +48/-0

Build and export PRU0 firmware

• Configures the shared PRU build rules for AM261x PRU0 and names its output and firmware-array header.

examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile

example.projectspecDefine the AM261x PRU1 CCS project +81/-0

Define the AM261x PRU1 CCS project

• Adds a PRU1 project using the common assembly source and exporting a PRU1-named firmware array.

examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec

linker.cmdMap PRU1 firmware into ICSS memory +43/-0

Map PRU1 firmware into ICSS memory

• Places instructions in PRU instruction RAM and data sections in PRU1 data RAM.

examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd

makefileBuild and export PRU1 firmware +48/-0

Build and export PRU1 firmware

• Configures the shared PRU build rules for AM261x PRU1 and names its output and firmware-array header.

examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile

makefileAggregate AM261x PRU0 and PRU1 builds +94/-0

Aggregate AM261x PRU0 and PRU1 builds

• Adds an AM261x-only example target that invokes both firmware makefiles and skips unsupported devices. It declares no non-PRU build dependency or host target.

examples/pru_i2c/makefile

@qodo-code-review

qodo-code-review Bot commented May 4, 2026 •

Copy link
Copy Markdown

Code Review by Qodo


Action required

1. Multi-byte reads reject each next byte 🐞 ⭐
Description
rx_data_ack_begin? sets SDA high, exactly as the separate NACK state does, rather than pulling it
low for ACK. During a multi-byte receive, the slave sees a NACK after the first byte while the
firmware continues clocking bytes.
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 receive ACK and NACK states both put SDA high during the ninth clock.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[873-885]
## Recommended Fix
Drive SDA low in the ACK state and leave SDA released for the final-byte NACK; verify both paths with a multi-byte slave read.

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

Dismiss ↗ | View ↗

2. Ten-bit-addressed devices cannot reply 🐞 ⭐
Description
After acknowledging the first ten-bit address byte, ADDRESS_ACK_SCL_END restarts transmission with
the bit counter at zero without selecting the low address byte. The next eight bits come from the
same high-byte positions in R13.w2, so a ten-bit slave receives the prefix twice instead of its
address’s low byte.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Ten-bit mode retransmits its address prefix rather than the low address byte.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[946-1012]
- examples/pru_i2c/firmware/pru_i2c_macro.h[532-555]
## Recommended Fix
Select the low byte for the second address phase and verify the complete ten-bit write and read sequences, including the repeated-start/read prefix required for reads.

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

Dismiss ↗ | View ↗

3. Make-built firmware never starts I²C work 🐞 ⭐
Description
Both firmware makefiles leave DFLAGS empty, so assembly guarded by PRU0 or PRU1 omits the IEP
compare-event enable code. An AM261x make build produces firmware images, but neither image enables
the periodic event that advances its I²C state machine.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Make-built images omit the core-specific scheduler code because both `DFLAGS` values are empty.
## Fix Focus Areas
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[44-44]
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile[44-44]
## Recommended Fix
Set `-DPRU0` and `-DPRU1` respectively, consistent with the two CCS projects, and verify both make-built images.

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

Dismiss ↗ | View ↗

4. Starting one core can stop the other 🐞 ⭐
Description
I2C_SETUP_IEP_COUNTER zeroes the shared compare-configuration register before setting its own
core’s enable bit. When the second PRU starts, that write clears the first PRU’s compare enable, so
the first core stops receiving the ticks needed to progress.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Each core replaces the shared compare-enable configuration instead of preserving the other core’s bit.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[792-803]
## Recommended Fix
Preserve the existing compare configuration when enabling each core’s event; account for concurrent core initialization.

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

Dismiss ↗ | View ↗

5. Later commands leave the host waiting 🐞 ⭐
Description
ICSS_SMBUS_QUICK_CMD_CHECK_NEXT ends the task without updating the next state when the command is
not SMBus Quick. Any command dispatched after TX and RX—including read-clock, reset-slave, loopback
and unknown commands—stays at this check instead of reaching its handler or an error response.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An unmatched SMBus Quick command stalls the dispatcher, and later unmatched SMBus checks have the same missing state transitions.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[646-785]
## Recommended Fix
Restore the next-state transition for every unmatched command check so supported handlers and the invalid-command response are reachable.

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

Dismiss ↗ | View ↗

6. Burst reads return without received data 🐞 ⭐
Description
When setup enables the SMBus burst bit, the ordinary receive path selects rx_data_ack_scl_end_v2?,
which clears the burst bit and finishes without storing the received byte. A host using that
configuration can receive a completion after the first byte while its RX buffer remains unchanged.
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 burst receive completion branch bypasses the RX-buffer store and ends after one byte.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[896-924]
- examples/pru_i2c/firmware/pru_i2c_main.asm[455-471]
## Recommended Fix
Store received bytes in the burst branch and define its intended transfer length and completion behavior; test it through the reachable ordinary RX command.

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

Dismiss ↗ | View ↗

7. I2C_WAIT_FOR_IEP_CMP lacks timeout 📘
Description
The macro busy-waits in a loop without an explicit termination/timeout, and its documentation does
not provide a real peak cycle budget nor list modified registers. This risks deadlock if the event
never occurs and violates required macro documentation.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`I2C_WAIT_FOR_IEP_CMP` performs an unbounded busy-wait loop and its documentation is incomplete (no real peak cycle budget, no modified-register list).

## Issue Context
Compliance requires PRU loops to have explicit termination/bounds checks and requires macros to document peak cycle budget and modified registers.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[78-103]

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

Dismiss ↗ | View ↗

8. pru_i2c_main.asm register aliasing 📘
Description
The new PRU assembly introduces direct register aliasing via .asg/.set rather than structured
allocation. This increases the risk of register overlap/corruption and reduces reviewability.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Direct register aliasing is used (`.asg` and `.set`) instead of structured register allocation.

## Issue Context
The compliance guideline prefers `.struct`/`.sassign` to reduce register overlap and improve maintainability.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[58-85]

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

Dismiss ↗ | View ↗

9. Unconditional IEP value override 🐞
Description
I2C_SETUP_IEP_COUNTER unconditionally overwrites IEP_COUNTER_NEXT_VAL1/2 with 0x9c3/0,
discarding the values loaded from DMEM. This forces initial compare scheduling toward the 100kHz
constant and can produce incorrect timing relative to the configured bus frequency.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`I2C_SETUP_IEP_COUNTER` loads `IEP_COUNTER_NEXT_VAL1/2` from DMEM, but then immediately overwrites them with hardcoded values (`0x9c3`, `0x0`) because the intended `.if $defined("DEBUG_CODE")` guard is commented out.

### Issue Context
`0x9c3` matches the 100kHz increment constant in `pru_i2c_interface.h`, but the firmware supports multiple frequencies and uses `I2C_GLOBAL_FREQ_REG` to select among them.

### Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[768-776]
- examples/pru_i2c/firmware/pru_i2c_interface.h[175-193]

### Suggested fix
Either:
1) Restore the debug guard (uncomment/fix the `.if $defined("DEBUG_CODE")` / `.endif` so the hardcoded load only happens in debug builds), or
2) Remove the hardcoded overwrite entirely and initialize the compare value from DMEM/current IEP count + configured increment.

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

Dismiss ↗ | View ↗

10. Wrong CMP register programmed 🐞
Description
I2C_SETUP_IEP_COUNTER writes the initial compare value to PRU0_IEP_CMP_REG unconditionally, so
PRU1 never programs PRU1_IEP_CMP_REG. This can prevent PRU1 compare events from firing on the
intended channel.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`I2C_SETUP_IEP_COUNTER` always writes compare values to `PRU0_IEP_CMP_REG`. When building for PRU1, the compare register is `PRU1_IEP_CMP_REG`, so PRU1’s compare channel may never be configured.

### Issue Context
`pru_i2c_main.asm` maps `PRU0_IEP_CMP_REG` to `ICSS_IEP_CMP0_REG` and `PRU1_IEP_CMP_REG` to `ICSS_IEP_CMP1_REG`.

### Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[740-802]
- examples/pru_i2c/firmware/pru_i2c_main.asm[74-79]

### Suggested fix
Conditionalize the `SBCO` target register in `I2C_SETUP_IEP_COUNTER` the same way `I2C_IEP_INTC_CLEAR_EVENT` does:
- if PRU0: write `PRU0_IEP_CMP_REG`
- if PRU1: write `PRU1_IEP_CMP_REG`

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

Dismiss ↗ | View ↗

11. LOOPBACK_COPY_DATA unchecked buffer access 📘
Description
The loopback copy performs LBBO/SBBO using a loop-derived offset (R15.b2) without verifying
the offset is in-bounds before each access and without validating the requested count against the
actual TX/RX buffer size. This can lead to out-of-bounds reads/writes if configuration is invalid or
corrupted.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`LOOPBACK_COPY_DATA` reads/writes bytes from TX/RX buffers using an incrementing offset without checking bounds before the memory accesses, and without validating the requested length against the buffer capacity.

## Issue Context
PRU firmware must prevent out-of-bounds memory access and ensure loop-derived offsets are validated before accessing memory.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[1357-1380]

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

Dismiss ↗ | View ↗

12. Wrong CMP status bit 🐞
Description
I2C_WAIT_FOR_IEP_CMP always polls PRU0_IEP_CMP_STATUS_BIT, so a PRU1 firmware build can wait on
the wrong compare-status bit and never observe its own CMP event. This can deadlock the PRU1 task
loop at startup.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`I2C_WAIT_FOR_IEP_CMP` polls `PRU0_IEP_CMP_STATUS_BIT` unconditionally. For PRU1, the CMP status bit is different (PRU1 bit), so PRU1 may spin forever waiting for an event that will never set the polled bit.

### Issue Context
`pru_i2c_main.asm` defines distinct status bits for PRU0 vs PRU1, and the firmware has separate PRU0/PRU1 build projects.

### Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[96-103]
- examples/pru_i2c/firmware/pru_i2c_main.asm[74-79]

### Suggested fix
Make `I2C_WAIT_FOR_IEP_CMP` choose the correct status bit based on `$defined("PRU0")/$defined("PRU1")` (mirroring the pattern already used in `I2C_IEP_INTC_CLEAR_EVENT`), or parameterize the macro to accept the status-bit constant.

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

Dismiss ↗ | View ↗

13. pru_i2c_macro.h header filename mismatch 📘
Description
The file header comment states a different filename (icss_i2c_macro.h) than the actual file
(pru_i2c_macro.h). This breaks the required formatting standard for accurate file-name headers.
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 file header comment lists the wrong filename, which violates the formatting/header requirements.

## Issue Context
The repository formatting standard requires source files to contain a header denoting the correct file name.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[31-35]

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

Dismiss ↗ | View ↗


View medium (26)
Remediation recommended
14. Macro include guard uses the wrong name pattern 📘 ⭐
Description
The include guards in pru_i2c_macro.h and pru_i2c_firmware_version.h use __icss_i2c_macros_h
and __firmware_version_h instead of the project’s four-underscore, uppercase guard names. In each
assembly header, the nonconforming name appears in the .if !$defined test and .set definition,
and is also referenced by the closing .endif comment.
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 include guards in `pru_i2c_macro.h` and `pru_i2c_firmware_version.h` use two leading underscores and lowercase bodies instead of the project’s four-underscore, uppercase form.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[37-38]
- examples/pru_i2c/firmware/pru_i2c_macro.h[1000-1000]
- examples/pru_i2c/firmware/pru_i2c_firmware_version.h[37-54]

## Recommended Fix
Rename the guard in `pru_i2c_macro.h` to `____ICSS_I2C_MACROS_h` and the guard in `pru_i2c_firmware_version.h` to `____FIRMWARE_VERSION_h`. Update each header’s `.if !$defined(...)` test, `.set` definition, and closing `.endif` comment so all references within that header match.

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

Dismiss ↗ | View ↗

15. Successful resets signal an error 🐞 ⭐
Description
The reset-command handler writes COMMAND_SUCCESS but sends RESET_SCL_SDA_HIGH to
RAISE_HOST_INTERRUPT_MEM_FOR_ERROR. When a reset finishes, the firmware follows the error
notification and acknowledgment path rather than the ready path used by successful setup and
transfers.
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 reset writes a success response but transitions into the error notification state.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[550-561]
- examples/pru_i2c/firmware/pru_i2c_main.asm[499-522]
## Recommended Fix
Route successful reset completion through the appropriate success/ready notification and next state; retain the error path only for failures.

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

Dismiss ↗ | View ↗

16. Uppercase macro names break the naming rule 📘 ⭐
Description
The assembly macros ENABLE_XIN_XOUT_SHITFTING, I2C_WAIT_FOR_IEP_CMP, I2C_IEP_INTC_CLEAR_EVENT,
SET_SCL_PIN_HIGH and the rest of the macro set in pru_i2c_macro.h are all declared in ALL_CAPS
with .macro. The rule requires lowercase underscore_case macro names, so every new macro in this
file departs from it and call sites in pru_i2c_main.asm inherit the same spelling.

Dismiss ↗ | View ↗

17. Lowercase labels break the uppercase label rule 📘 ⭐
Description
Labels such as init: in pru_i2c_main.asm and tx_data_sda_begin?:,
read_address_register_done?: and similar in pru_i2c_macro.h are written in lowercase, while the
rule requires uppercase A–Z, digits and underscores. The same mixed style also appears in
TASK_LOOP_100Khz:, so the label set in these files is inconsistent with the convention.

Dismiss ↗ | View ↗

18. Task labels skip the FN_ and _TASK pattern 📘 ⭐
Description
The scheduler task entry labels TASK_LOOP_100Khz, TASK_LOOP_400Khz and TASK_LOOP_1Mhz lack the
required FN_ prefix and _TASK suffix, and they contain lowercase letters from the frequency
suffixes. The rule requires task names of the form FN_<TASK_NAME>_TASK in uppercase snake case, so
these task entries do not match the convention.

Dismiss ↗ | View ↗

19. Macro docs leave pseudocode sections blank 📘 ⭐
Description
Many macro doc blocks in pru_i2c_macro.h, for example I2C_WAVE_FUNCTION0, have a Pseudo code:
header followed by no pseudocode at all. The rule requires a stepwise, language-agnostic pseudocode
section for each macro, so these blocks fail the check even though they have headers.

Dismiss ↗ | View ↗

20. Macros omit the registers they modify 📘 ⭐
Description
SET_SDA_PIN_INPUT_DIRECTION writes through r28 and r29, while I2C_IEP_INTC_CLEAR_EVENT
writes TEMP_REG1, TEMP_REG2, and the IEP next-value registers, but their doc blocks omit
register-usage lists. When a caller keeps live values in those registers, the missing clobber
information can lead to silent corruption; the documentation gap also affects other low-level macros
that use temporary and IEP counter registers.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`SET_SDA_PIN_INPUT_DIRECTION` and similar PRU assembly macros modify registers without documenting their register usage, leaving callers unable to identify clobbered values.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[943-966]

## Recommended Fix
Add a `Register usage:` block to each affected macro comment that lists input, output, clobbered, and preserved registers. Include `r28` and `r29` for `SET_SDA_PIN_INPUT_DIRECTION`, and check each list against the registers its macro body actually writes.

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

Dismiss ↗ | View ↗

21. Assembly lines use runs of multiple spaces 📘 ⭐
Description
Lines such as .asg    R1, TEMP_REG1 in pru_i2c_main.asm contain four consecutive spaces, and
many other instruction lines in the main file and macro file follow the same alignment pattern. The
rule restricts non-markdown sources to single spaces, so each such line violates it.

Dismiss ↗ | View ↗

22. Directive lines indented by one space 📘 ⭐
Description
The .include directives in pru_i2c_main.asm start with one leading space, not the four-space
indent the rule requires for assembly. The same pattern appears in the .if line of
pru_i2c_firmware_version.h, so indentation within these files is not consistent.

Dismiss ↗ | View ↗

23. Comment uses the abbreviation i.e. 📘 ⭐
Description
The comment in RAISE_HOST_INTERRUPT_FOR_READY reads i.e. read or write in pru_i2c_main.asm,
which uses the abbreviation the rule prohibits in source comments. The rule requires the phrase
that is in its place, so the comment does not meet the convention.

Dismiss ↗ | View ↗

24. Firmware macros lack the m_ prefix 📘 ⭐
Description
The macros in pru_i2c_macro.h are defined as ENABLE_XIN_XOUT_SHITFTING, I2C_WAIT_FOR_IEP_CMP,
SEND_TX_DATA_CHECK_FOR_ACK, SET_SDA_PIN_INPUT_DIRECTION and about twenty others, none beginning
with m_, and pru_i2c_main.asm invokes them under the same un-prefixed names. The convention is
what lets a reader tell macro expansions apart from instructions and labels, so every new macro in
this PR breaks it and the rule has no documented exception for this firmware.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

Issue description
Every new assembly macro in the PRU I2C firmware lacks the mandatory `m_` prefix required by the project's assembly naming convention. Examples include `ENABLE_XIN_XOUT_SHITFTING`, `I2C_WAIT_FOR_IEP_CMP`, `SEND_TX_DATA_CHECK_FOR_ACK`, and `SET_SDA_PIN_INPUT_DIRECTION`.

Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[71-1000]
- examples/pru_i2c/firmware/pru_i2c_main.asm[92-1389]

Recommended Fix
Rename every `.macro` definition in pru_i2c_macro.h to start with `m_` (for example `m_enable_xin_xout_shifting`), and update every invocation in pru_i2c_main.asm to the new names. Verify no un-prefixed alias remains and that the firmware still assembles for both PRU0 and PRU1.

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

Dismiss ↗ | View ↗

25. PRU firmware headers lack license tags 📘 ⭐
Description
pru_i2c_interface.h carries a Texas Instruments BSD copyright block but no
SPDX-License-Identifier line anywhere in the file, and pru_i2c_macro.h and
pru_i2c_firmware_version.h likewise lack one. The tag is absent from every header added under the
PRU firmware directory, so license tooling cannot identify the license of these files.
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 headers pru_i2c_interface.h, pru_i2c_macro.h and pru_i2c_firmware_version.h contain copyright blocks but no SPDX-License-Identifier tag.

Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_interface.h[1-2]
- examples/pru_i2c/firmware/pru_i2c_macro.h[1-2]
- examples/pru_i2c/firmware/pru_i2c_firmware_version.h[1-2]

Recommended Fix
Add a line such as `SPDX-License-Identifier: BSD-3-Clause` (using the comment syntax of each file: `/* */` in the C header, `;` in the assembly headers) above the existing copyright block, matching the license actually granted by the TI BSD text.

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

Dismiss ↗ | View ↗

26. I2C macros lack peak cycle counts 📘 ⭐
Description
Macros such as I2C_IEP_INTC_CLEAR_EVENT, SEND_TX_DATA_CHECK_FOR_ACK,
READ_RX_DATA_AND_SEND_ACK, and SET_SDA_PIN_INPUT_DIRECTION drive the SCL/SDA bit-bang timing,
but their headers leave the PEAK cycles: field blank or omit it entirely, so the worst-case timing
of each state is never stated. Without that number, a later change to the instruction sequence can
push a state past the 400 kHz or 1 MHz timing budget without anyone noticing.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

Issue description
Timing-critical I2C bit-bang macros in pru_i2c_macro.h document an empty or missing `PEAK cycles:` field. Examples include I2C_IEP_INTC_CLEAR_EVENT, SEND_TX_DATA_CHECK_FOR_ACK, READ_RX_DATA_AND_SEND_ACK and SET_SDA_PIN_INPUT_DIRECTION.

Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[108-124]
- examples/pru_i2c/firmware/pru_i2c_macro.h[571-578]
- examples/pru_i2c/firmware/pru_i2c_macro.h[807-814]
- examples/pru_i2c/firmware/pru_i2c_macro.h[944-960]

Recommended Fix
For each timing-critical macro, count the worst-case PRU cycles along the longest branch path (including the LBBO/SBBO and QBxx latencies) and write the number in the `PEAK cycles:` field, e.g. `PEAK cycles: 12 (worst case, branch taken)`. Note any assumptions such as branch outcome or fixed loop count. Do the same for the per-state budget stated as 20 cycles in pru_i2c_main.asm lines 234-235.

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

Dismiss ↗ | View ↗

27. Unused version header is included 📘 ⭐
Description
pru_i2c_firmware_version.h is included at the top of pru_i2c_main.asm, but none of its symbols
(I2C_FIRMWARE_VERSION, FIRMWARE_VERSION_*) are referenced anywhere in the main file. A code
comment at lines 106 says a version section still needs to be added, so the include is currently
dead and it adds a dependency with no use.
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_i2c_main.asm includes pru_i2c_firmware_version.h, but none of the symbols it defines are referenced in the file. The include is unused.

Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[46-46]
- examples/pru_i2c/firmware/pru_i2c_main.asm[106-106]

Recommended Fix
Remove the `.include "pru_i2c_firmware_version.h"` line, or add the intended version-store code that uses `I2C_FIRMWARE_VERSION` in the same change so the include has a consumer.

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

Dismiss ↗ | View ↗

28. Hardcoded addresses have no layout notes 📘 ⭐
Description
SET_SDA_PIN_INPUT_DIRECTION and SET_SDA_PIN_OUTPUT_DIRECTION hardcode the PRU register address
0x50D00818 with only a comment naming the AM261x part; nothing states which peripheral register
lives there or what bit 9 controls. The ERROR_LOOP in pru_i2c_main.asm also writes an undocumented
literal 0x00400000 to an INTC register, so the memory map used by the firmware cannot be read from
the 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
Hardcoded PRU/peripheral addresses in the new firmware have no documented purpose. `0x50D00818` in SET_SDA_PIN_INPUT_DIRECTION and SET_SDA_PIN_OUTPUT_DIRECTION (pru_i2c_macro.h) and `0x00400000` written in ERROR_LOOP (pru_i2c_main.asm) are not described, and the main file has no memory layout block.

Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[960-998]
- examples/pru_i2c/firmware/pru_i2c_main.asm[31-35]
- examples/pru_i2c/firmware/pru_i2c_main.asm[158-165]

Recommended Fix
Add a comment above each hardcoded address naming the register (and the bit it touches, e.g. bit 9 for SDA direction), and add a header block to pru_i2c_main.asm listing the address ranges used (INTC, IEP, DMEM0, PRU shared RAM, and the pad-control register) with their purpose. Replace `0x00400000` with a named constant from the INTC definitions where available.

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

Dismiss ↗ | View ↗

29. Instance memory layout lacks size checks 📘 ⭐
Description
The ICSS_I2C_INSTANCE_SIZE, ICSS_I2C_INSTANCE_TX_OFFSET and ICSS_I2C_INSTANCE_RX_OFFSET
constants define the per-instance layout that the firmware writes through R10, R11 and R12,
yet nothing asserts that the TX and RX buffers fit inside the instance size. Changing any of these
three values would still assemble silently, so an overlapping or overflowing layout would show up
only at runtime.
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 I2C instance layout constants (size 0x300, TX offset 0x100, RX offset 0x200) are defined without any assembler-time check that the TX and RX regions fit inside the instance. Changing these values would not be caught at build time.

Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_interface.h[49-52]
- examples/pru_i2c/firmware/pru_i2c_macro.h[37-50]

Recommended Fix
In pru_i2c_macro.h, after the include block, add `.if (ICSS_I2C_INSTANCE_TX_OFFSET + <max TX size>) > ICSS_I2C_INSTANCE_SIZE` followed by `.emsg "TX buffer exceeds instance size"` and the same for the RX offset, with `.endif` after each. Use the actual maximum buffer length as the right-hand term.

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

Dismiss ↗ | View ↗

30. Macro arguments are never validated 📘 ⭐
Description
Macros such as SEND_TX_DATA_CHECK_FOR_ACK take register and label arguments (arg1, arg2,
arg3) that are used directly as operands in QBBC, LSL, LBBO and LDI $CODE(...), with no
.if or .err guard. A caller who passes a wrong register width or a missing label gets an
assembler error at an unrelated line or a silently wrong instruction, not a clear message at the
call site.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

Issue description
SEND_TX_DATA_CHECK_FOR_ACK and similar macros in pru_i2c_macro.h use their arguments (register `arg1`, labels `arg2` and `arg3`) directly without checking them at assembly time. A wrong argument silently produces an incorrect instruction or fails with an error far from the call site.

Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[590-595]
- examples/pru_i2c/firmware/pru_i2c_macro.h[699-699]

Recommended Fix
At the top of each parameterised macro, add `.if` checks that the register argument is in the allowed R0-R31 range (or one of the expected temp registers) and that label arguments are non-empty, with `.err <message>` on failure, so bad calls stop the build with a clear message.

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

Dismiss ↗ | View ↗

31. Examples index misses the new PRU I2C project 📘 ⭐
Description
The ## Projects list in examples/readme.md has no pru_i2c entry, although this PR adds the
examples/pru_i2c project directory and wires it into examples/makefile. Users browsing the
examples index will not discover the project, and the required one-to-two-sentence description is
absent.
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 `pru_i2c` example project is not listed under `## Projects` in `examples/readme.md`, so the section-level index is incomplete.

Fix Focus Areas
- examples/readme.md[1-40]
- examples/makefile[6-6]

Recommended Fix
Add a `pru_i2c` list item under `## Projects` in `examples/readme.md`, following the existing format (project name on one line, then a `*` bullet with a one-to-two sentence description of the PRU I2C master firmware and R5F example).

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

Dismiss ↗ | View ↗

32. Portability table omits the new project 📘 ⭐
Description
The Supported processors per-project table in examples/readme.md has no row for pru_i2c, even
though this PR adds the project and targets am261x. The table is the only place that tells readers
which processors the project was validated or ported to, and it stays silent for this project.
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 `Supported processors per-project` table in `examples/readme.md` lacks a row for the new `pru_i2c` project, so its per-processor status is undocumented.

Fix Focus Areas
- examples/readme.md[40-94]
- examples/makefile[6-6]

Recommended Fix
Add a `pru_i2c` row to the table with allowed status values for each processor column (for example `Y` for am261x and `Yport` or `Npru` for others as validated), and add `<!-- FIXME: ... -->` comments next to any cell whose compatibility is not yet verified.

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

Dismiss ↗ | View ↗

33. New project ships without a README 📘 ⭐
Description
The new examples/pru_i2c project directory contains only makefile and firmware sources, with no
README.md alongside its build manifest. Every other example in the tree ships its own readme, so a
reader of this project has no local description of how to build or run it.
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 `examples/pru_i2c` project directory has a build manifest but no `README.md`, so it does not meet the requirement for a README in each new project directory.

Fix Focus Areas
- examples/pru_i2c/makefile[1-2]

Recommended Fix
Add `examples/pru_i2c/README.md` describing the project purpose, the am261x firmware targets built by `makefile`, and the build command (for example `make` or `make pru`), and commit it with the PR.

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

Dismiss ↗ | View ↗

34. Firmware error path spins with no exit marker 📘 ⭐
Description
ERROR_LOOP in pru_i2c_main.asm branches back to itself with QBA ERROR_LOOP and has no
iteration cap and no INTENTIONALLY_UNBOUNDED_LOOP marker, and the three TASK_LOOP_* loops that
drive the I2C state machine are likewise unmarked infinite loops. A reader cannot tell whether the
endless spin after an invalid frequency is intended, and the rule requires an explicit marker on
each intentional unbounded loop.
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 `ERROR_LOOP` label and the `TASK_LOOP_*` loops in the PRU main firmware are unbounded `QBA` jumps with no iteration limit and no `INTENTIONALLY_UNBOUNDED_LOOP` marker comment, so the checklist cannot tell whether the endless spin is intended.

Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[158-165]
- examples/pru_i2c/firmware/pru_i2c_main.asm[174-226]

Recommended Fix
Add a comment with the marker phrase `INTENTIONALLY_UNBOUNDED_LOOP` directly above `ERROR_LOOP` and each `TASK_LOOP_*` label, stating why the loop is meant to run forever (for example, waiting for a host reset). If the error loop is not meant to be terminal, replace it with a bounded retry or a return to the reset state.

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

Dismiss ↗ | View ↗

35. Bit-timing branches go unverified 📘 ⭐
Description
SEND_TX_DATA_CHECK_FOR_ACK branches on the data bit with QBBC and takes differently shaped paths
(set versus clear, with a JMP on one side), but nothing above the branch records per-path cycle
counts or a padding plan. The surrounding comments say the states are kept to match timing, so a
mismatch between the paths would shift the SDA edge on the wire and the timing claim has no
documented basis.
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 timing-critical bit-level branches in the I2C macros (for example the `QBBC tx_data_sda_low?` branch in `SEND_TX_DATA_CHECK_FOR_ACK`) have no per-path cycle counts or padding notes, even though the code states that these paths are timed to match.

Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[590-620]

Recommended Fix
Above each timing-critical conditional branch, add a comment that states it is timing-critical, lists the cycle count for each path from the decision to the join point, and lists any padding instructions, and fill in the empty `PEAK cycles:` fields with the measured values.

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

Dismiss ↗ | View ↗

36. SMBus requests never complete 🐞 ⭐
Description
The SMBus command checks leave their matching next-state transitions commented out and call
STATE_TASK_OVER without a response. Even after dispatch advances through unmatched commands, a
host submitting any advertised SMBus command remains on its matching check with no completion or
failure interrupt.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Advertised SMBus commands match dispatch states that neither perform work nor return a response.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[643-785]
- examples/pru_i2c/firmware/pru_i2c_interface.h[116-135]
## Recommended Fix
Implement each exposed command or return an explicit unsupported-command response and host notification; do not leave a matching state stationary.

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

Dismiss ↗ | View ↗

37. The second core links data to wrong RAM 🐞 ⭐
Description
The PRU1 linker script puts PRU1_DMEM_1 at 0x2000 and assigns its data and stack sections there.
Existing AM261x PRU1 linker scripts put local PRU1 data RAM at 0x0000, so sections linked by this
project use the other RAM window instead.
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 PRU1 linker script reverses local and remote data-RAM addresses.
## Fix Focus Areas
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd[15-42]
## Recommended Fix
Map PRU1 local DMEM to zero and PRU0 remote DMEM to `0x2000`, as in the sibling AM261x PRU1 scripts, then inspect linked section addresses.

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

Dismiss ↗ | View ↗

38. Other selected data pins stay unconfigured 🐞 ⭐
Description
SET_SDA_PIN_INPUT_DIRECTION and its output counterpart always modify pad-control address
0x50D00818, although setup takes the SDA pin number from the host and uses it for PRU input and
output operations. When the host selects a different SDA pin, the firmware changes the fixed pad’s
direction instead of that pin’s, disrupting ACK sampling and receive transitions.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Direction macros configure one fixed SDA pad while the command interface accepts a selectable SDA pin.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[959-997]
- examples/pru_i2c/firmware/pru_i2c_main.asm[292-306]
## Recommended Fix
Either configure the pad corresponding to the selected pin or validate and document that only the fixed SDA pin is supported.

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

Dismiss ↗ | View ↗

39. Long postBuildStep command line 📘
Description
The new postBuildStep embeds a very long single-line command, which violates the repository
line-length/formatting expectations for generated/config constructs. This reduces readability and
makes future edits error-prone.
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 `postBuildStep` attribute contains a very long single-line command, violating the repo's line-length expectations for generated/config constructs.

## Issue Context
This is in a CCS `example.projectspec` file where long attributes can typically be wrapped or moved to a script to keep lines within limits.

## Fix Focus Areas
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[56-58]

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

Dismiss ↗ | View ↗


View low (1)
Informational
40. Tab characters land in firmware sources 📘 ⭐
Description
pru_i2c_firmware_version.h contains literal tabs on its .if, __firmware_version_h .set, and
.endif lines, while pru_i2c_main.asm line 103 and pru_i2c_macro.h line 1000 also contain tabs.
Because the check applies file-wide to these .h and .asm files, later lint runs will keep
flagging them; the tabs are not limited to excluded linker files.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Several PRU firmware `.h` and `.asm` files contain literal tab characters, which the checklist forbids in `.asm`, `.inc`, `.c`, and `.h` files.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_firmware_version.h[37-54]
- examples/pru_i2c/firmware/pru_i2c_macro.h[1000-1000]
- examples/pru_i2c/firmware/pru_i2c_main.asm[103-103]

## Recommended Fix
Replace every tab with spaces in the listed files, using `expand -t 4` or an editor’s convert-to-spaces command. Then rerun `grep -P "\t"` over the changed `.asm`, `.inc`, `.c`, and `.h` files to confirm no matches remain.

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

Dismiss ↗ | View ↗


Comment on lines +1 to +2
export OPEN_PRU_PATH?=$(abspath ../../../../../..)
include $(OPEN_PRU_PATH)/imports.mak

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. open_pru_path uses fixed abspath 📘 Rule violation ☼ Reliability

The new makefiles compute OPEN_PRU_PATH using a fixed relative $(abspath ../../../../../..)
which can break when invoked from a different working directory. This violates the requirement to
derive the repo root from the current makefile location for reliable includes.
Agent Prompt
## Issue description
Makefiles set `OPEN_PRU_PATH` using `$(abspath ../../../../../..)` which depends on the directory `make` is invoked from, causing fragile includes.

## Issue Context
The compliance requirement asks to derive the repository root relative to the current makefile path (e.g., using `$(dir $(lastword $(MAKEFILE_LIST)))`).

## Fix Focus Areas
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[1-2]
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile[1-2]
- examples/pru_i2c/example/am261x-lp/r5fss0-0_freertos/ti-arm-clang/makefile[5-7]

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

Comment on lines +37 to +46
.if !$defined("__icss_i2c_macros_h")
__icss_i2c_macros_h .set 1

;************************************* includes *************************************

;;.include "icss_constant_defines.inc"
;;.include "icss_cfg_regs.h"
;;.include "icss_iep_regs.h"
;;.include "icss_intc_regs.inc"
;;;.include "endat_icss_reg_defs.h"

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. Nonstandard pru header guard 📘 Rule violation ⚙ Maintainability

The new PRU assembly include file uses a noncompliant header guard symbol and mechanism. This risks
multiple-include issues and violates the required four-underscore $isdefed guard pattern.
Agent Prompt
## Issue description
`pru_i2c_macro.h` uses a nonstandard header guard (`$defined` + `__icss_i2c_macros_h`) instead of the required `$isdefed` + four-underscore guard symbol.

## Issue Context
Assembly include files may be included from multiple compilation units/macros; guard consistency prevents multiple-include errors.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[37-46]

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

Comment on lines +58 to +66
.asg R1, TEMP_REG1 ; temporary register 1
.asg R2, TEMP_REG2 ; temporary register 2
.asg R3, TEMP_REG3 ; temporary register 3
.asg R4, TEMP_REG4 ; temporary register 4
.asg R5, TEMP_REG5 ; temporary register 5
.asg R6, TEMP_REG6 ; temporary register 6
.asg R7, TEMP_REG7 ; temporary register 7
.asg R8, TEMP_REG8 ; temporary register 8

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

3. Direct .asg register aliases 📘 Rule violation ☼ Reliability

The new PRU firmware defines working registers via direct PRU register aliasing (e.g., `.asg R1,
TEMP_REG1`). This violates the requirement to prefer structured register mappings
(.struct/.sassign) to reduce overlap/corruption risk.
Agent Prompt
## Issue description
PRU registers are assigned via `.asg` aliases (e.g., `TEMP_REG1` -> `R1`) instead of using a `.struct` + `.sassign` register map.

## Issue Context
Structured register mapping helps prevent accidental overlap/corruption and improves maintainability when macros/functions evolve.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[58-66]

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

Comment on lines +54 to +75
;************************************************************************************
;
; Macro: ENABLE_XIN_XOUT_SHITFTING
;
; Enable support of shifting during XIN/XOUT operation
;
; PEAK cycles:
; 3 cycles
; Pseudo code:
; ICSS_CFG_SPPC[0-7] |= 0x02
;
; Parameters:
; None
;
; Returns:
; None
;
ENABLE_XIN_XOUT_SHITFTING .macro
LBCO &TEMP_REG1, ICSS_CFG_CONST, ICSS_CFG_SPPC, 4
OR TEMP_REG1.b0, TEMP_REG1.b0, 0x02
SBCO &TEMP_REG1, ICSS_CFG_CONST, ICSS_CFG_SPPC, 4
.endm

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

4. Macro docs omit modified registers 📘 Rule violation ⚙ Maintainability

New PRU assembly macros document pseudocode and peak cycles but do not document which registers they
modify. This violates the required macro documentation standard and increases the risk of
register-corruption regressions.
Agent Prompt
## Issue description
Macro documentation is missing the required "registers modified" list.

## Issue Context
This firmware uses many macros that touch shared working registers; documenting clobbers is required to prevent subtle corruption when macros are composed.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[54-75]

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

Comment on lines +1 to +10
/*
* Copyright (C) 2024 Texas Instruments Incorporated
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*

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

5. Files missing filename header 📘 Rule violation ⚙ Maintainability

New source/header files include a TI copyright block but do not include a header denoting the file
name. This violates the requirement that every source/header file include both file-name header and
TI copyright statement.
Agent Prompt
## Issue description
New files are missing a header line that denotes the file name.

## Issue Context
Compliance requires both a file-name header and a TI copyright statement in every source/header file.

## Fix Focus Areas
- examples/pru_i2c/example/pru_i2c_example.c[1-10]
- examples/pru_i2c/example/am261x-lp/r5fss0-0_freertos/main.c[1-12]
- examples/pru_i2c/example/pru_i2c_example.h[1-12]

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

Comment on lines +34 to +40
typedef struct I2c_Params_s
{
PRUICSS_Handle pruicssHandle;
/**< PRU-ICSS Handle for which the Tamagawa driver will be based on */
uint32_t baudRate;

} I2c_Params; No newline at end of 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.

Action required

6. Missing newline at eof 📘 Rule violation ⚙ Maintainability

pru_i2c_example.h is missing a trailing newline at end-of-file. This violates the source
formatting requirement for consistent EOL handling and can cause tooling/diff issues.
Agent Prompt
## Issue description
The header file is missing a newline at end-of-file.

## Issue Context
Some compilers, linters, and patch tools expect LF-terminated final lines; missing EOL can create diff noise and portability issues.

## Fix Focus Areas
- examples/pru_i2c/example/pru_i2c_example.h[34-40]

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

Comment on lines +138 to +144
I2c_pruicssInit();

while(1)
{

}

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

7. High-priority busy loop 🐞 Bug ☼ Reliability

The highest-priority FreeRTOS task calls pru_i2c_main(), which then spins forever in an empty
while(1) without any blocking/yield, starving the idle task and all lower-priority tasks. This can
break system behavior (timers/idle processing) and wastes CPU/power when running the example.
Agent Prompt
### Issue description
`pru_i2c_main()` runs in the highest-priority FreeRTOS task and contains a tight `while(1)` with no blocking call. This keeps the task runnable forever and prevents the idle task (and any lower-priority tasks) from executing.

### Issue Context
This is an example app, but as written it will consume 100% CPU and can destabilize the system if any other tasks/timers/idle-time work are expected.

### Fix Focus Areas
- examples/pru_i2c/example/pru_i2c_example.c[128-149]
- examples/pru_i2c/example/am261x-lp/r5fss0-0_freertos/main.c[40-75]

### Suggested fix
- Add a blocking call inside the loop, e.g. `vTaskDelay(pdMS_TO_TICKS(1));` (or an appropriate period) so the scheduler can run idle/other tasks.
- Optionally lower the task priority and/or restructure so `freertos_main()` creates worker tasks and then deletes itself, matching the comment in `main.c`.

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

@achala-ti achala-ti changed the title am261x: pru i2c: Add PRU I2C Master firmware and R5F example [WIP]am261x: pru i2c: Add PRU I2C Master firmware and R5F example May 4, 2026
@qodo-code-review

qodo-code-review Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 641d03e

Comment on lines +71 to +75
ENABLE_XIN_XOUT_SHITFTING .macro
LBCO &TEMP_REG1, ICSS_CFG_CONST, ICSS_CFG_SPPC, 4
OR TEMP_REG1.b0, TEMP_REG1.b0, 0x02
SBCO &TEMP_REG1, ICSS_CFG_CONST, ICSS_CFG_SPPC, 4
.endm

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. Uppercase opcodes in macros 📘 Rule violation ⚙ Maintainability

New PRU assembly code uses uppercase instruction mnemonics (e.g., LBCO, OR, SBCO) instead of
the required lowercase style. This violates the opcode casing consistency requirement for modified
code.
Agent Prompt
## Issue description
Instruction opcodes in new/modified PRU assembly are written in uppercase, violating the required lowercase opcode style.

## Issue Context
The style rule requires consistent lowercase mnemonics for readability and review consistency.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[71-75]

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

Comment on lines +96 to +103
I2C_WAIT_FOR_IEP_CMP .macro

WAIT_FOR_INT?:
LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4
QBBC WAIT_FOR_INT?, TEMP_REG1, PRU0_IEP_CMP_STATUS_BIT
;;;;QBBC WAIT_FOR_INT?, R31, 31

.endm

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. Pru1 iep compare mismatch 🐞 Bug ≡ Correctness

I2C_WAIT_FOR_IEP_CMP always polls PRU0_IEP_CMP_STATUS_BIT, while I2C_SETUP_IEP_COUNTER
unconditionally programs PRU0_IEP_CMP_REG but conditionally enables PRU1 compare events; in PRU1
builds this can prevent any IEP compare event from being observed and the firmware can spin forever
in the wait loop.
Agent Prompt
### Issue description
PRU1 firmware builds define `PRU1`, but `I2C_WAIT_FOR_IEP_CMP` always waits on `PRU0_IEP_CMP_STATUS_BIT`, and `I2C_SETUP_IEP_COUNTER` always writes the compare value to `PRU0_IEP_CMP_REG` while enabling PRU1 compare events. This mismatch can block PRU1 execution permanently in the wait loop.

### Issue Context
- PRU0/PRU1 builds are distinguished by preprocessor defines (`-DPRU0` vs `-DPRU1`) in the CCS projects.
- `PRU0_IEP_CMP_STATUS_BIT` and `PRU1_IEP_CMP_STATUS_BIT` are defined distinctly in `pru_i2c_main.asm`.

### Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[96-103]
- examples/pru_i2c/firmware/pru_i2c_macro.h[740-800]
- examples/pru_i2c/firmware/pru_i2c_main.asm[74-79]

### Suggested change
1. Update `I2C_WAIT_FOR_IEP_CMP` to select `PRU0_IEP_CMP_STATUS_BIT` vs `PRU1_IEP_CMP_STATUS_BIT` based on `$defined("PRU0")/$defined("PRU1")` (similar to `I2C_IEP_INTC_CLEAR_EVENT`).
2. Update `I2C_SETUP_IEP_COUNTER` to program `PRU0_IEP_CMP_REG` for PRU0 builds and `PRU1_IEP_CMP_REG` for PRU1 builds, and ensure the enabled compare event matches the programmed compare register.

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

Comment on lines +39 to +44
# Defines (pass instance specific definitions to the program)
# see --define or -D in 'PRU Optimizing C/C++ Compiler User's Guide'
# For example, to define PRU0, ICSSG1, SOC_AM243X, and set _DEBUG_=1:
# -DPRU0 -DICSSG1 --define=SOC_AM243X -D_DEBUG_=1
DFLAGS :=

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

3. Makefiles omit pru defines 🐞 Bug ≡ Correctness

The new ti-pru-cgt makefiles leave DFLAGS empty even though the firmware uses
$defined("PRU0")/$defined("PRU1") to select core-specific behavior, so make builds will not set
these symbols unless the caller injects them externally.
Agent Prompt
### Issue description
The PRU I2C firmware uses `$defined("PRU0")` / `$defined("PRU1")` conditionals to choose PRU-core-specific behavior (IEP status bits, compare registers, interrupt bits). However, both new makefiles set `DFLAGS :=` empty, and the shared build rules only pass whatever `DFLAGS` contains to `clpru`.

### Issue Context
- CCS projects pass `-DPRU0`/`-DPRU1`, but the provided makefiles currently do not.
- `pru_rules.mak` compiles with `$(DFLAGS)` as provided by the core makefile.

### Fix Focus Areas
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/makefile[39-44]
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/makefile[39-44]
- pru_rules.mak[126-130]

### Suggested change
- In the PRU0 makefile, set:
  - `DFLAGS := -DPRU0 -DSLICE0`
- In the PRU1 makefile, set:
  - `DFLAGS := -DPRU1 -DSLICE1`
- If other symbols are required to match CCS builds, add them here as well, but at minimum the PRU0/PRU1 defines should be present so the firmware compiles with the intended core-specific branches.

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

  - Add I2C firmware
  - Create PRU0/PRU1 build projects for ICSS_M0
  - Configure makefiles and projectspec for open-pru structure

Signed-off-by: Achala Ram <a-ram@ti.com>
@qodo-code-review

qodo-code-review Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 9a16e00

"

postBuildStep="
$(CG_TOOL_ROOT)/bin/hexpru --diag_wrap=off --array --array:name_prefix=PRU0Firmware -o ../pru0_load_bin.h ${BuildArtifactFileBaseName}.out;

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. postbuildstep line not wrapped 📘 Rule violation ⚙ Maintainability

The postBuildStep command is added as a single long line rather than being wrapped/split using a
supported continuation mechanism. This reduces readability and violates the project configuration
line-wrapping requirement.
Agent Prompt
## Issue description
A very long `postBuildStep` command is written on a single line in the project configuration instead of being wrapped/split using a supported continuation mechanism.

## Issue Context
PR Compliance ID 22 expects long command attributes (such as post-build steps) to be wrapped/split to meet repository line-length expectations and keep project specs readable.

## Fix Focus Areas
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt/example.projectspec[56-58]
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/example.projectspec[56-58]

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

FIRMWARE_VERSION_BUILD .set 0x00

; macro for indicating version of firmware
I2C_FIRMWARE_VERSION .set ((FIRMWARE_VERSION_RELEASE << 31) | (FIRMWARE_VERSION_MAJOR << 24) | (FIRMWARE_VERSION_MINOR << 16) | (FIRMWARE_VERSION_BUILD << 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. i2c_firmware_version line too long 📘 Rule violation ⚙ Maintainability

The I2C_FIRMWARE_VERSION .set expression is written as a single very long source line, exceeding
the repository column limits. This harms readability and violates the line-length requirement.
Agent Prompt
## Issue description
A single source line exceeds the repository column limits.

## Issue Context
Long expressions should be wrapped/split (for example by using intermediate `.set` symbols) to stay within the soft/hard line-length limits.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_firmware_version.h[50-51]

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

Comment on lines +15 to +20
PAGE 1:
/* Data RAMs */
/* 8 KB PRU Data RAM 0 */
PRU0_DMEM_0 : org = 0x00000000 len = 0x00002000
/* 8 KB PRU Data RAM 1 */
PRU1_DMEM_1 : org = 0x00002000 len = 0x00002000

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

3. Pru1 linker dmem swapped 🐞 Bug ≡ Correctness

The PRU1 linker.cmd maps PRU0_DMEM_0 at 0x0 and PRU1_DMEM_1 at 0x2000, but PRU1 sections are
allocated into PRU1_DMEM_1, so PRU1 stack/BSS can end up in the wrong local RAM alias. This differs
from other AM261x PRU1 linker scripts in the repo (which place PRU1_DMEM_1 at 0x0), and can lead to
PRU1 firmware malfunction or memory corruption.
Agent Prompt
## Issue description
`examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd` uses the same DMEM origin layout as PRU0 (DMEM0 at 0x0, DMEM1 at 0x2000). For PRU1 builds, the repo’s existing AM261x PRU1 linker scripts map PRU1’s local DMEM (PRU1_DMEM_1) at 0x0 and PRU0_DMEM_0 at 0x2000.

This mismatch can cause PRU1 `.stack/.bss/.data/...` (allocated to `PRU1_DMEM_1`) to land in the wrong address range.

## Issue Context
The same-repo reference implementation for AM261x PRU1 (e.g., CRC firmware) shows the expected mapping.

## Fix Focus Areas
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd[15-21]

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

@pratheesh

Copy link
Copy Markdown
Contributor

Hi @achala-ti — nice work on the PRU I2C master. One thing that's blocking the am261x CI here: the "Verify all makefiles were built" step fails with "makefile never built" for the two pru_i2c PRU firmware makefiles, because nothing in the top-level build recurses into examples/pru_i2c.

Root cause: there's no examples/pru_i2c/makefile aggregator, and pru_i2c isn't in examples/makefile's SUBDIRS, so the firmware leaf makefiles never get invoked and the verify step flags them.

Two small changes fix it:

  1. Add examples/pru_i2c to SUBDIRS in examples/makefile.
  2. Add an examples/pru_i2c/makefile aggregator (modeled on examples/empty), scoped via SUPPORTED_PROCESSORS := am261x, whose am261x target builds the pru0/pru1 ti-pru-cgt firmware. Non-am261x devices hit the prebuild check and print "does not have a build option" and build nothing, so other device builds are unaffected.

The am261x target:

am261x:
# am261x-lp
	$(MAKE) -C firmware/am261x-lp/icss_m0_pru0_fw/ti-pru-cgt $(ARGUMENTS_PRU)
	$(MAKE) -C firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt $(ARGUMENTS_PRU)

Verified locally with GNU Make dry-runs: am261x recurses into both firmware leaf makefiles (each producing a .out, satisfying the verify step); am263x prints "does not have a build option" and builds nothing.

Happy to send this as a patch/PR against your branch if useful — let me know. (Separately, the PR body mentions an R5F example but the current diff looks firmware-only — is the R5F example still coming?)

The am261x "Verify all makefiles were built" CI step failed with
"makefile never built" for the two pru_i2c PRU firmware makefiles,
because nothing in the top-level make recursed into them.

- Add examples/pru_i2c/makefile aggregator (modeled on examples/empty),
  scoped to am261x with an am261x target that builds the pru0/pru1
  ti-pru-cgt firmware. Non-am261x devices hit the SUPPORTED_PROCESSORS
  prebuild check and skip cleanly, so other device builds are unaffected.
- Add pru_i2c to examples/makefile SUBDIRS so the top-level make recurses
  into it.

Verified with GNU Make dry-runs: am261x recurses into both firmware
leaf makefiles (each producing a .out, satisfying the verify step);
am263x prints "does not have a build option" and builds nothing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment on lines +31 to +35
;************************************************************************************
; File: icss_i2c_macro.h
;
; Brief: This file contains ICSS I2C macros definations
;************************************************************************************

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. pru_i2c_macro.h header filename mismatch 📘 Rule violation ⚙ Maintainability

The file header comment states a different filename (icss_i2c_macro.h) than the actual file
(pru_i2c_macro.h). This breaks the required formatting standard for accurate file-name headers.
Agent Prompt
## Issue description
The file header comment lists the wrong filename, which violates the formatting/header requirements.

## Issue Context
The repository formatting standard requires source files to contain a header denoting the correct file name.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[31-35]

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

Comment on lines +58 to +85
.asg R1, TEMP_REG1 ; temporary register 1
.asg R2, TEMP_REG2 ; temporary register 2
.asg R3, TEMP_REG3 ; temporary register 3
.asg R4, TEMP_REG4 ; temporary register 4
.asg R5, TEMP_REG5 ; temporary register 5
.asg R6, TEMP_REG6 ; temporary register 6
.asg R7, TEMP_REG7 ; temporary register 7
.asg R8, TEMP_REG8 ; temporary register 8

.asg R20, IEP_COUNTER_NEXT_VAL1
.asg R21, IEP_COUNTER_NEXT_VAL2
.asg R22, I2C_GLOBAL_FREQ_REG




PRU0_IEP_CMP_REG .set ICSS_IEP_CMP0_REG
PRU1_IEP_CMP_REG .set ICSS_IEP_CMP1_REG
PRU0_IEP_CMP_ENABLE_BIT .set 1
PRU1_IEP_CMP_ENABLE_BIT .set 2
PRU0_IEP_CMP_STATUS_BIT .set 0
PRU1_IEP_CMP_STATUS_BIT .set 1


; Bank ids for Xfer instructions
BANK0 .set 10
BANK1 .set 11
BANK2 .set 12

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

3. pru_i2c_main.asm register aliasing 📘 Rule violation ⚙ Maintainability

The new PRU assembly introduces direct register aliasing via .asg/.set rather than structured
allocation. This increases the risk of register overlap/corruption and reduces reviewability.
Agent Prompt
## Issue description
Direct register aliasing is used (`.asg` and `.set`) instead of structured register allocation.

## Issue Context
The compliance guideline prefers `.struct`/`.sassign` to reduce register overlap and improve maintainability.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[58-85]

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

Comment on lines +78 to +103
;************************************************************************************
;
; Macro: I2C_WAIT_FOR_IEP_CMP
;
; wait until the IEP CMP Event triggers and interrupt
;
; PEAK cycles:
; NA
; Pseudo code:
; while(r31.t31==0)
;
; Parameters:
; None
;
; Returns:
; None
;
;************************************************************************************
I2C_WAIT_FOR_IEP_CMP .macro

WAIT_FOR_INT?:
LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4
QBBC WAIT_FOR_INT?, TEMP_REG1, PRU0_IEP_CMP_STATUS_BIT
;;;;QBBC WAIT_FOR_INT?, R31, 31

.endm

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

4. i2c_wait_for_iep_cmp lacks timeout 📘 Rule violation ☼ Reliability

The macro busy-waits in a loop without an explicit termination/timeout, and its documentation does
not provide a real peak cycle budget nor list modified registers. This risks deadlock if the event
never occurs and violates required macro documentation.
Agent Prompt
## Issue description
`I2C_WAIT_FOR_IEP_CMP` performs an unbounded busy-wait loop and its documentation is incomplete (no real peak cycle budget, no modified-register list).

## Issue Context
Compliance requires PRU loops to have explicit termination/bounds checks and requires macros to document peak cycle budget and modified registers.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[78-103]

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

Comment on lines +1375 to +1380
LOOPBACK_COPY_DATA:
LBBO &R15.b1, R11, R15.b2, 1
SBBO &R15.b1, R12, R15.b2, 1
ADD R15.b2, R15.b2, 1
QBGE LOOPBACK_COPY_DATA_RETURN, R15.b3, R15.b2
STATE_TASK_OVER

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

5. loopback_copy_data unchecked buffer access 📘 Rule violation ⛨ Security

The loopback copy performs LBBO/SBBO using a loop-derived offset (R15.b2) without verifying
the offset is in-bounds before each access and without validating the requested count against the
actual TX/RX buffer size. This can lead to out-of-bounds reads/writes if configuration is invalid or
corrupted.
Agent Prompt
## Issue description
`LOOPBACK_COPY_DATA` reads/writes bytes from TX/RX buffers using an incrementing offset without checking bounds before the memory accesses, and without validating the requested length against the buffer capacity.

## Issue Context
PRU firmware must prevent out-of-bounds memory access and ensure loop-derived offsets are validated before accessing memory.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[1357-1380]

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

Comment on lines +96 to +103
I2C_WAIT_FOR_IEP_CMP .macro

WAIT_FOR_INT?:
LBCO &TEMP_REG1, ICSS_IEP_CONST, ICSS_IEP_CMP_STATUS_REG, 4
QBBC WAIT_FOR_INT?, TEMP_REG1, PRU0_IEP_CMP_STATUS_BIT
;;;;QBBC WAIT_FOR_INT?, R31, 31

.endm

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

6. Wrong cmp status bit 🐞 Bug ≡ Correctness

I2C_WAIT_FOR_IEP_CMP always polls PRU0_IEP_CMP_STATUS_BIT, so a PRU1 firmware build can wait on
the wrong compare-status bit and never observe its own CMP event. This can deadlock the PRU1 task
loop at startup.
Agent Prompt
### Issue description
`I2C_WAIT_FOR_IEP_CMP` polls `PRU0_IEP_CMP_STATUS_BIT` unconditionally. For PRU1, the CMP status bit is different (PRU1 bit), so PRU1 may spin forever waiting for an event that will never set the polled bit.

### Issue Context
`pru_i2c_main.asm` defines distinct status bits for PRU0 vs PRU1, and the firmware has separate PRU0/PRU1 build projects.

### Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[96-103]
- examples/pru_i2c/firmware/pru_i2c_main.asm[74-79]

### Suggested fix
Make `I2C_WAIT_FOR_IEP_CMP` choose the correct status bit based on `$defined("PRU0")/$defined("PRU1")` (mirroring the pattern already used in `I2C_IEP_INTC_CLEAR_EVENT`), or parameterize the macro to accept the status-bit constant.

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

Comment on lines +784 to +788
loop4?:
;;ADD IEP_COUNTER_NEXT_VAL1, IEP_COUNTER_NEXT_VAL1, I2C_GLOBAL_FREQ_REG.w2
;;ADC IEP_COUNTER_NEXT_VAL2, IEP_COUNTER_NEXT_VAL2, 0x00
SBCO &IEP_COUNTER_NEXT_VAL1, ICSS_IEP_CONST, PRU0_IEP_CMP_REG, 8

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

7. Wrong cmp register programmed 🐞 Bug ≡ Correctness

I2C_SETUP_IEP_COUNTER writes the initial compare value to PRU0_IEP_CMP_REG unconditionally, so
PRU1 never programs PRU1_IEP_CMP_REG. This can prevent PRU1 compare events from firing on the
intended channel.
Agent Prompt
### Issue description
`I2C_SETUP_IEP_COUNTER` always writes compare values to `PRU0_IEP_CMP_REG`. When building for PRU1, the compare register is `PRU1_IEP_CMP_REG`, so PRU1’s compare channel may never be configured.

### Issue Context
`pru_i2c_main.asm` maps `PRU0_IEP_CMP_REG` to `ICSS_IEP_CMP0_REG` and `PRU1_IEP_CMP_REG` to `ICSS_IEP_CMP1_REG`.

### Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[740-802]
- examples/pru_i2c/firmware/pru_i2c_main.asm[74-79]

### Suggested fix
Conditionalize the `SBCO` target register in `I2C_SETUP_IEP_COUNTER` the same way `I2C_IEP_INTC_CLEAR_EVENT` does:
- if PRU0: write `PRU0_IEP_CMP_REG`
- if PRU1: write `PRU1_IEP_CMP_REG`

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

Comment on lines +768 to +776
LDI TEMP_REG3.w0, ICSS_I2C_CONFIG_MEMORY
LBCO &IEP_COUNTER_NEXT_VAL1, ICSS_DMEM0_CONST, TEMP_REG3.w0, 8
LBCO &TEMP_REG2, ICSS_IEP_CONST, ICSS_IEP_COUNT_REG, 8

;;;debug code
;;.if $defined("DEBUG_CODE")
LDI IEP_COUNTER_NEXT_VAL1, 0x9c3
LDI IEP_COUNTER_NEXT_VAL2, 0x0
;;.endif

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

8. Unconditional iep value override 🐞 Bug ≡ Correctness

I2C_SETUP_IEP_COUNTER unconditionally overwrites IEP_COUNTER_NEXT_VAL1/2 with 0x9c3/0,
discarding the values loaded from DMEM. This forces initial compare scheduling toward the 100kHz
constant and can produce incorrect timing relative to the configured bus frequency.
Agent Prompt
### Issue description
`I2C_SETUP_IEP_COUNTER` loads `IEP_COUNTER_NEXT_VAL1/2` from DMEM, but then immediately overwrites them with hardcoded values (`0x9c3`, `0x0`) because the intended `.if $defined("DEBUG_CODE")` guard is commented out.

### Issue Context
`0x9c3` matches the 100kHz increment constant in `pru_i2c_interface.h`, but the firmware supports multiple frequencies and uses `I2C_GLOBAL_FREQ_REG` to select among them.

### Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[768-776]
- examples/pru_i2c/firmware/pru_i2c_interface.h[175-193]

### Suggested fix
Either:
1) Restore the debug guard (uncomment/fix the `.if $defined("DEBUG_CODE")` / `.endif` so the hardcoded load only happens in debug builds), or
2) Remove the hardcoded overwrite entirely and initialize the compare value from DMEM/current IEP count + configured increment.

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

Resolve the examples/makefile SUBDIRS conflict: main added pru_eqep on the
same line this branch added pru_i2c. Keep both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pratheesh Gangadhar <pratheesh.gangadhar@gmail.com>
@pratheesh

Copy link
Copy Markdown
Contributor

Hi @achala-ti. I opened three PRs against this branch (a0502729_PRU_I2C) so they can be folded into #137:

Two questions:

  1. Was your board testing on ICSSM1 pins? 0x50D00818 would be right there, and examples: pru_i2c: fix PRU1/dual-core IEP use, read ACK and SDA control (for #137) #171 supports it with -DICSSM1.
  2. Should the stubbed SMBus commands be dropped for now?

@pratheesh

Copy link
Copy Markdown
Contributor

For reference: the PRU I2C master from this PR's stack (via #172, head 8f4c1c2) now passes read/write tests on LP-AM263 (AM263x) silicon at 100 kHz and 367.6 kHz, with only an SoC address select for OUT_CTRL. Details and raw results: #172 (comment)

; Returns:
; None
;
ENABLE_XIN_XOUT_SHITFTING .macro

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

16. Uppercase macro names break the naming rule 📘 Rule violation ✧ Quality

The assembly macros ENABLE_XIN_XOUT_SHITFTING, I2C_WAIT_FOR_IEP_CMP, I2C_IEP_INTC_CLEAR_EVENT,
SET_SCL_PIN_HIGH and the rest of the macro set in pru_i2c_macro.h are all declared in ALL_CAPS
with .macro. The rule requires lowercase underscore_case macro names, so every new macro in this
file departs from it and call sites in pru_i2c_main.asm inherit the same spelling.

Dismiss ↗ | View ↗


main:

init:

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

17. Lowercase labels break the uppercase label rule 📘 Rule violation ✧ Quality

Labels such as init: in pru_i2c_main.asm and tx_data_sda_begin?:,
read_address_register_done?: and similar in pru_i2c_macro.h are written in lowercase, while the
rule requires uppercase A–Z, digits and underscores. The same mixed style also appears in
TASK_LOOP_100Khz:, so the label set in these files is inconsistent with the convention.

Dismiss ↗ | View ↗

; 2) Clear the event
; 3) Perform the i2c wave transition
;----------------------------------------------------------
TASK_LOOP_100Khz:

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

18. Task labels skip the fn_ and _task pattern 📘 Rule violation ✧ Quality

The scheduler task entry labels TASK_LOOP_100Khz, TASK_LOOP_400Khz and TASK_LOOP_1Mhz lack the
required FN_ prefix and _TASK suffix, and they contain lowercase letters from the frequency
suffixes. The rule requires task names of the form FN_<TASK_NAME>_TASK in uppercase snake case, so
these task entries do not match the convention.

Dismiss ↗ | View ↗

Comment on lines +169 to +172
;
; Pseudo code:
;
;

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

19. Macro docs leave pseudocode sections blank 📘 Rule violation ✧ Quality

Many macro doc blocks in pru_i2c_macro.h, for example I2C_WAVE_FUNCTION0, have a Pseudo code:
header followed by no pseudocode at all. The rule requires a stepwise, language-agnostic pseudocode
section for each macro, so these blocks fail the check even though they have headers.

Dismiss ↗ | View ↗

Comment on lines +960 to +964
SET_SDA_PIN_INPUT_DIRECTION .macro

;; For Am263x LDI32 r29, 0x50D00824
;for Am261x
LDI32 r29, 0x50D00818

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

20. Macros omit the registers they modify 📘 Rule violation ✧ Quality

SET_SDA_PIN_INPUT_DIRECTION writes through r28 and r29, while I2C_IEP_INTC_CLEAR_EVENT
writes TEMP_REG1, TEMP_REG2, and the IEP next-value registers, but their doc blocks omit
register-usage lists. When a caller keeps live values in those registers, the missing clobber
information can lead to silent corruption; the documentation gap also affects other low-level macros
that use temporary and IEP counter registers.
Agent Prompt
## Issue description
`SET_SDA_PIN_INPUT_DIRECTION` and similar PRU assembly macros modify registers without documenting their register usage, leaving callers unable to identify clobbered values.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[943-966]

## Recommended Fix
Add a `Register usage:` block to each affected macro comment that lists input, output, clobbered, and preserved registers. Include `r28` and `r29` for `SET_SDA_PIN_INPUT_DIRECTION`, and check each list against the registers its macro body actually writes.

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

Dismiss ↗ | View ↗

Comment on lines +912 to +919
rx_data_ack_scl_end?:
SET_SCL_PIN_LOW
AND R15.b0, R15.b0, 0x00
SUB TEMP_REG4.b0, R15.b2, 1
SBBO &arg1, R12, TEMP_REG4.b0, 1
QBGT rx_mode_continue?, R15.b2, R15.b3
AND R15.b2, R15.b2, 0x00
LDI R13.w0, $CODE(arg2)

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

6. Burst reads return without received data 🐞 Bug ≡ Correctness

When setup enables the SMBus burst bit, the ordinary receive path selects rx_data_ack_scl_end_v2?,
which clears the burst bit and finishes without storing the received byte. A host using that
configuration can receive a completion after the first byte while its RX buffer remains unchanged.
Agent Prompt
## Issue description
The burst receive completion branch bypasses the RX-buffer store and ends after one byte.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[896-924]
- examples/pru_i2c/firmware/pru_i2c_main.asm[455-471]
## Recommended Fix
Store received bytes in the burst branch and define its intended transfer length and completion behavior; test it through the reachable ordinary RX command.

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

Dismiss ↗ | View ↗

Comment on lines +1007 to +1012
READ_SDA_PIN_ACK
UPDATE_NEXT_LOCAL_STATE ADDRESS_ACK_SCL_END
STATE_TASK_OVER

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; make SCL low

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. Ten-bit-addressed devices cannot reply 🐞 Bug ≡ Correctness

After acknowledging the first ten-bit address byte, ADDRESS_ACK_SCL_END restarts transmission with
the bit counter at zero without selecting the low address byte. The next eight bits come from the
same high-byte positions in R13.w2, so a ten-bit slave receives the prefix twice instead of its
address’s low byte.
Agent Prompt
## Issue description
Ten-bit mode retransmits its address prefix rather than the low address byte.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[946-1012]
- examples/pru_i2c/firmware/pru_i2c_macro.h[532-555]
## Recommended Fix
Select the low byte for the second address phase and verify the complete ten-bit write and read sequences, including the repeated-start/read prefix required for reads.

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

Dismiss ↗ | View ↗

QBNE ICSS_I2C_RESET_CMD_CHECK_RETURN, TEMP_REG4.w2, ICSS_I2C_RESET_CMD
UPDATE_NEXT_LOCAL_STATE RESET_SCL_SDA_HIGH
LDI TEMP_REG4.w0, COMMAND_SUCCESS
SBBO &TEMP_REG4, R10, ICSS_I2C_COMMAND_OFFSET, 2

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

15. Successful resets signal an error 🐞 Bug ≡ Correctness

The reset-command handler writes COMMAND_SUCCESS but sends RESET_SCL_SDA_HIGH to
RAISE_HOST_INTERRUPT_MEM_FOR_ERROR. When a reset finishes, the firmware follows the error
notification and acknowledgment path rather than the ready path used by successful setup and
transfers.
Agent Prompt
## Issue description
A reset writes a success response but transitions into the error notification state.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_main.asm[550-561]
- examples/pru_i2c/firmware/pru_i2c_main.asm[499-522]
## Recommended Fix
Route successful reset completion through the appropriate success/ready notification and next state; retain the error path only for failures.

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

Dismiss ↗ | View ↗

Comment on lines +20 to +21
PRU1_DMEM_1 : org = 0x00002000 len = 0x00002000

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

37. The second core links data to wrong ram 🐞 Bug ≡ Correctness

The PRU1 linker script puts PRU1_DMEM_1 at 0x2000 and assigns its data and stack sections there.
Existing AM261x PRU1 linker scripts put local PRU1 data RAM at 0x0000, so sections linked by this
project use the other RAM window instead.
Agent Prompt
## Issue description
The PRU1 linker script reverses local and remote data-RAM addresses.
## Fix Focus Areas
- examples/pru_i2c/firmware/am261x-lp/icss_m0_pru1_fw/ti-pru-cgt/linker.cmd[15-42]
## Recommended Fix
Map PRU1 local DMEM to zero and PRU0 remote DMEM to `0x2000`, as in the sibling AM261x PRU1 scripts, then inspect linked section addresses.

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

Dismiss ↗ | View ↗

Comment on lines +964 to +965
LDI32 r29, 0x50D00818
LBBO &r28, r29, 0, 4

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

38. Other selected data pins stay unconfigured 🐞 Bug ≡ Correctness

SET_SDA_PIN_INPUT_DIRECTION and its output counterpart always modify pad-control address
0x50D00818, although setup takes the SDA pin number from the host and uses it for PRU input and
output operations. When the host selects a different SDA pin, the firmware changes the fixed pad’s
direction instead of that pin’s, disrupting ACK sampling and receive transitions.
Agent Prompt
## Issue description
Direction macros configure one fixed SDA pad while the command interface accepts a selectable SDA pin.
## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[959-997]
- examples/pru_i2c/firmware/pru_i2c_main.asm[292-306]
## Recommended Fix
Either configure the pad corresponding to the selected pin or validate and document that only the fixed SDA pin is supported.

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

Dismiss ↗ | View ↗

@pratheesh-ti pratheesh-ti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Closing as superseded by #172 #172 #173

@TexasInstruments TexasInstruments deleted a comment from pratheesh Dec 1, 2026
pratheesh added a commit to pratheesh/open-pru that referenced this pull request Dec 1, 2026
TexasInstruments#137 was closed in favour of this PR and its base moved to main.
Conflict in examples/makefile: keep pru_eqep and pru_i2s from main
and pru_i2c from this branch.
pratheesh added a commit to pratheesh/open-pru that referenced this pull request Dec 1, 2026
…ample branch

TexasInstruments#137 is closed in favour of this PR, so this PR now also carries
TexasInstruments#171's review follow-ups from 2026-10-16, which it did not have:

- 146ccec: pseudocode, arg1 and registers-modified docs for
  I2C_IEP_INTC_CLEAR_EVENT and I2C_WAVE_FUNCTION0. The scheduler wait is
  marked INTENTIONALLY_UNBOUNDED_LOOP. The I2C_WAVE_FUNCTION0 register
  note now also covers this branch's R23/R26 open-drain pin registers.
- 466c7af, 9b8099e: derive the IEP compare increment from the
  frequency selector when the host leaves it at 0, and keep a nonzero
  host value. The R5F example always writes a nonzero increment, so its
  path is unchanged.
- e161b91: document the shared-IEP start-up ordering constraint.

Two commits are not taken. This branch's open-drain bus replaces the
push-pull SDA direction control they patch:
- 6e43662 fixes spacing in SET_SDA_PIN_INPUT/OUTPUT_DIRECTION, which no
  longer exist here.
- a0ca016 leaves SDA released after a NACK. Here SDA is only ever
  released or pulled low, and an address or data NACK ends with a STOP
  through DATA_PROCESSING_COMPLETE.

pru0/pru1_load_bin.h are regenerated with the makefile flow (clpru
2.3.3, no warnings). Each image grows by exactly the 7 instructions of
the selector-to-increment derivation.
pratheesh added a commit to pratheesh/open-pru that referenced this pull request Dec 1, 2026
TexasInstruments#137 is closed and this PR now targets main. The only conflict is the
SUBDIRS list in examples/makefile, where main added pru_eqep and pru_i2s;
keep all three.
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.

3 participants