Skip to content

examples: pru_i2c: add R5F NORTOS host example for am261x-lp (for #137) - #172

Open
pratheesh wants to merge 32 commits into
TexasInstruments:mainfrom
pratheesh:examples/pru-i2c-r5f-example
Open

pratheesh wants to merge 32 commits into
TexasInstruments:mainfrom
pratheesh:examples/pru-i2c-r5f-example

Conversation

@pratheesh

@pratheesh pratheesh commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Adds the PRU I2C/SMBus master (examples/pru_i2c) and its R5F NORTOS host example for the AM261x-LP. This PR now targets main and supersedes #137.

Status (refreshed after #137 was closed)

  • Contents. examples: pru_i2c: fix PRU1/dual-core IEP use, read ACK and SDA control (for #137) #171 is closed as superseded. This branch holds [WIP]am261x: pru i2c: Add PRU I2C Master firmware and R5F example #137's commits (9a16e005, d3795004) and every fix from examples: pru_i2c: fix PRU1/dual-core IEP use, read ACK and SDA control (for #137) #171 (merged in 40119da7). On top of those it adds the open-drain bus with SMBus support, the R5F example and the review follow-ups below.
  • main merged in (cfc0c41b). The only conflict was the examples/makefile SUBDIRS list; pru_eqep, pru_i2c and pru_i2s are all kept.
  • MCU+ SDK 11+ project (958780a2). main's CI now uses AM261x MCU+ SDK 26.00, which renamed the driver and board libs (drivers.am261x.r5f.ti-arm-clang.nortos.*) and produces an mcelf-only boot image. The am261x-lp/r5fss0-0_nortos makefile, projectspec and boot-image makefile were regenerated from main's examples/empty am261x-lp project, with NORTOS in place of FreeRTOS. The SDK 10.2 versions no longer link.
  • Index and docs (26df1181, 2caa2959). pru_i2c is now in the examples/readme.md project list and portability table, per docs_ai/task_create_project.md D4. am261x is Y. am243x, am263px, am263x and am64x are Yport, since they have similar per-pin PRU GPIO output-disable capability. am62x is N-sw, as for the other examples with an MCU+ R5F host (7c16c703). The readme's "Validated HW & SW" now reports the silicon run below. 2caa2959 also completes the register-usage lists in the macro headers (comments only).

Firmware merged from #171

The #171 changes were taken where they apply to an open-drain bus:

  • Taken: the macro documentation, the INTENTIONALLY_UNBOUNDED_LOOP scheduler marker, the selector-to-increment fallback (used only when the host leaves the increment at 0), and the shared-IEP start-up ordering note.
  • Not taken: the push-pull SDA-retake-after-NACK change and the SDA-direction macro spacing fix. On this branch SDA and SCL are released by setting OUTDISABLE, so there is no SDA drive to take back, and those macros do not exist here.
  • Conflict: on an address NACK this branch keeps its own handling, which sets the SMBus error flag and sends STOP.

The R5F host always writes the increment, so the merged firmware takes the same path as the silicon-tested 8f4c1c2c. The regenerated pru0/pru1_load_bin.h grew by exactly the fallback's 7 instructions.

What the example does

  • mcuplus/pru_i2c_example.c takes every offset, command and response code from pru_i2c_interface.h. The sequence:

    1. Configure the PRU and load the firmware.
    2. SETUP.
    3. Write [ptr, 4 bytes] to an EEPROM-style target at 0x50.
    4. Write [ptr], read the 4 bytes back and compare.

    Each step logs the response code, and the run ends with PASS or FAIL. The host polls the per-instance IRQ byte with a timeout and does not use the PRU interrupt.

  • It runs on PRU1, because on the AM261x-LP none of the PR0_PRU0_GPIOx signals reach a BoosterPack header. SCL is PR0_PRU1_GPIO18 (J1.4) and SDA is PR0_PRU1_GPIO19 (J1.3). This routing comes from SPRUJF1D and SysConfig pad resolution and has not been checked against the schematic.

  • The bus is open-drain with clock stretching and an SMBus 25 ms SCL-low timeout.

  • The tick is the larger of 1/(4 x bus rate) and 0.68 us, so SCL low meets the Fast-mode tLOW of 1.3 us. That gives about 368 kHz for the 400 kHz setting.

  • readme.md documents the host memory interface, the SMBus commands, pins, run steps and limitations.

Verification

  • Build. I built locally with make -C examples/pru_i2c all DEVICE=am261x BUILD_MCUPLUS=y, using AM261x MCU+ SDK 11.00.00.29, ti-arm-clang 4.0.4.LTS, SysConfig 1.26.0 and clpru 2.3.3. It produces pru_i2c.release.mcelf. CI on this push builds against SDK 26.00.00.06.

  • Silicon, LP-AM263 (AM263x). PRU1 at 200 MHz ran firmware 8f4c1c2c. The only change was the AM263x GPIO_OUT_CTRL addresses. These all passed at 100 kHz and at 367.6 kHz, with the MCU I2C1 controller reading back every transfer:

    • address probe, ACK and NACK
    • a 16-byte EEPROM read
    • TPIC2810 register writes
    • an 8-byte EEPROM write and restore

    Details are in the comment below and on the pr-i2c-am263x-lp branch of the fork.

  • Not covered:

🤖 Generated with Claude Code

achala-ti and others added 7 commits June 10, 2026 14:59
  - 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>
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>
Add the R5F side of the PRU I2C master example. The host code loads the
PRU I2C firmware on ICSSM0 PRU1, configures it through the PRU data RAM
(400 kHz, SCL/SDA = PR0_PRU1_GPIO18/19 on BoosterPack J1.4/J1.3), writes
a few bytes to an EEPROM-style target at 0x50, reads them back and logs
PASS or FAIL with the firmware response codes. It polls the IRQ bit in
the data RAM instead of using the PRU interrupt.

- mcuplus/pru_i2c_example.c: common host logic, uses pru_i2c_interface.h
- mcuplus/am261x-lp/r5fss0-0_nortos: main.c, example.syscfg and the
  ti-arm-clang makefile/projectspec, derived from the empty example
- makefile: NON_PRU_DEPENDENCIES := mcuplus and am261x_mcuplus target
- readme.md: memory interface, pins, build/run, known limitations

Build-tested only (MCU+ SDK AM261x 10.02.00.15), not run on hardware.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… clock

- The firmware reads the IRQ register (0x08) and the frequency word (0x0C)
  through ICSS_DMEM0_CONST, which is DMEM0 on both cores. The example runs
  on PRU1 and wrote them to DMEM1, so the firmware would read a zero
  frequency selector and the host would poll the wrong IRQ word. Write
  them in DMEM0, and only clear this instance's IRQ bit.
- Use the core number as the instance id, so a PRU0 and a PRU1 instance
  can share the IRQ register.
- The IEP_CMP_INCREMENT_VAL_* constants assume a 200 MHz IEP clock; this
  SysConfig runs it at 250 MHz (200 MHz needs the R5F at 400 MHz). Derive
  the increment from CONFIG_PRU_ICSS0_IEP_CLK_FREQ_HZ, rounding up to a
  whole IEP clock per tick so SCL never exceeds PRU_I2C_BUS_HZ
  (785 counts, ~398 kHz at 250 MHz).

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

Found by running the firmware ELFs on TI pru-simulator against an I2C
target model (see the PR description for the harness and results).

Per-core resources (both PRUs share the IEP and the scratchpad banks):
- The makefile build defined neither PRU0 nor PRU1 (DFLAGS was empty),
  so icss_constant_defines.inc treated both cores as PRU1: the firmware
  read its frequency word from the other core's DMEM, got 0 and went to
  ERROR_LOOP. Neither IEP compare was enabled either. The committed
  pru0/pru1_load_bin.h were built this way and are identical apart from
  the array name. Add -DPRU0/-DPRU1 (as the projectspecs already do) and
  fail the build with .emsg if neither is defined.
- I2C_WAIT_FOR_IEP_CMP polled the PRU0 status bit and
  I2C_SETUP_IEP_COUNTER programmed CMP0 on both cores, so PRU1 never saw
  a tick. Select CMP register, status bit and enable bit once per core.
- I2C_SETUP_IEP_COUNTER wrote CMP_CFG with only its own enable bit set,
  disabling the other core's compare. Read-modify-write it instead.
- The first compare value was a hardcoded 0x9C3 (debug guard commented
  out). Use the live IEP count + one tick, so a core can join a counter
  the other core already started.
- I2C_IEP_INTC_CLEAR_EVENT wrote back the whole CMP_STATUS value, which
  (write-1-to-clear) also clears the other core's pending event. Clear
  only this core's bit.
- Both cores saved their context to scratchpad bank 10. Use bank 10 for
  PRU0 and bank 11 for PRU1.
- ERROR_LOOP stopped the shared IEP counter. Leave it running.

I2C protocol:
- Read: the master drove SDA high in the ACK slot after every byte
  (rx_data_ack_begin used SET_SDA_PIN_HIGH), so it NACKed each byte and
  multi-byte reads returned 0xFF after the first byte. Drive it low.
- SET_SDA_PIN_INPUT/OUTPUT_DIRECTION wrote 0x50D00818
  (ICSSM1_PRU0_GPIO_OUT_CTRL) with a hardcoded bit 9. These projects run
  on ICSSM0, so SDA was never released: ACKs were read back from the
  master's own drive (a write to an absent address reported success).
  Use this core's ICSSM0 register (ICSSM1 with -DICSSM1) and the
  configured SDA pin.
- Release SDA on the SCL falling edge after the 8th bit instead of one
  tick later, and keep it released after the address ACK of a read, so
  the push-pull master does not drive SDA high while the target drives
  ACK or read data.

Housekeeping: file header names, register usage map, wait macro docs,
and a missing newline/indent on the final .endif (assembler warning
W0004 "Open block(s) at EOF").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pratheesh Gangadhar <pratheesh.gangadhar@gmail.com>
The IEP counts in steps of DEFAULT_INC = 5. 0x270 (624) and 0x9C3 (2499)
are not multiples of 5, so a compare that fires only when the counter
equals the compare value is never hit at 400 kHz or 100 kHz. Use 0x271
(625, i.e. the 125 cycles the comment already describes) and 0x9C4
(2500). 1 MHz (0x140 = 320) was already a multiple of 5.

SPRUJB6B does not say whether an IEP compare is an equality match or a
crossing match. With these values the tick is exact under either.

Also fix the file header name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pratheesh Gangadhar <pratheesh.gangadhar@gmail.com>
Rebuilt with the makefile flow (make -C examples/pru_i2c pru
DEVICE=am261x BUILD_MCUPLUS=y), which now passes -DPRU0 / -DPRU1. The
previous arrays were built with neither define and were identical for
both cores apart from the array name. These arrays are byte-identical to
the ELFs exercised on pru-simulator.

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

qodo-code-review Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

examples: pru_i2c: add PRU I2C master firmware and R5F NORTOS example

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

Grey Divider

AI Description

• Adds PRU firmware for an open-drain I2C/SMBus master on ICSSM0 PRU0 and PRU1.
• Adds an R5F NORTOS example that loads the firmware and runs a write/read-back test.
• Wires the firmware into the top-level build and adds pru_i2c to the examples index and portability
 table.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The host command path, shared-memory contract, generated PRU images, PRU waveform state machine, GPIO pinmux, and build wiring jointly implement one externally observable AM261x PRU I2C transfer behavior.
  • The documentation's LP-AM263 results provide supporting evidence that this same firmware behavior has operated on related hardware, but do not create a separate capability or validate the AM261x deployment.
Behavioral complexity 🔴 High 🧩 Multiple interactions

  • Before: the base repository had no AM261x PRU I2C master capability.
  • After: the R5F publishes configuration and commands through shared memory while PRU firmware runs a multi-state waveform and command machine and the generated image is selected per PRU core.
  • New correctness conditions include ordering configuration and TX-buffer writes before the command, preserving per-instance IRQ acknowledgement, maintaining open-drain SCL/SDA semantics, synchronizing IEP compare scheduling with START/STOP, ACK/NACK, clock stretching and timeout transitions, and ensuring the generated image matches the selected assembly.
  • The macro contract also makes shared-IEP startup ordering explicit.
  • New correctness condition: shared scheduler and per-core compare configuration must be initialized safely while every transfer state preserves bus and response invariants.
  • The follow-up documentation adds representative LP-AM263 transfer validation but does not remove these conditions or validate the AM261x-LP configuration.
Potential damage 🟡 Medium 🩹 Recoverable

  • If the integration regresses, setup or transfers can fail, time out, return incorrect readback, or leave an external target write incomplete.
  • Reverting stops new failures and restores pre-PR repository behavior, but an already completed incorrect or partial I2C write may require a manually verified target-device repair.
  • The documented LP-AM263 tests reduce uncertainty that the firmware can perform representative transfers, while the AM261x-LP build remains untested and no automatic repair or compensation path is shown.
  • Code rollback restores prior repository behavior; persistent target state or an external write already accepted by the device may need a new transaction or manual repair, and the source does not establish automatic recovery.
Assessed commit 7c16c70
Diagram

graph TD
    R5F["R5F host example"] --> DRAM[("PRU data RAM")] --> PRU["PRU1 firmware"] --> GPIO["MSS_CTRL OUT_CTRL"] --> TGT["I2C target"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Interrupt-driven completion via PRU INTC
  • ➕ Frees the R5F core while transfers run
  • ➕ Matches the PRU-to-host interrupt the firmware already raises
  • ➖ More driver setup code in an example
  • ➖ Harder to follow for a first-time user
2. Use the R5F's native I2C controller instead of the PRU
  • ➕ No PRU firmware or pinmux trade-offs
  • ➕ Hardware-supported clock stretching and SMBus
  • ➖ Does not demonstrate the PRU I2C capability this project exists for

Recommendation: The PRU bit-bang firmware with a polled data-RAM mailbox is a reasonable fit for an SDK example. Interrupt-driven completion would reduce R5F polling. The example keeps polling for simplicity, and the readme documents the INTC path as a follow-up.

Files changed (24) +6781 / -1

Enhancement (8) +5161 / -0
pru0_load_bin.hGenerated PRU0 firmware image header +951/-0

Generated PRU0 firmware image header

• Generated byte array of the PRU0 firmware, included by the R5F build.

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

pru1_load_bin.hGenerated PRU1 firmware image header +951/-0

Generated PRU1 firmware image header

• Generated byte array of the PRU1 firmware, which the example loads. It grew by the 7 instructions of the selector-to-increment fallback.

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

pru_i2c_firmware_version.hFirmware version definitions +54/-0

Firmware version definitions

• Defines firmware version macros for the PRU I2C image.

examples/pru_i2c/firmware/pru_i2c_firmware_version.h

pru_i2c_interface.hShared PRU-host memory map and command codes +236/-0

Shared PRU-host memory map and command codes

• Defines the data RAM offsets, bit layouts, response and command codes shared by firmware and host. Used by the C example and the assembly via .cdecls.

examples/pru_i2c/firmware/pru_i2c_interface.h

pru_i2c_macro.hPRU assembly macros for I2C open-drain bus +1009/-0

PRU assembly macros for I2C open-drain bus

• Adds macros for IEP tick waits, GPIO output-disable line control, and SMBus and I2C transfer steps. Documents register use and the unbounded scheduler loop.

examples/pru_i2c/firmware/pru_i2c_macro.h

pru_i2c_main.asmPRU I2C master state machine firmware +1395/-0

PRU I2C master state machine firmware

• Implements the I2C and SMBus master on PRU, timed by IEP compare events. Drives SCL and SDA through OUTDISABLE bits, handles clock stretching, and reports responses through the data RAM mailbox.

examples/pru_i2c/firmware/pru_i2c_main.asm

pru_i2c_example.cR5F host example for PRU I2C master +514/-0

R5F host example for PRU I2C master

• Configures the PRU and loads the firmware, then runs a write, pointer set, and read-back test against target 0x50. It derives the IEP increment from the configured IEP clock and logs each response code.

examples/pru_i2c/mcuplus/pru_i2c_example.c

main.cNORTOS entry point for the example +51/-0

NORTOS entry point for the example

• Creates the example task and calls pru_i2c_example_main.

examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/main.c

Documentation (2) +276 / -0
readme.mdProject readme for PRU I2C master +271/-0

Project readme for PRU I2C master

• Documents the memory interface, SMBus and I2C sequences, open-drain bus, pin assignment, build steps, expected output, and known limitations. It states the AM261x-LP build has not been run on hardware.

examples/pru_i2c/readme.md

readme.mdIndex and portability table entries for pru_i2c +5/-0

Index and portability table entries for pru_i2c

• Adds pru_i2c to the project list and marks am261x as supported, with am243x, am263px, am263x and am64x as portable and am62x as N-sw.

examples/readme.md

Other (14) +1344 / -1
makefileAdd pru_i2c to top-level SUBDIRS +1/-1

Add pru_i2c to top-level SUBDIRS

• Adds pru_i2c to the SUBDIRS list so the top-level make recurses into the new project.

examples/makefile

makefileProject aggregator scoped to am261x +98/-0

Project aggregator scoped to am261x

• Builds PRU0 and PRU1 firmware and the mcuplus host code for am261x. Other devices skip with a 'does not have a build option' message.

examples/pru_i2c/makefile

makefilePRU0 firmware build makefile +48/-0

PRU0 firmware build makefile

• Builds the PRU0 firmware with ti-pru-cgt using the -DPRU0 define.

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

makefilePRU1 firmware build makefile +48/-0

PRU1 firmware build makefile

• Builds the PRU1 firmware with ti-pru-cgt using the -DPRU1 define; this is the core the example uses.

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

linker.cmdPRU0 firmware linker command file +43/-0

PRU0 firmware linker command file

• Defines the PRU0 memory map and section placement for the firmware.

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

linker.cmdPRU1 firmware linker command file +43/-0

PRU1 firmware linker command file

• Defines the PRU1 memory map and section placement for the firmware.

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

example.projectspecPRU0 CCS project specification +81/-0

PRU0 CCS project specification

• Adds the CCS project definition for the PRU0 firmware build.

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

example.projectspecPRU1 CCS project specification +81/-0

PRU1 CCS project specification

• Adds the CCS project definition for the PRU1 firmware build.

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

example.syscfgSysConfig pinmux and PRU ICSS settings +296/-0

SysConfig pinmux and PRU ICSS settings

• Sets PR0_PRU1_GPIO18 (SCL) and GPIO19 (SDA) as input-enabled pins with internal pull-ups, and selects the IEP clock.

examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/example.syscfg

example.projectspecR5F NORTOS CCS project specification +115/-0

R5F NORTOS CCS project specification

• Adds the CCS project for the R5F NORTOS example, built with the MCU+ SDK 26.00 drivers.

examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/example.projectspec

makefileR5F NORTOS build makefile +350/-0

R5F NORTOS build makefile

• Builds the R5F image against the drivers.am261x.r5f.ti-arm-clang.nortos libraries and includes the PRU firmware headers.

examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile

makefile_ccs_bootimage_genBoot image generation makefile +112/-0

Boot image generation makefile

• Generates the mcelf boot image from the R5F build output.

examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_ccs_bootimage_gen

makefile_projectspecProjectspec makefile include +16/-0

Projectspec makefile include

• Adds the projectspec makefile include used by the R5F build.

examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/makefile_projectspec

syscfg_c.rov.xsSysConfig ROV script +12/-0

SysConfig ROV script

• Adds the ROV script generated by SysConfig for debugging the example.

examples/pru_i2c/mcuplus/am261x-lp/r5fss0-0_nortos/ti-arm-clang/syscfg_c.rov.xs

pratheesh and others added 6 commits October 2, 2026 13:48
…le SDA

Found on pru-simulator while checking the commands beyond TX.

- Dispatcher: the SMBus stub checks (QUICK .. BLOCK_READ) only advanced
  to the next check from some stubs, so dispatch stopped at
  ICSS_SMBUS_QUICK_CHECK for every command after TX. READ_SCL,
  RESET_SLAVE and LOOPBACK were unreachable, and any SMBus or unknown
  command left the firmware spinning there until reset. Replace the stub
  chain with one range check: SMBus commands (not implemented) get
  INVALID_COMMAND, everything else goes on to READ_SCL / RESET_SLAVE /
  LOOPBACK and then INVALID_COMMAND.
- RESET_SLAVE counted falling edges and ended with SCL low: 8 full SCL
  pulses and a bus left low. It also kept driving SDA high, fighting the
  stuck target it is meant to free. Release SDA, give 9 full pulses and
  end with SCL high.
- SDA is now released whenever the bus is idle (after setup, after STOP,
  after RESET) and taken back at the start of each transfer, so an idle
  master never drives SDA high against a target holding it low.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pratheesh Gangadhar <pratheesh.gangadhar@gmail.com>
Byte-identical to the ELFs exercised on pru-simulator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pratheesh Gangadhar <pratheesh.gangadhar@gmail.com>
SMBus (commands 0x14..0x1C, previously stubs):
  quick command, send/receive byte, write/read byte, write/read word,
  block write/read. A transfer is a write phase (command code and block
  count staged as prefix bytes in front of the Tx buffer, then the Tx
  data) and, for the reads, a repeated START and a read phase. Block read
  reports the target's byte count in the count register. SMBus always
  sends START/STOP and NACKs the last byte read, whatever CON says.
  10-bit addressing is rejected (ADDRESSING_MODE_FAILED).
PEC (CON bit 6, ICSS_I2C_PEC_BIT): CRC-8 (0x07) updated bit by bit over
  every address and data bit; appended to write-only transfers and checked
  on reads (new response PEC_ERROR 0x050F).
Open-drain bus: SCL and SDA are never driven high. R30 keeps both bits at
  0 and the lines are switched with their OUTDISABLE bits in
  ICSSMx_PRUy_GPIO_OUT_CTRL through a shadow register (one store per edge).
  The SDA direction macros are gone; the master can no longer fight a
  target on either line.
Clock stretching: every state that follows an SCL release waits for SCL
  to read high. A new SCL-low timeout (instance offset 0xE8, in ticks,
  0 = none) ends a transfer with TIME_OUT_ERROR. After a stretch the high
  period is counted from the real rising edge (tHIGH).
Errors now end with a STOP: address NACK, data NACK, bad block count.
Bus timing (UM10204 Table 10, SMBus = Standard-mode):
  - START hold, repeated START setup/hold and STOP setup are two ticks
    (one tick is 2.5 us at 100 kHz, below the 4.0/4.7 us minimums).
  - The 400 kHz tick is 680 IEP counts (367.6 kHz): with 625 the 2-tick
    SCL low was 1.25 us, under the Fast-mode tLOW of 1.3 us.
Removed: the unreachable CMD_CODE_* / *_BURST states and the SMBus burst
  CON latch (bit 5 is now reserved).

New interface fields: ICSS_I2C_PEC_BIT, ICSS_I2C_SCL_TIMEOUT_OFFSET,
PEC_ERROR; ICSS_I2C_PRU_CMD_CODE_OFFSET is the SMBus command code (bit 0
is the R/W bit for quick command); instance offsets 0xFE/0xFF are used to
stage the SMBus prefix bytes.

Hardware note: SCL now needs a pull-up and its GPI path (the pad
configured with rx), like SDA.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pratheesh Gangadhar <pratheesh.gangadhar@gmail.com>
Byte-identical to the ELFs exercised on pru-simulator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pratheesh Gangadhar <pratheesh.gangadhar@gmail.com>
The example needs the firmware fixes (TexasInstruments#171) and the open-drain/SMBus
firmware it is built for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follows the firmware's open-drain bus with clock stretching:
- SysConfig: SCL (PR0_PRU1_GPIO18) gets rx and a pull-up like SDA, so the
  firmware can read SCL back, and SysConfig leaves both OUTDISABLE bits
  set (released).
- Host: release both lines in ICSSM0_PRU1_GPIO_OUT_CTRL before starting
  the PRU, instead of enabling the SDA driver (which with R30 = 0 would
  hold SDA low until the firmware's setup).
- The tick is the larger of 1/(4 * PRU_I2C_BUS_HZ) and 0.68 us so that
  SCL low meets the Fast-mode tLOW of 1.3 us (850 counts at 250 MHz,
  ~368 kHz).
- Set the SCL-low timeout to the SMBus 25 ms.
- readme: SMBus command table, open-drain/clock stretching, both lines
  need pull-ups; removed the "SCL is push-pull" and "SMBus stubs"
  limitations.

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

Copy link
Copy Markdown
Collaborator

/agentic_review

@qodo-code-review

qodo-code-review Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Code Review by Qodo


View medium (9)
Remediation recommended
1. Assembly macros keep uppercase names 📘
Description
The new PRU macros SET_SCL_PIN_LOW, SET_SDA_PIN_HIGH, WAIT_SCL_HIGH, PEC_UPDATE and
TX_FETCH_BYTE use uppercase names instead of lowercase underscore_case. Their definitions and call
sites therefore introduce a second macro naming convention into the changed assembly macro header.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New assembly macro definitions use uppercase names, contrary to the required lowercase underscore_case convention.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[260-272]
- examples/pru_i2c/firmware/pru_i2c_macro.h[293-305]
- examples/pru_i2c/firmware/pru_i2c_macro.h[323-358]

## Recommended Fix
Rename each new macro to lowercase underscore_case and update every invocation consistently, for example `set_scl_pin_low`, `wait_scl_high`, `pec_update`, and `tx_fetch_byte`.

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

Dismiss ↗ | View ↗

2. Macro-local labels use lowercase names 📘
Description
The new macro-local labels scl_wait?, scl_high?, scl_ok?, pec_bit0?, pec_done?,
fetch_buf? and fetch_done? contain lowercase letters. These labels are introduced by the changed
assembly code and do not meet the required uppercase underscore_case label convention.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New macro-local assembly labels use lowercase names instead of uppercase underscore_case.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[299-305]
- examples/pru_i2c/firmware/pru_i2c_macro.h[328-332]
- examples/pru_i2c/firmware/pru_i2c_macro.h[355-357]

## Recommended Fix
Rename the new local labels to uppercase underscore_case while preserving the assembler's local-label suffix and update all branches to those renamed labels.

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

Dismiss ↗ | View ↗

3. New bus macros keep unprefixed names 📘
Description
The new assembler macros SET_SCL_PIN_LOW, SET_SDA_PIN_HIGH, SET_SDA_PIN_LOW, WAIT_SCL_HIGH,
PEC_UPDATE, and TX_FETCH_BYTE do not use the required m_ prefix. Their definitions and call
sites therefore introduce another macro naming form into the PRU assembler interface, making macro
ownership and searches inconsistent for later maintainers.
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 newly added assembler macros use unprefixed names even though the compliance convention requires every assembly macro to begin with `m_`.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[260-272]
- examples/pru_i2c/firmware/pru_i2c_macro.h[293-358]
- examples/pru_i2c/firmware/pru_i2c_macro.h[619-628]

## Recommended Fix
Rename each newly added macro to the corresponding `m_`-prefixed form and update every invocation in the modified assembler files, leaving no unprefixed aliases behind.

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

Dismiss ↗ | View ↗

4. Firmware headers omit license identifiers 📘
Description
pru_i2c_interface.h and pru_i2c_macro.h are modified PRU firmware headers but contain no
SPDX-License-Identifier comment before their declarations. Any compliance scan or downstream audit
that checks modified firmware files therefore cannot identify an approved license for 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 modified PRU firmware headers do not contain an SPDX-License-Identifier tag before their contents, preventing automated license identification.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_interface.h[1-32]
- examples/pru_i2c/firmware/pru_i2c_macro.h[1-32]

## Recommended Fix
Add the repository-approved SPDX-License-Identifier comment near the top of both firmware headers, before any declarations or assembler content.

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

Dismiss ↗ | View ↗

5. Host helpers lack required pseudocode 📘
Description
The new host functions such as PruI2c_init have descriptive comments but no marked pseudocode or
algorithm section. Their setup, firmware-loading, error-return and command flow therefore has no
language-agnostic control-flow summary for later maintainers.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New and modified host functions lack the required stepwise pseudocode documentation covering inputs, control flow, side effects and outputs.

## Fix Focus Areas
- examples/pru_i2c/mcuplus/pru_i2c_example.c[190-510]

## Recommended Fix
Add a `Pseudocode:` section to each function's associated comment, describing its inputs, loops or branches, resource and memory operations, error paths, and return result without copying C syntax.

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

Dismiss ↗ | View ↗

6. Clock-stretching paths have undocumented timing 📘
Description
WAIT_SCL_HIGH branches between released-high and clock-stretched paths, including a potentially
unbounded wait through STATE_TASK_OVER, without documenting path cycle counts, padding, clock
assumptions, or a finite worst-case budget. Because the macro runs in the I2C bit-timing state
machine for address and data bits, normal operation and target-held-low conditions can follow
different timing paths before subsequent SCL and SDA 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
`WAIT_SCL_HIGH` lacks documented timing constraints and per-path cycle analysis for both released-high and clock-stretched operation. Its wait may be unbounded, so a finite peak-cycle claim requires a finite bound.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[277-306]
- examples/pru_i2c/firmware/pru_i2c_main.asm[981-1057]
- examples/pru_i2c/firmware/pru_i2c_interface.h[91-95]

## Recommended Fix
Inspect the generated PRU assembly for each `WAIT_SCL_HIGH` path and document the cycle count for each path and any required padding immediately above the branches. Equalize released and stretched paths where required. Add nearby real-time constraints stating the assumed PRU/IEP clock, target SCL period and high/low deadlines, per-state cycle budget, and normal and stretched-clock assumptions. Either enforce a finite stretch bound and document the resulting worst-case PRU cycles, including timeout-disabled behavior, or explicitly document that the timeout-disabled invocation has no finite peak cost; keep this analysis current when the timing path changes.

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

Dismiss ↗ | View ↗

7. The scheduler can wait forever for a tick 📘
Description
I2C_WAIT_FOR_IEP_CMP branches back while the IEP compare-status bit is clear, with no timeout,
cancellation check, or INTENTIONALLY_UNBOUNDED_LOOP marker despite a comment calling the wait
unbounded by design. If the compare event never arrives or the status bit is misconfigured, each
state-machine invocation can remain stuck in the polling 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
`I2C_WAIT_FOR_IEP_CMP` polls the IEP compare status without a bounded exit condition, so a missing event can stall the firmware indefinitely; its comment calls the wait unbounded, but the required marker is absent.

## Fix Focus Areas
- examples/pru_i2c/firmware/pru_i2c_macro.h[82-107]

## Recommended Fix
Prefer a finite timeout or watchdog-based escape path that transitions to a failure state and reports a firmware timeout response when the compare event does not arrive within the allowed interval. If the scheduler contract requires an unbounded wait, add `INTENTIONALLY_UNBOUNDED_LOOP` immediately above the loop and document the external guarantee that makes the wait safe.

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

Dismiss ↗ | View ↗

8. Source code contains repeated spaces 📘
Description
The changed host source uses multiple consecutive spaces for alignment in macro definitions and
declarations, such as the spacing before comments and between type/name columns. This violates the
single-space source rule and makes whitespace normalization inconsistent across the new 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
The new C source contains consecutive spaces outside markdown, including alignment spacing in macro definitions.

## Fix Focus Areas
- examples/pru_i2c/mcuplus/pru_i2c_example.c[149-166]

## Recommended Fix
Replace consecutive spaces in source lines with single spaces, while retaining indentation at four spaces per nesting level and preserving comments and macro semantics.

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

Dismiss ↗ | View ↗

9. Host helpers omit cycle-budget comments 📘
Description
The new host helper PruI2c_waitForPru contains a polling loop and time reads but has no adjacent
worst-case cycle-count comment or measurement method. The same omission applies to the other newly
added functions in pru_i2c_example.c, so later changes cannot determine the execution-cost impact
required by the checklist.
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 host functions have no adjacent WCET documentation stating an upper bound, derivation or measurement method, and the wait helper includes a polling loop.

## Fix Focus Areas
- examples/pru_i2c/mcuplus/pru_i2c_example.c[217-228]
- examples/pru_i2c/mcuplus/pru_i2c_example.c[231-398]
- examples/pru_i2c/mcuplus/pru_i2c_example.c[405-510]

## Recommended Fix
Add a clearly labeled WCET comment above every new or modified function, including bounds and assumptions for polling and transfer loops, and state whether each value is measured or hand-counted.

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

Dismiss ↗ | View ↗


Comment thread examples/pru_i2c/makefile Resolved
Comment thread examples/pru_i2c/readme.md Resolved
pratheesh and others added 8 commits October 16, 2026 09:21
Address review findings on the macros changed by the per-core IEP and
scratchpad-bank fixes:
- I2C_IEP_INTC_CLEAR_EVENT: add pseudocode, the arg1 no-event continuation
  label that was documented as 'Parameters: None', and the registers it
  modifies.
- I2C_WAVE_FUNCTION0: add pseudocode and the registers it modifies,
  including the per-core context bank.
- I2C_WAIT_FOR_IEP_CMP: tag the scheduler tick with
  INTENTIONALLY_UNBOUNDED_LOOP; there is no other time base to time it
  out against.

Documentation only, no instruction changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
White space between mnemonic and operand is 5 spaces for 3-letter and 4
for 4-letter operations (best_practices.md); the SET/CLR/LDI32/LBBO/SBBO
lines in SET_SDA_PIN_INPUT/OUTPUT_DIRECTION used one space. Whitespace
only, the assembled output is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
NO_ADDRESS_ACK_RECIEVED took SDA back with the SDA GPO still holding the
last address bit (0 for a write), so after a NACKed write address the
master pulled SDA low on a bus it never STOPped, contradicting the
'SDA is released whenever the bus is idle' rule. Leave SDA released:
SET_SCL_SDA_HIGH takes it back at the start of the next transfer.

The data-byte ACK slot had the same pattern (SET_SDA_PIN_OUTPUT_DIRECTION
before testing the ACK bit). Take SDA back only after an ACK, when the
master transmits next (data or STOP).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…y selector

I2C_SETUP_IEP_COUNTER and I2C_IEP_INTC_CLEAR_EVENT add
I2C_GLOBAL_FREQ_REG.w2 to the compare value, but startup only loaded the
configuration word and nothing set w2 for the selected frequency. A
configuration holding just the selector (w0) gave an increment of 0, so
the compare was re-armed at the current count and the tick had no period.

Set w2 from the selector (IEP_CMP_INCREMENT_VAL_100KHZ / _400KHZ / _1MHZ)
before the IEP is set up. An unsupported selector keeps w2 = 0 and still
ends in ERROR_LOOP. Any w2 the host wrote is now replaced by the
selector's value.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
PRU0 and PRU1 share the IEP counter and IEP_CMP_CFG_REG and nothing in
hardware serialises their start-up. State that the two cores must be
released one after the other, and what goes wrong otherwise (lost enable
bit, counter reset under the running core).

The race itself is not closed in firmware: the enable-bit update is
already a read-modify-write rather than the earlier overwrite, and no
cross-core lock is available to these cores in this example.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Rebuilt with the makefile flow (make -C examples/pru_i2c pru DEVICE=am261x
BUILD_MCUPLUS=y) after the review-fix changes. Not hardware tested.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Derive w2 from the frequency selector only when the host left it at 0,
so a nonzero increment written by the host stays an override.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Pratheesh Gangadhar <pratheesh.gangadhar@gmail.com>
pratheesh and others added 5 commits October 16, 2026 14:04
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Pratheesh Gangadhar <pratheesh.gangadhar@gmail.com>
…ng timeout

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

Drivers_open() returns void in this SDK, so there is no status to check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Pratheesh Gangadhar <pratheesh.gangadhar@gmail.com>
The firmware set its bit in the shared 16-bit IRQ word with a load, set and
store, and the host cleared it with a read-modify-write. If both ran at the
same moment, or PRU0 and PRU1 raised their flags together, one write erased
the other's bit and that host timed out. Each instance now owns the byte
IRQ_COMMON_REGISTER_OFFSET + instance id: the PRU writes 1 with one store
(no load first), the host writes 0. Regenerate pru0/pru1_load_bin.h.

The raise macro drops one load and one set and adds one add and one load
immediate; the check macro adds one add. Not tested on hardware.

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

Copy link
Copy Markdown
Contributor Author

Pushed 8f4c1c2, which fixes Qodo finding 21 (lost IRQ flag).

The host cleared its instance bit in the shared 16-bit IRQ word with a read-modify-write. If the other PRU core set its own bit at the same moment, one flag was lost and that host timed out. Each instance now owns one byte at IRQ_COMMON_REGISTER_OFFSET + instance id: the PRU writes 1 with a single byte store, and the host writes 0. No read-modify-write is left on either side.

  • pru0_load_bin.h / pru1_load_bin.h are regenerated. A rebuild from this tree reproduces them byte for byte.
  • The R5F host code compiles with -Werror for am261x-lp.
  • Not yet run on hardware: a PRU I2C silicon test needs jumper wires on the LP-AM261. I'll post the result here when that runs.

This changes the flag layout shared between host and firmware, so anything else carrying this firmware (#171) needs the same layout.

@pratheesh

Copy link
Copy Markdown
Contributor Author

Silicon test on LP-AM263 (AM263x): PRU1 I2C master, PR head 8f4c1c2

I tested this PR's firmware on an LP-AM263 board. The port to AM263x needed no firmware fixes. The only firmware
change is to select the AM263x ICSSM_PRUx_GPIO_OUT_CTRL addresses (MSS_CTRL 0x50D00824/0x828 instead of AM261x's
0x810..0x81C) under SOC_AM263X in pru_i2c_main.asm. Everything else is the PR head as is, including
8f4c1c2's per-instance IRQ flag byte, which is now exercised on hardware.

Branch: https://github.com/pratheesh/open-pru/tree/pr-i2c-am263x-lp. It is this PR plus the AM263x PRU1 project, an
R5F bench app (examples/pru_i2c/mcuplus/am263x-lp/), the bench scripts and the raw results (bench/).

Setup. ICSSM PRU1 runs at 200 MHz. PR0_PRU1_GPIO17 (ball D13, J8-73) is SDA and PR0_PRU1_GPIO7 (ball A16,
J8-74) is SCL, jumpered to the board's I2C1 (J5-50/J5-49, 4.7 k pull-ups). The targets are the on-board CAT23M01
EEPROM (0x52/0x53) and the TPIC2810 LED driver (0x61). The PRU and the MCU I2C1 controller share the wires but are
never active together: the R5F stops the PRU and reads back that both lines are released before it opens I2C1, and
then reads back everything the PRU did.

test 100 kHz "400 kHz" (367.6 kHz)
Address probe: ACK at 0x61/0x52/0x53, NACK at 0x10/0x21 PASS PASS
PRU 16-byte read of 0x53:0x0400 equals the MCU I2C1 read PASS PASS
TPIC2810: PRU writes [0x11,p], MCU reads back p, PRU writes [0x22], for p = 0x55/0xAA/0x00 PASS PASS
EEPROM: PRU writes 8 bytes at 0x53:0x0400 (complement), MCU readback matches, PRU restores, MCU readback matches PASS PASS

The 400 kHz setting gives 367.6 kHz on AM263x because the 680 ns tick floor (tLOW >= 1.33 us) applies at the
200 MHz IEP clock. Increments are 0x9C4 and 0x2A8, which match IEP_CMP_INCREMENT_VAL_100KHZ/400KHZ.

What this confirms on silicon: the GPIO bit numbering (R30/OUT_CTRL bit n = PRU1_GPIOn), that PRU stores reach
MSS_CTRL OUT_CTRL, and that OUTDISABLE = 1 releases the line, so the open-drain emulation works as designed. It also
confirms the per-instance IRQ byte handshake with one instance active, and the EEPROM page write through the PRU's
write-pointer-then-read sequence.

Not covered: waveforms (no scope or analyser, so the rates come from the IEP arithmetic and rise time is
unmeasured), dual-instance concurrency (only PRU1 ran), long-run error rates (one session per rate), and AM261x (this
board only).

A side note for anyone testing against the TPIC2810: a read after 0x44 (write and load) returns 0xFF. Read back
after 0x11, as the MCU+ SDK i2c_led_read_write example does.

@pratheesh-ti
pratheesh-ti changed the base branch from a0502729_PRU_I2C to main December 1, 2026 07:23
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.
…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.
… 11.0+

The project was cloned from examples/empty before main moved AM26x to
MCU+ SDK 11.0+ (402bcbb, b12ce33). From SDK 11.0 the driver and board
libraries are built per OS (drivers.am261x.r5f.ti-arm-clang.nortos.*.lib),
and the old unsuffixed names no longer exist, so this example no longer
linked against the SDK used by main's CI (AM261x MCU+ SDK 26.00).

The same update is applied to the makefile, example.projectspec and
makefile_ccs_bootimage_gen as main's examples/empty, adapted for NORTOS:
- driver/board libraries use the .nortos. names; add -DOS_NORTOS
- link with --gen_xml_func_hash and write a .lnkxml link-info file
- the boot image is the multicore ELF (.mcelf) only, with
  --otfaConfigFile; the rprc/appimage steps are removed
- .S files are compiled with INCLUDES and DEFINES

Built with gmake against AM261x MCU+ SDK 11.00.00.29 (ti-cgt-armllvm
4.0.4.LTS, SysConfig 1.26.0): links and produces pru_i2c.release.mcelf.
examples/readme.md: add pru_i2c to the Projects list and to the
portability table, as docs_ai/task_create_project.md D4 asks. am261x is
Y (this project) and am263x is Yport (the PRU firmware ran on an
LP-AM263 with only the GPIO_OUT_CTRL addresses changed). The other
columns are FIXME rather than guessed: the firmware uses the MSS_CTRL
ICSSM_PRUx_GPIO_OUT_CTRL output-disable bits, and whether am243x,
am263px, am62x and am64x have an equivalent has not been checked.

examples/pru_i2c/readme.md: "Validated HW & SW" now lists the SDK 11
build tools and the LP-AM263 run (tests, rates, tools, the one
firmware change, and what was not covered). The board revision was not
recorded and is marked FIXME. The AM261x-LP has still not been run on
hardware. Drop the .appimage mention, since the SDK 11 boot image flow
only produces the .mcelf.
Comment thread examples/readme.md Resolved
…devices

pru_i2c_macro.h: the I2C_WAVE_FUNCTION0 note said the states never write
R26. SETUP_I2C_SCL_SDA_HIGH loads it (the GPIO_OUT_CTRL address) and
clears the SCL/SDA bits of R30, so say so. Add "Registers modified" and
"Registers read" blocks to RAISE_INTERRUPT_MEM_FOR_HOST,
RAISE_INTERRUPT_FOR_HOST, CHECK_INTERRUPT_RECEIVED and
I2C_SETUP_IEP_COUNTER, fill in RAISE_INTERRUPT_MEM_FOR_HOST's pseudo
code and arg1, and replace CHECK_INTERRUPT_RECEIVED's copy-pasted
description. Comments only: the regenerated pru0/pru1_load_bin.h are
unchanged.

examples/readme.md: add a FIXME comment to the pru_i2c portability row
so the FIXME cells read as not yet checked. They stay FIXME rather than
a guessed legend value, as docs_ai/task_create_project.md asks.
@pratheesh

Copy link
Copy Markdown
Contributor Author

Refreshed for main now that #137 is closed:

  • main merged (cfc0c41b) and examples: pru_i2c: fix PRU1/dual-core IEP use, read ACK and SDA control (for #137) #171 merged (40119da7). Open-drain-specific choices are listed in the merge commit and the description.
  • AM261x-LP NORTOS project moved to MCU+ SDK 11+ lib names and the mcelf-only boot image (958780a2). The SDK 10.2 versions no longer link against the SDK that CI now uses.
  • examples/readme.md index and portability row, plus "Validated HW & SW" with the LP-AM263 silicon run (26df1181).
  • Macro register-usage headers completed (2caa2959, comments only).

All review threads are answered and resolved. Not yet done: a run on an AM261x-LP, and the FIXME portability cells (am243x, am263px, am62x, am64x).

The PRU I2C firmware needs only PRU GPIOs whose outputs can be disabled
per pin, and the maintainer confirmed that am243x, am263px and am64x
are similar in that capability, so they are Yport. am62x is N-sw like
the other examples with an MCU+ R5F host: the PRU firmware may port, but
the host application would have to be rewritten.

Drop the board revision FIXME from the LP-AM263 hardware run row; the
board is identified as LP-AM263.
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