Enable I2C Driver

November 9, 2017


I would like to make a note for a trick that I have done in the PYNQ project. After building the SD card image, and booting it up on the board, I have seen the I2C support is not added into the current device list. In other words, after booting up the board, you won't be able to see i2c-0 or i2c-1 in /dev.


I did the following steps to bring them up:

Step 1: Go inside the Linux kernel source folder. For example, we can git clone from the Xilinx PetaLinux release.

Step 2: In the Ubuntu building environment, run: make ARCH=arm menuconfig

Step 3: In the GUI, select Device Drivers --> I2C support --> I2C Hardware Bus support --> Cadence I2C Controller.

Type Y there to select it. Note that if that option is not there, please make sure the ARCH is set to arm. Another thing to notice, is that Xilinx I2C Controller should not be selected since it is not related to the PS-controlled I2C.


The final configuration can be saved as a file. Let's call it kernel.config and compare with the one used in the boot configuration of the image building flow. We can see the only difference is:

# CONFIG_I2C_CADENCE is not set

has been changed into:

CONFIG_I2C_CADENCE=y

Step 4: Rebuild the boot files.

Step 5: Update the files in the boot partition of the SD card image.

Step 6: Boot up the board again, we can see both the i2c-0 and i2c-1 are there in the device list, ready to be used!