rellek
Posts: 2
Joined: Mon Feb 22, 2021 1:41 pm

CM3+ i2c0 mapping to pins 44/45 broken

Mon Feb 22, 2021 4:30 pm

Hi Everyone,

I am trying to get a real-time clock (RTC) to work on the i2c0 on a CM3+. I want to use pins 44&45 with the i2c0. This used to work with the following entry in config.txt:

Code: Select all

dtoverlay=i2c0,pins_44_45
dtoverlay=i2c0-rtc,pcf8523
i2c0-rtc was a rewritten overlay. I followed this instruction: viewtopic.php?f=44&t=213312&sid=55408f7 ... a51166806b.

This worked well with an older kernel. However, with the latest kernel this no longer seems possible. I am not even able to display the address with i2cdetect -y 0.

Code: Select all

pi@raspberrypi:~ $ 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: -- -- -- -- -- -- -- --

With the current kernel, now it should be possible to activate an RTC on i2c0 (pins 44&45) with the following entry:

Code: Select all

dtparam=i2c_vc=on
dtoverlay=i2c-rtc,pcf8523,i2c_csi_dsi
But this didn't work. To my surprise, instead of mapping to 44/45, the above command maps to GPIOs 28/29.

Code: Select all

pi@raspberrypi:~ $ raspi-gpio get
BANK0 (GPIO 0 to 27):
[...]
GPIO 2: level=1 fsel=4 alt=0 func=SDA1
GPIO 3: level=1 fsel=4 alt=0 func=SCL1
GPIO 4: level=1 fsel=0 func=INPUT
[...]
BANK1 (GPIO 28 to 45):
GPIO 28: level=0 fsel=4 alt=0 func=SDA0
GPIO 29: level=0 fsel=4 alt=0 func=SCL0
[...]
Did I miss something? As far as I understand, since the kernel version > 5.4, some changes have been made to the i2c overlays and multiplexing has been activated.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 10566
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: CM3+ i2c0 mapping to pins 44/45 broken

Mon Feb 22, 2021 5:59 pm

What exactly is in your i2c0-rtc overlay?

Any reference to &i2c_vc is incorrect and needs to be replaced with &i2c0if or &i2c0 if you're using "dtoverlay=i2c0,pins_44_45".
Having said that, "dtoverlay=i2c0,pins_44_45" is failing to configure GPIOs 44&45 to Alt1 on my CM4. All the pinctrl nodes appear to be set up correctly, but it's just not setting the muxing.

When enabling the mux it uses the pin configuration for that platform relating to the camera and display. If you follow the instructions for adding a camera module to CM3 then it'll use GPIOs 0&1, and 28&29, hence the allocation for i2c_csi_dsi being on 28&29.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

rellek
Posts: 2
Joined: Mon Feb 22, 2021 1:41 pm

Re: CM3+ i2c0 mapping to pins 44/45 broken

Tue Feb 23, 2021 10:19 am

Thank you for your quick response.
6by9 wrote:
Mon Feb 22, 2021 5:59 pm
What exactly is in your i2c0-rtc overlay?

Any reference to &i2c_vc is incorrect and needs to be replaced with &i2c0if or &i2c0 if you're using "dtoverlay=i2c0,pins_44_45".
I downloaded the i2c-rtc-overlay.dts from here https://github.com/raspberrypi/linux/bl ... verlay.dts, replaced all i2c_arm with i2c0 in the dts file and then compiled it to i2c0-rtc.dtbo

But let's put the rtc overlay aside for now. The main problem I have here is that I am not able to map i2c0 to pins 44&45. By activating the overlay

Code: Select all

dtoverlay=i2c0,pins_44_45
in config.txt I should be able to see the i2c client address with i2cdetect -y 0. But this is not the case.
6by9 wrote:
Mon Feb 22, 2021 5:59 pm
Having said that, "dtoverlay=i2c0,pins_44_45" is failing to configure GPIOs 44&45 to Alt1 on my CM4. All the pinctrl nodes appear to be set up correctly, but it's just not setting the muxing.
Can confirm, this is also not working on my CM4 neither on my CM3+.
So this is unplanned behavior?

What works on the CM4 is the entry

Code: Select all

dtparam=i2c_vc=on
dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi
This will map i2c0 to pins 44&45 on the CM4. But on the CM3+ it maps to 28&29. I can explain this behaviour with your description and source:
6by9 wrote:
Mon Feb 22, 2021 5:59 pm
When enabling the mux it uses the pin configuration for that platform relating to the camera and display. If you follow the instructions for adding a camera module to CM3 then it'll use GPIOs 0&1, and 28&29, hence the allocation for i2c_csi_dsi being on 28&29.
Isn't the description for the i2c-rtc-overlay a bit misleading then?
pi@raspberrypi:~ $ dtoverlay -h i2c-rtc
Name: i2c-rtc

Info: Adds support for a number of I2C Real Time Clock devices
[...]

i2c0 Choose the I2C0 bus on GPIOs 0&1

i2c_csi_dsi Choose the I2C0 bus on GPIOs 44&45

[...]
So the parameter i2c_csi_dsi is platform related (CM4 => pins 44/45 & CM3+ => pins 28/29).

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 10566
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: CM3+ i2c0 mapping to pins 44/45 broken

Tue Feb 23, 2021 12:31 pm

rellek wrote:
Tue Feb 23, 2021 10:19 am
6by9 wrote:
Mon Feb 22, 2021 5:59 pm
Having said that, "dtoverlay=i2c0,pins_44_45" is failing to configure GPIOs 44&45 to Alt1 on my CM4. All the pinctrl nodes appear to be set up correctly, but it's just not setting the muxing.
Can confirm, this is also not working on my CM4 neither on my CM3+.
So this is unplanned behavior?
Yes, unplanned behaviour. Enabling via dtoverlay=i2c0 should disable the mux and reinstate the "old" behaviour.
rellek wrote:What works on the CM4 is the entry

Code: Select all

dtparam=i2c_vc=on
dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi
This will map i2c0 to pins 44&45 on the CM4. But on the CM3+ it maps to 28&29. I can explain this behaviour with your description and source:
6by9 wrote:
Mon Feb 22, 2021 5:59 pm
When enabling the mux it uses the pin configuration for that platform relating to the camera and display. If you follow the instructions for adding a camera module to CM3 then it'll use GPIOs 0&1, and 28&29, hence the allocation for i2c_csi_dsi being on 28&29.
Isn't the description for the i2c-rtc-overlay a bit misleading then?
pi@raspberrypi:~ $ dtoverlay -h i2c-rtc
Name: i2c-rtc

Info: Adds support for a number of I2C Real Time Clock devices
[...]

i2c0 Choose the I2C0 bus on GPIOs 0&1

i2c_csi_dsi Choose the I2C0 bus on GPIOs 44&45

[...]
So the parameter i2c_csi_dsi is platform related (CM4 => pins 44/45 & CM3+ => pins 28/29).
Yes, that is indeed a badly worded bit of help text.
i2c_csi_dsi is the I2C pinmuxing that is used by the camera (CSI) and display (DSI) connectors on a Pi. Those vary between 28&29 and 44&45 based on board variant.
The board dt file will pull in either bcm283x-rpi-i2c0mux_0_28.dtsi or bcm283x-rpi-i2c0mux_0_44.dtsi.

When using the mux, i2c0 should always be on 0&1.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Compute Module”