Using bone bus I2C on BBBWL/BBB/BBAI 19 Jul 2020
In this post we will take a look at how you can use the new compatibility layer along with some new bone bus DT overlays to setup /dev/bone/i2c/*
on your BBBWL/BBB/BBAI.
🐾 Installing the compatibility layer
Please refer to the “Installing compatibility layer on your BBBWL/BBB/BBAI” post for this.
🐾 bone bus i2c
We have these i2c peripherals available to use:
bone bus | BBBWL/BBB | BBAI | I2C SCL | I2C SDA |
---|---|---|---|---|
/dev/bone/i2c/1 | I2C1 | I2C5 | P9.17 | P9.18 |
/dev/bone/i2c/2 | I2C2 | I2C4 | P9.19 | P9.20 |
/dev/bone/i2c/2a | I2C2 | N/A | P9.21 | P9.22 |
/dev/bone/i2c/3 | I2C1 | I2C3 | P9.24 | P9.26 |
Note: If you are using BBBWL/BBB you can not use both /dev/bone/i2c/1
and /dev/bone/i2c/3
at the same time as they both use I2C1, same goes for /dev/bone/i2c/2
and /dev/bone/i2c/2a
as they both use I2C2!
🐾 Installing /dev/bone/i2c/* DT overlays
- Clone the repository,
$ git clone https://github.com/lorforlinux/bb.org-overlays.git
. - Change directory,
$ cd bb.org-overlays
. - Change branch,
$ git checkout bone_i2c
. - Compile overlays,
$ make
. - Install bone i2c DT overlays,
$ sudo cp src/arm/BONE-I2C{1,2,2A,3}-00A0.dtbo /lib/firmware/
. - To cleanup the binaries you can use,
$ make clean
.
Now, you are all set to use the overlays!
🐾 Loading the overalys using /boot/uEnv.txt
To load the overlays during boot you have to edit /boot/uEnv.txt
. You can use either nano
OR vim
to edit the file. There are total 8 slots for overlays which we can use, uboot_overlay_{addr0 - addr3}
are used to override cape with EEPROM and uboot_overlay_{addr4 - addr7}
are used for additional custom capes. I suggest to use uboot_overlay_{addr4 - addr7}
for bone i2c virtual capes but, You can use any to load the overlay.
To load the capes you can uncomment the lines for the slots if they are already present in the /boot/uEnv.txt
but commented out as we see on BBBWl/BBB’s uEnv.txt
. If by any chance they are not present you can copy paste them form below. You can learn more about u-boot SPL overlays here!
enable_uboot_overlays=1
#uboot_overlay_addr4=/lib/firmware/BONE-I2C1-00A0.dtbo
#uboot_overlay_addr5=/lib/firmware/BONE-I2C2-00A0.dtbo
#uboot_overlay_addr6=/lib/firmware/BONE-I2C2A-00A0.dtbo
#uboot_overlay_addr7=/lib/firmware/BONE-I2C3-00A0.dtbo
Now, you can uncomment the overlay(s) you want to load during boot. Just keep in mind that you can not use both /dev/bone/i2c/1
and /dev/bone/i2c/3
at the same time as they both use I2C1, same goes for /dev/bone/i2c/2
and /dev/bone/i2c/2a
as they both use I2C2. For BBAI we don’t have /bone/i2c/2a
available so loading overlay /lib/firmware/BONE-I2C2A-00A0.dtbo
will not do anything on BBAI.