BBAI PRU-I2C driver

Hi All,

I am trying to develop a PRU driver for I2C on the Beaglebone AI (Ti-am5729). I have some questions about the setup procedure using Interrupt and polling (I am not using DMA). I am not quite sure about the differences between the setup described between section 24.1.5.1.1.1.1 and 24.1.5.1.1.1.2) and the figure (24.19) of the TRM.

1- I am not sure about the value to put for I2C_IRQENABLE_SET (referenced in figure 24.19) I have tried with 0x1f (enable XRDY, RRDY, ARDY, NACK, and AL as they are used later). However, I receive a Kernel Oops when I try to run my code " [Feb26 14:54] Unable to handle kernel NULL pointer dereference at virtual address 00000000

[ +0.003725] Internal error: Oops: 5 [#1] PREEMPT SMP ARM

genirq: exiting task “irq/114-4807a00” (110) is an active IRQ thread (irq 114)"

What value should be used to configure the I2C_IRQENABLE_SET?

2- I have tried to write in the I2C_DATA register but reading the register after always gives 0xD. I have checked the value of I2C_IRQSTATUS_RAW, and it always read 0x10 (XRDY). Am I missing something to write the data?

If you want to have a look at my code, it is under this repository https://github.com/PierrickRauby/BBAI-PRU-I2C/blob/main/am572x_pru_i2c_driver.pru1_1.c

Thanks for any help you can provide!

Pierrick

PS: I have posted this same question on the Ti e2e forum a few days ago but I have not solved my issue yet.

Hey, can I flip it around? Becuase I have a question for you.

Have you managed to get this working on a normal BBB? I’m also trying to develop an i2c driver for the PRU. It almost looks like we started with the same codebase (https://github.com/LinuxDroneLab/pru-i2c-lib), but you have obviously modified yours a lot more than I have mine to get it working with the 527.

There is definitely some piece missing here. Mine gets to the point of setting the I2C_CON register, but then XRDY never comes, and if I read back the I2C_CON register, it has lost its master bit. If you look at the TRM, it says that the bit is automatically cleared “at the end of a transfer on a dedicated stop condition, in case of arbitration lost or when the module is configured as a master but addressed as a slave by an external master.” When I read back the IRQSTATUS register, it just gives back 0.

I’ve tried trawling through e2e support threads, but the most promising ones always link to the TI Processors wiki, which TI decided wasn’t worth maintaining and shut down about 2 months ago :frowning:

I made another thread begging people for their stash of these old articles (https://groups.google.com/u/0/g/beagleboard/c/w6Nd1WmPoSU), so that may be of interest to you as well.

I’m sorry if it feels like I’m hijacking your thread, but maybe we can help each other out here?

Thanks,
Fred

Hey Fred,
Yeah, I have found the LinuxDroneLab library useful, but the am5729 is quite different from the AM335x… so no luck for me on that, and I have not tried to run in on the BBB. Is it not working out of the box?
Have you kept the “pru_i2c_driver_DelayMicros(12);” from the LinuxDroneLab ? What are you writing to the CON register before polling XRDY?
Thanks

Pierrick

PS: I am missing the Ti wiki too haha!

Hi Fred,
An update on my progress. After a meeting with Jason Kridner, I solved the Kernel Oops issue that I had. The problem was writing something on the I2C_IRQENABLE_SET register (fixed in this commit).
I am now working on the rest of the code; I have confirmed that I don’t receive XDR, but I receive XRDY (Figure 24-20 of the TRM), which I expect to happen.
I will continue developing my code and keep you posted. Any progress on your side?
Thanks,
Pierrick