Usage of the KX132 with the BBAI PRU I2C driver for BeagleBone AI. This work takes advantage of an the BBAI-PRU-I2C driver to obtain deterministic vibration data with the Beaglebone AI. This has been developped for the BBAI TIDL image: 4.14.108-ti-r131 There are changes in newer images: the call to remoteproc are done differently, the PRUs names are also different. However, at the time 4.14.108-ti-r131 is what you get if you use the recommanded images from the BeagleBone Foundation website, so I have been using this image.
Clone the repository:
cd ~
git clone https://github.com/PierrickRauby/BBAI-PRU-I2C.git
Then you will want to change the am57xx_pru.cmd linker file located under:
/var/lib/cloud9/common
. Comment:
I2C3 : org = 0x48060000 len = 0x00000300 CREGISTER=5
And replace by this line instead:
I2C1 : org = 0x4807A000 len = 0x00000300 CREGISTER=5
This will let the pru-cgt compile understand the hardware register described by the library.
Once you have change the linker file you can go back to the project's folder:
cd ~
cd BBAI-PRU-I2C
Then compile and run the pru codes by doing:
cd pru_codes
make
The make file will do everything for you, including booting the pru. The last step is to start the user space execution, from the project's folder:
cd user_space
make
./user_space
The output is the value written in the Portrait Landscape register.
The project is composed of different folders:
- pru_codes: contains the
main.c
that call the I2C function and setups the BUS depending on the request send from the user space via rpmsg, aMakefile
to compile the PRU codes, stop the PRU1, place the firmware and start the PRU. The folder also includes the driver fileam572x_pru_i2c_driver.pru1_1.c
with the I2C fonctions. Inside pru_codes theinclude
folder contains the struct that describes the HSI2C registers. - user_space: present an example of user space code using rpmsg to tell the PRU to trigger an I2C transaction. The result of the transaction is then sent to the user space with rpmsg.