Repository navigation
Conversation
- 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>
PR Summary by Qodoexamples: pru_i2c: add PRU I2C master firmware and R5F NORTOS example
AI Description
Merge Risk
|
…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>
|
/agentic_review |
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>
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>
|
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
This changes the flag layout shared between host and firmware, so anything else carrying this firmware (#171) needs the same layout. |
Silicon test on LP-AM263 (AM263x): PRU1 I2C master, PR head 8f4c1c2I tested this PR's firmware on an LP-AM263 board. The port to AM263x needed no firmware fixes. The only firmware Branch: https://github.com/pratheesh/open-pru/tree/pr-i2c-am263x-lp. It is this PR plus the AM263x PRU1 project, an Setup. ICSSM PRU1 runs at 200 MHz.
The 400 kHz setting gives 367.6 kHz on AM263x because the 680 ns tick floor (tLOW >= 1.33 us) applies at the What this confirms on silicon: the GPIO bit numbering (R30/OUT_CTRL bit n = Not covered: waveforms (no scope or analyser, so the rates come from the IEP arithmetic and rise time is A side note for anyone testing against the TPIC2810: a read after |
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.
…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.
|
Refreshed for
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.
Adds the PRU I2C/SMBus master (
examples/pru_i2c) and its R5F NORTOS host example for the AM261x-LP. This PR now targetsmainand supersedes #137.Status (refreshed after #137 was closed)
9a16e005,d3795004) and every fix from examples: pru_i2c: fix PRU1/dual-core IEP use, read ACK and SDA control (for #137) #171 (merged in40119da7). On top of those it adds the open-drain bus with SMBus support, the R5F example and the review follow-ups below.mainmerged in (cfc0c41b). The only conflict was theexamples/makefileSUBDIRS list;pru_eqep,pru_i2candpru_i2sare all kept.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. Theam261x-lp/r5fss0-0_nortosmakefile, projectspec and boot-image makefile were regenerated frommain'sexamples/emptyam261x-lp project, with NORTOS in place of FreeRTOS. The SDK 10.2 versions no longer link.26df1181,2caa2959).pru_i2cis now in theexamples/readme.mdproject list and portability table, perdocs_ai/task_create_project.mdD4. am261x isY. am243x, am263px, am263x and am64x areYport, since they have similar per-pin PRU GPIO output-disable capability. am62x isN-sw, as for the other examples with an MCU+ R5F host (7c16c703). The readme's "Validated HW & SW" now reports the silicon run below.2caa2959also 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:
INTENTIONALLY_UNBOUNDED_LOOPscheduler marker, the selector-to-increment fallback (used only when the host leaves the increment at 0), and the shared-IEP start-up ordering note.The R5F host always writes the increment, so the merged firmware takes the same path as the silicon-tested
8f4c1c2c. The regeneratedpru0/pru1_load_bin.hgrew by exactly the fallback's 7 instructions.What the example does
mcuplus/pru_i2c_example.ctakes every offset, command and response code frompru_i2c_interface.h. The sequence:SETUP.[ptr, 4 bytes]to an EEPROM-style target at 0x50.[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_GPIOxsignals reach a BoosterPack header. SCL isPR0_PRU1_GPIO18(J1.4) and SDA isPR0_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.mddocuments 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 producespru_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 AM263xGPIO_OUT_CTRLaddresses. These all passed at 100 kHz and at 367.6 kHz, with the MCU I2C1 controller reading back every transfer:Details are in the comment below and on the
pr-i2c-am263x-lpbranch of the fork.Not covered:
🤖 Generated with Claude Code