Jump to content

How do I Enable i2c2 on Armbian 24.11.1 Bookworm Minimal


Go to solution Solved by c0rnelius,

Recommended Posts

Posted (edited)

context
------------
Hardware: BPI CM4 on BPI CM4IO board
OS: Armbian 24.11.1 Bookworm Minimal Build: https://dl.armbian.com/bananapicm4io/Bookworm_current_minimal

problem

------------

How do i enable i2c2 so i can be able to use the following pins on the BPI CM4IO board for i2c
 

pin 82 (GPIOX_17): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 83 (GPIOX_18): (MUX UNCLAIMED) periphs-banks:595


Previously on the ubuntu build all i had to do is add the following line to `/boot/env.txt` , `overlays="12c2"`, as stated in this doc https://wiki.banana-pi.org/Getting_Started_with_CM4#DTB_overlay
 

2. Update the overlays env in vfat /boot/env.txt to enable what you want.
 # Device Tree Overlays
 #   uart1           -- Enable UART1 (uart_A, GPIO Header PIN8 & PIN10)
 #   pwm_c           -- Enable PWM_C (GPIO Header PIN7)
 #   i2c2            -- Enable i2c2 (GPIO Header PIN3 & PIN5)
 #   spi0            -- Enable SPI0 (GPIO Header PIN19 & PIN21 & PIN23 & PIN24)
 overlays="i2c2 spi0 uart1"


but on the `Armbian 24.11.1 Bookworm Minimal Build` i cant find this overlay
 

pi@bananapicm4io:~$ sudo ls /boot/dtb-6.6.61-current-meson64/amlogic/overlay/
README.meson-overlays					meson-g12a-radxa-zero-pwmao-a-on-gpioao-11.dtbo		   meson-i2cA.dtbo
meson-fixup.scr						meson-g12a-radxa-zero-spi-spidev.dtbo			   meson-i2cB.dtbo
meson-g12-gxl-cma-pool-896MB.dtbo			meson-g12a-radxa-zero-uart-ao-a-on-gpioao-0-gpioao-1.dtbo  meson-sm1-bananapi-m5-rtl8822cs.dtbo
meson-g12-pwm-gpiox-5-fan.dtbo				meson-g12a-radxa-zero-uart-ao-b-on-gpioao-2-gpioao-3.dtbo  meson-sm1-bananapi-uartA.dtbo
meson-g12a-radxa-zero-gpio-10-led.dtbo			meson-g12a-radxa-zero-uart-ao-b-on-gpioao-8-gpioao-9.dtbo  meson-sm1-bananapi-uartAO_B.dtbo
meson-g12a-radxa-zero-gpio-8-led.dtbo			meson-g12a-radxa-zero-uart-ee-c.dtbo			   meson-sm1-bananapi-uartA_cts_rts.dtbo
meson-g12a-radxa-zero-i2c-ao-m0-gpioao-2-gpioao-3.dtbo	meson-g12b-bananapi-cm4-pwm-gpioh-5-fan.dtbo		   meson-uartA.dtbo
meson-g12a-radxa-zero-i2c-ee-m1-gpioh-6-gpioh-7.dtbo	meson-g12b-bananapi-cm4-wifi-freq-200mhz.dtbo		   meson-uartC.dtbo
meson-g12a-radxa-zero-i2c-ee-m1-gpiox-10-gpiox-11.dtbo	meson-g12b-bananapi-m2s-rtl8822cs.dtbo			   meson-w1-gpio.dtbo
meson-g12a-radxa-zero-i2c-ee-m3-gpioa-14-gpioa-15.dtbo	meson-g12b-odroid-n2-spi.dtbo				   meson-w1AB-gpio.dtbo
meson-g12a-radxa-zero-pwm-c-on-gpiox-8.dtbo		meson-g12b-waveshare-cm4-io-base-usb.dtbo
pi@bananapicm4io:~$ cat /boot/armbianEnv.txt 
verbosity=1
console=both
overlay_prefix=meson
fdtfile=amlogic/meson-g12b-bananapi-cm4-cm4io.dtb
rootdev=UUID=e4b40e17-5d66-4b52-a45e-4a8c6cdee335
rootfstype=ext4
fdt_overlays=
overlays=i2c2 
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
pi@bananapicm4io:~$ 



i2cdetect output on Armbian (on ubuntu image i get a reading on i2cdetect -y 1 but not on armbian)
 

pi@bananapicm4io:~$ sudo i2cdetect -l
i2c-0	i2c       	Meson I2C adapter               	I2C adapter
i2c-1	i2c       	Meson I2C adapter               	I2C adapter
i2c-2	i2c       	DesignWare HDMI                 	I2C adapter
pi@bananapicm4io:~$ sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@bananapicm4io:~$ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@bananapicm4io:~$

 

Edited by jak
wrong pins listed
Posted

