Beaglebone Black I2C patch - cu-ecen-aeld/buildroot-assignments-base GitHub Wiki
Beaglebone Black has 3 I2C buses available. Out of these 3, I2C-0 is used internally for some onboard components (HDMI, EEPROM, etc). You can test this by running i2cdetect -r -y 0
. It isn't brought out to any pins on the expansion header.
I2C-1 and I2C-2 buses are available and can be used after adding the I2C patch. Although I2C-2 bus is visible after adding i2c-tools
package to the kernel, the bus isn't mapped to the expansion port by default. This prevents it from being used unless the patch has been added to modify the device tree overlay.
The I2C-2 bus is by default assigned to be used for the capes in the device overlay tree. You can check this in am335x-bone-common.dtsi. If you aren't using capes, then you can use either of the I2C-1 and I2C-2 buses
You can use the following steps to generate your own patch for I2C if needed. These steps will also work for generating the patch for other peripherals but the modifications to am335x-bone-common.dtsi will vary depending on the application.
- Create a new temporary repo in github. The am335x-bone-common.dtsi is present in the buildroot/output directory and it's also present in .gitignore.
- Build a working kernel image. The packages present in the image won't affect the patch. Ensure that buildroot/output/build/linux-custom/arch/arm/boot/dts/am335x-bone-common.dtsi file is present in your local repo. Push arch/arm/boot/dts/am335x-bone-common.dtsi on the new temporary repo. This will create a copy of this file that we will use to generate a patch.
- Modify the local am335x-bone-common.dtsi file based on your need.
git commit -m "any message"
- !!! DON'T PUSH THE MODIFIED FILE TO GITHUB !!!
- Make modifications to the am335x-bone-common.dtsi
- Go to the location on am335x-bone-common.dtsi file in the local files of the temporary repo and enter
git diff -u am335x-bone-common.dtsi>patchfile_name.patch
. This should generate a patch in the same directory with the name patchfile_name.patch.
Currently the patch makes the following modifications to am335x-bone-common.dtsi
- Uncomments the configuration for I2C-2 pins at lines 82-87.
- Uncomments the line that configures the pinout on P9 expansion port for I2C-2 bus at line 290
- Adds configuration for I2C-1 bus.
- Following the steps here https://github.com/cu-ecen-aeld/buildroot-assignments-base/wiki/Beagle-Bone-Black-Devicetree-Hardware-Support check if buildroot/output/build/linux-custom/arch/arm/boot/dts/am335x-bone-common.dtsi get modified.