@c0rnelius thanks for the quick response
I had actually tried this before, sorry I didn't include it in my original question.  I get the behavior below when i add the user-overlay. 

Adding this user overlay seems to enable an i2c device but i still dont get any comms on that i2c device 
 

root@bananapicm4io:/home/pi# sudo cat /sys/kernel/debug/pinctrl/ff634400.bus:pinctrl@40-pinctrl-meson/pinmux-pins | grep i2c
pin 22 (GPIOH_6): ffd1e000.i2c (GPIO UNCLAIMED) function i2c1 group i2c1_sda_h6
pin 23 (GPIOH_7): ffd1e000.i2c (GPIO UNCLAIMED) function i2c1 group i2c1_sck_h7
pin 63 (GPIOA_14): ffd1c000.i2c (GPIO UNCLAIMED) function i2c3 group i2c3_sda_a
pin 64 (GPIOA_15): ffd1c000.i2c (GPIO UNCLAIMED) function i2c3 group i2c3_sck_a
pin 82 (GPIOX_17): ffd1d000.i2c (GPIO UNCLAIMED) function i2c2 group i2c2_sda_x
pin 83 (GPIOX_18): ffd1d000.i2c periphs-banks:595 function i2c2 group i2c2_sck_x
root@bananapicm4io:/home/pi# i2cdetect -l
i2c-0	i2c       	Meson I2C adapter               	I2C adapter
i2c-1	i2c       	Meson I2C adapter               	I2C adapter
i2c-2	i2c       	Meson I2C adapter               	I2C adapter
i2c-3	i2c       	DesignWare HDMI                 	I2C adapter
root@bananapicm4io:/home/pi# 

See 
 

root@bananapicm4io:/home/pi# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@bananapicm4io:/home/pi# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@bananapicm4io:/home/pi# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@bananapicm4io:/home/pi# i2cdetect -y 3
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@bananapicm4io:/home/pi# 

This is the same issue i had when i tried to create my own user overlay (you can see in the armbian-monitor trace my fruitless attempts)

To prove that its not my hardware connection, here is the same command runned on an SD card running this ambian build: 2023-12-26-ubuntu-20.04-server-bpi-cm4-aarch64-sd-emmc.img.zip
https://drive.google.com/drive/folders/1ogrdn-Kx5oqIOLUhwMqqMAhxZIcDYzPs

(All i did was swap the sd card and runned the same cmd, no change in h/w connections)
Notice in the trace below its able to detect the i2c device on address 
 

root@ubuntu:/home/pi# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal
root@ubuntu:/home/pi# uname -r
4.9.241-BPI-CM4
root@ubuntu:/home/pi# i2cdetect -l
i2c-3	i2c       	Meson I2C adapter               	I2C adapter
i2c-2	i2c       	Meson I2C adapter               	I2C adapter


root@ubuntu:/home/pi# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- 41 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: 70 -- -- -- -- -- -- --                         
root@ubuntu:/home/pi# tail /boot/env.txt 
# 2 - 180 degree
# 3 - 270 degree
fb_rotate=0

# Device Tree Overlays
#   uart1           -- Enable UART1 (uart_A, GPIO Header PIN8 & PIN10)
#   pwm_c           -- Enable PWM_C (GPIO Header PIN7)
#   i2c2            -- Enable i2c2 (GPIO Header PIN3 & PIN5)
#   spi0            -- Enable SPI0 (GPIO Header PIN19 & PIN21 & PIN23 & PIN24)
overlays="i2c2"
root@ubuntu:/home/pi# 

 

Posted

Any idea how can build the minimal image of  an earlier "stable" kernel (that supported the use of inbuilt i2c/uart overlays).
 

I will look into this more when I get the time but at the moment I just want to get i2c working, the ubuntu 20.04 server image is great and works but it takes a bit longer to boot, my assumption is if I can build a minimal image of the same it would improve boot time a little.

Yes am aware of the problems that come with using an earlier kernel but at the moment I want to focus on the project functional units and abstract myself from spending an entire day trying to make i2c work.

  • Solution
Posted

@jak Try this one.

 

/dts-v1/;
/plugin/;

/ {
	fragment@0 {
		target = <&i2c2>;
		__overlay__ {
			status = "okay";
		};
	};

	fragment@1 {
		target = <&uart_A>;
		__overlay__ {
			status = "disabled";
		};
	};
};

 

Result in my case:

bananapi: ~  $ sudo i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  

 

Posted

@c0rnelius it works
 

root@bananapicm4io:~# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- 41 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: 70 -- -- -- -- -- -- --  

i dont know which device is at 0x70 but i will figure it out.

Can you explain why your overlay works?

Posted
43 minutes ago, jak said:

Can you explain why your overlay works?

 

Both Bluetooth and i2c2 use GPIOX_17 and GPIOX_18, so we need to disable Bluetooth for those HEADER PINS to function. Basically, if you need i2c2 than you are going to lose Bluetooth support.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines