kahlenberg
Posts: 59
Joined: Mon Jul 29, 2013 10:47 am

CM4 I²C0 and I²C1 connections

Wed Dec 16, 2020 10:56 pm

Hi,

In the schematics of CM4 there are two I²C modules: [ID_SD, ID_SC] and [SCL0, SDA0]. So, I assume that [SCL0, SDA0] is I²C0 module and [ID_SD, ID_SC] is I²C1 module. Normally (in Raspberry Pi 4) [ID_SD, ID_SC] is I²C0 module.
Is this a schematics error?

Rasperry Pi 4 pinout:

Image

CM4 pinout
Image
Thanks.

aBUGSworstnightmare
Posts: 6028
Joined: Tue Jun 30, 2015 1:35 pm

Re: CM4 I²C0 and I²C1 connections

Thu Dec 17, 2020 5:09 am

Dt-blob source file gives you the answers to such questions! Look at https://github.com/raspberrypi/document ... .dts#L1876

As you can see, GPIO44/45 is I2C used for the camera, HAT EEPROM has no I2C assigned (absent)

schematic is perfectly fine.
Also look at the documentation for more details https://github.com/raspberrypi/document ... putemodule

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4733
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 I²C0 and I²C1 connections

Thu Dec 17, 2020 9:10 am

All of the IDC header pins on the CM4IO board have the functions as on a regular Pi. This includes I2C0 being connected to pins 27 & 28, also known as ID_SD and ID_SC. It is true that the dt-blob doesn't currently declare those pins, but that will change in the next firmware release - in the meantime an external dt-blob.bin can be used to enable HAT functionality.

cleverca22
Posts: 6823
Joined: Sat Aug 18, 2012 2:33 pm

Re: CM4 I²C0 and I²C1 connections

Thu Dec 17, 2020 9:38 am

PhilE wrote:
Thu Dec 17, 2020 9:10 am
All of the IDC header pins on the CM4IO board have the functions as on a regular Pi. This includes I2C0 being connected to pins 27 & 28, also known as ID_SD and ID_SC. It is true that the dt-blob doesn't currently declare those pins, but that will change in the next firmware release - in the meantime an external dt-blob.bin can be used to enable HAT functionality.
i'm thinking that HAT functionality should be off by default on a CM, given that it will generally be running in an embedded situation with the correct firmare on its eMMC

what about having it in dt-blob, but the config.txt to turn hat scanning off, has the default flipped on a CM4?, so that same config.txt entry is instead used to turn it back on?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4733
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 I²C0 and I²C1 connections

Thu Dec 17, 2020 9:43 am

The decision has been made to enable it by default. "force_eeprom_read=0" (or a custom dt-blob) will be required to disable it.

cleverca22
Posts: 6823
Joined: Sat Aug 18, 2012 2:33 pm

Re: CM4 I²C0 and I²C1 connections

Thu Dec 17, 2020 9:50 am

PhilE wrote:
Thu Dec 17, 2020 9:43 am
The decision has been made to enable it by default. "force_eeprom_read=0" (or a custom dt-blob) will be required to disable it.
and i guess its not that big of a deal for anybody using the CM4 and gpio0/1, to just do ""force_eeprom_read=0", exactly like they would have done on any other pi model
keeps things simple by having the same default everywhere

kahlenberg
Posts: 59
Joined: Mon Jul 29, 2013 10:47 am

Re: CM4 I²C0 and I²C1 connections

Thu Dec 17, 2020 9:51 pm

RTC PCF85063AT/AAZ on CM4IO Board uses SCL0/SDA0.
That means, it is not connected to HAT EEPROM I²C (ID_SD, ID_SC) and this is totally ok, right?
And, CAM1 and DSI1 are also connected to SCL0/SDA0, CAM0 and DSI0 are connected to ID_SD, ID_SC.

Another question: Are ID_SD, ID_SC pulled-up on CM4 module?

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

Re: CM4 I²C0 and I²C1 connections

Fri Dec 18, 2020 9:23 am

kahlenberg wrote:
Thu Dec 17, 2020 9:51 pm
RTC PCF85063AT/AAZ on CM4IO Board uses SCL0/SDA0.
That means, it is not connected to HAT EEPROM I²C (ID_SD, ID_SC) and this is totally ok, right?
It's fine but with the caveat that you can't use the firmware camera / touchscreen drivers over GPIOs 44&45 (SDA0/SCL0) at the same time as the kernel drivers for the RTC and fan controller.

Indeed you can't use the BSC0 (Broadcom Serial Controller) peripheral as a whole from both processors, therefore you can't use ID_SD/ID_SC (0&1) from the ARM at the same time as SDA0/SCL0 (44&45) from the firmware.
44&45 can be remapped to come from BSC1 instead, and you can set up the i2c-pinctrl-mux to allow use of 2&3 and 44&45 from BSC1. It's not a configuration that will be adopted as a standard though.
kahlenberg wrote:And, CAM1 and DSI1 are also connected to SCL0/SDA0, CAM0 and DSI0 are connected to ID_SD, ID_SC.
Correct.
kahlenberg wrote:Another question: Are ID_SD, ID_SC pulled-up on CM4 module?
It's in the CM4IO datasheet. Schematics on page 9, fig 4 CM4 Highspeed.
If the jumpers on J6 are fitted, you get 2k2 pullups. Otherwise there are no pullups. There are no pull-ups for those lines on the CM4 itself.
As stated in the CM4 datasheet, "GPIO2 and GPIO3 have 1.8K pull up resistors"
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

darkstar96
Posts: 1
Joined: Mon Dec 28, 2020 4:14 am

Re: CM4 I²C0 and I²C1 connections

Mon Dec 28, 2020 4:18 am

PhilE wrote:
Thu Dec 17, 2020 9:10 am
All of the IDC header pins on the CM4IO board have the functions as on a regular Pi. This includes I2C0 being connected to pins 27 & 28, also known as ID_SD and ID_SC. It is true that the dt-blob doesn't currently declare those pins, but that will change in the next firmware release - in the meantime an external dt-blob.bin can be used to enable HAT functionality.
I'm attempting to use a Pi UPS HAT on the CM4IO board with the CM4 and ran across this thread. I'm having i2c communication problems with the hat and have verified it works on a Pi4.

From what I can see, i2cdetect shows the correct addresses and data.

Does the CM4 have HAT functionality enabled out of the box or do I need to setup a dt-blob to enable that as you said?

Thanks

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4733
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 I²C0 and I²C1 connections

Fri Jan 01, 2021 3:28 pm

The dt-blob change I mention in your quote hasn't made it into a released firmware yet, so HAT support doesn't yet work without a custom dt-blob.bin file.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4733
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 I²C0 and I²C1 connections

Mon Jan 04, 2021 2:31 pm

The latest rpi-update firmware has HAT support enabled on CM4. The bundle includes a 5.10 kernel, but if you just want the new firmware you can use "sudo SKIP_KERNEL=1 rpi-update".

Note that, like all pre-release kernels and firmwares, there is a degree of risk associated with an update, but I'm running the 2a52dbc9 release ("sudo SKIP_KERNEL=1 rpi-update 2a52dbc9") on a CM4, and it's detected a HAT and is so far behaving itself.

Red Sun
Posts: 19
Joined: Sun Jan 03, 2021 2:15 pm

Re: CM4 I²C0 and I²C1 connections

Thu Jan 07, 2021 1:51 pm

Hi,
I have not posted before, so if I am butting into the wrong discussion, I apologise.
I am designing a motherboard like the CM4 IO board and looking at the SDA0 and SCL0 going into both a camera connector and a display connector on the CM4IO schematic. If a camera and display were fitted simultaneously could appropriate software make them both work ok?
There is another question after this..

msl
Posts: 190
Joined: Tue Jul 07, 2020 9:12 pm
Location: Munich

Re: CM4 I²C0 and I²C1 connections

Thu Jan 07, 2021 6:08 pm

Red Sun wrote:
Thu Jan 07, 2021 1:51 pm
Hi,
I have not posted before, so if I am butting into the wrong discussion, I apologise.
I am designing a motherboard like the CM4 IO board and looking at the SDA0 and SCL0 going into both a camera connector and a display connector on the CM4IO schematic. If a camera and display were fitted simultaneously could appropriate software make them both work ok?
There is another question after this..
Devices on i2c bus must have different addresses to work without conflict. Official display and camera work on the same i2c bus without problems

Red Sun
Posts: 19
Joined: Sun Jan 03, 2021 2:15 pm

Re: CM4 I²C0 and I²C1 connections

Thu Jan 07, 2021 8:24 pm

Brilliant, I wasn't sure it was a proper I2C bus.
Next question: Can I put 2 official displays on Disp0 and Disp1, and/or 2 identical cameras on Cam0 and Cam1 using the same I2C bus? In other words, is there a means of setting different addresses on these identical devices?

msl
Posts: 190
Joined: Tue Jul 07, 2020 9:12 pm
Location: Munich

Re: CM4 I²C0 and I²C1 connections

Thu Jan 07, 2021 8:46 pm

Red Sun wrote:
Thu Jan 07, 2021 8:24 pm
Brilliant, I wasn't sure it was a proper I2C bus.
Next question: Can I put 2 official displays on Disp0 and Disp1, and/or 2 identical cameras on Cam0 and Cam1 using the same I2C bus? In other words, is there a means of setting different addresses on these identical devices?
Take a look at CM4 CMIO board. CAM0/DISP0 uses one i2c bus, CAM1/DISP1 - another. So there is no conflict on a bus.
Also you’ll need custom dt-blob for this.
https://github.com/raspberrypi/document ... putemodule
https://www.raspberrypi.org/documentati ... -camera.md
https://www.raspberrypi.org/documentati ... display.md

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

Re: CM4 I²C0 and I²C1 connections

Thu Jan 07, 2021 9:30 pm

msl wrote:
Thu Jan 07, 2021 8:46 pm
Red Sun wrote:
Thu Jan 07, 2021 8:24 pm
Brilliant, I wasn't sure it was a proper I2C bus.
Next question: Can I put 2 official displays on Disp0 and Disp1, and/or 2 identical cameras on Cam0 and Cam1 using the same I2C bus? In other words, is there a means of setting different addresses on these identical devices?
Take a look at CM4 CMIO board. CAM0/DISP0 uses one i2c bus, CAM1/DISP1 - another. So there is no conflict on a bus.
Also you’ll need custom dt-blob for this.
https://github.com/raspberrypi/document ... putemodule
https://www.raspberrypi.org/documentati ... -camera.md
https://www.raspberrypi.org/documentati ... display.md
The firmware will only drive a single dsi display.
I've just collected a second dsi display to sort getting the vc4-kms-v3d driver to drive 2 dsi displays at a time.

As above you can not have the arm and firmware sharing a single i2c controller, and that is the parent controller (bsc0) which is used by default to drive both gpios 0ð1 and 44&45.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Red Sun
Posts: 19
Joined: Sun Jan 03, 2021 2:15 pm

Re: CM4 I²C0 and I²C1 connections

Sat Jan 09, 2021 11:25 am

Thanks for your reply 6by9. You work late!

You have prompted me to dive in and find out what BSC0 (etc.)is, and what all of the alternate pin functions are, plus what function they have actually been assigned.

I can understand why Kahlenberg had a problem on Dec 16th, because I am having the same problem.

Despite what Engineer PhilE says: All of the IDC header pins on the CM4IO board have the functions as on a regular Pi. This includes I2C0 being connected to pins 27 & 28, also known as ID_SD and ID_SC. - it does not appear to be true.

Schematic "High Speed" shows that, in fact, I2C1 (SDA1 and SCL1)is connected to ID_SD and ID_SC which are connected to pins 27 & 28. (Header J6 below).
ID_SC assignment.JPG
ID_SC assignment.JPG (28.92 KiB) Viewed 4688 times
There is another problem:
Looking at CM4 GPIO (see below) we can see that I2C1 does not come from GPIO2 and GPIO3 (pins 58 and 56) anymore.
CM4 GPIO.JPG
CM4 GPIO.JPG (81.59 KiB) Viewed 4688 times
Looking at the Alternate Function chart on the ARM peripherals datasheet we find that the only other possibility for I2C1 (SDI1 and SCL1) is GPIO44 and GPIO45 so I am guessing that pins 35 and 36 are GPIO44 and GPIO45.
However looking at the pin assignments on P16 of the CM4 datasheet we can see that the pins (80 and 82) have been assigned to I2C0. (see below).
CM4 pin assignment.JPG
CM4 pin assignment.JPG (64.42 KiB) Viewed 4688 times

I guess the datasheet has an error...(?)

dp11
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1002
Joined: Thu Dec 29, 2011 5:46 pm

Re: CM4 I²C0 and I²C1 connections

Sat Jan 09, 2021 12:06 pm

SCL1 SDA1 on the cm4IO board are just net labels they do not refer to the BCM2711 I2c controllers.

Red Sun
Posts: 19
Joined: Sun Jan 03, 2021 2:15 pm

Re: CM4 I²C0 and I²C1 connections

Sat Jan 09, 2021 12:42 pm

OK.
Even so, BSC1 does not come out of GPIO 2 and GPIO 3 as you can see from the GPIO picture. It has to come from GPIO44 and GPIO45 doesn't it?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4733
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 I²C0 and I²C1 connections

Sat Jan 09, 2021 1:02 pm

From the diagram above, GPIO2 is on pin 58 and GPIO2 is on pin 56. Where I2C1/BSC1 appears is under software control, but the default is GPIOs 2&3.

Red Sun
Posts: 19
Joined: Sun Jan 03, 2021 2:15 pm

Re: CM4 I²C0 and I²C1 connections

Sat Jan 09, 2021 3:13 pm

All very well, but if you are on GPIO 2 and GPIO3 you will connect BSC1 to the GPIO header in the right location, but you will not connect to the camera or displays. I am assuming the board was made from this schematic, of course. Maybe you connect to one, do your software stuff then connect to the other. That does not seem likely, though.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4733
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 I²C0 and I²C1 connections

Sat Jan 09, 2021 5:36 pm

BSC0 = camera and displays, BSC1 = other stuff. What's the problem?

Red Sun
Posts: 19
Joined: Sun Jan 03, 2021 2:15 pm

Re: CM4 I²C0 and I²C1 connections

Sun Jan 10, 2021 3:43 pm

Hi PhilE

-problem is that I am designing a board based on this and I need to know what the connections are, and how they work...
Please don't talk to me about dt blobs or I will have to go and see my analyst.

I think I know how this works. (!)

If we start up normally, then
BSC0 feeds through GPIO0 and GPIO1 using the ALT0 Function and supplies ID_SD and ID_SC to pins 27 & 28 on the GPIO header.
BSC1 feeds through GPIO2 and GPIO3 using the ALT0 Function and supplies SDA1 and SCL1 to pins 3 & 5 on the GPIO header.
This is the standard format for all Raspberry Pi headers.

If we don't have an eeprom then we can put in jumpers at J6 and connect BSC0 to the primary display and camera connectors which have 2 MIPI lanes like the ones on the Pi 4B. The net label is confusingly (and probably accidentally) labelled as if it was connected to BSC1 but this does not affect the electrical function. The connectors are 22 way rather than the 15 way on the Pi 4B. Slight change - the connectors are now fed from CAM0 and DSI0 rather than CAM1 and DSI1 as on the Pi4B.

If we want to fire up CAM1 and DSI1, which have 4 MIPI lanes each then we need to use BSC 1 so we take it off GPIO 2 & 3 by removing the ALT function and put it on GPIO 44 & 45 using the ALT2 function. This will take BSC1 (SDA1 and SCL1) off the GPIO header and feed it to CAM1 and DSI1 instead. GPIO2 and GPIO3 will still, of course, be connected to the header.

Ok?

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

Re: CM4 I²C0 and I²C1 connections

Sun Jan 10, 2021 4:34 pm

Red Sun wrote:
Sun Jan 10, 2021 3:43 pm
If we start up normally, then
BSC0 feeds through GPIO0 and GPIO1 using the ALT0 Function and supplies ID_SD and ID_SC to pins 27 & 28 on the GPIO header.
BSC1 feeds through GPIO2 and GPIO3 using the ALT0 Function and supplies SDA1 and SCL1 to pins 3 & 5 on the GPIO header.
This is the standard format for all Raspberry Pi headers.
Correct
Red Sun wrote:If we don't have an eeprom then we can put in jumpers at J6 and connect BSC0 to the primary display and camera connectors which have 2 MIPI lanes like the ones on the Pi 4B. The net label is confusingly (and probably accidentally) labelled as if it was connected to BSC1 but this does not affect the electrical function. The connectors are 22 way rather than the 15 way on the Pi 4B. Slight change - the connectors are now fed from CAM0 and DSI0 rather than CAM1 and DSI1 as on the Pi4B.
CAM0 and DISP0 are considered the SECONDARY camera and display connectors.
Signal names from the CM4 are ID_SD and ID_SC. See section 2.10 of https://datasheets.raspberrypi.org/cm4/ ... asheet.pdf
Yes they get given slightly confusing net names of SDA1 and SCL1 after the jumpers of J6 - c'est la vie.
Red Sun wrote:If we want to fire up CAM1 and DSI1, which have 4 MIPI lanes each then we need to use BSC 1 so we take it off GPIO 2 & 3 by removing the ALT function and put it on GPIO 44 & 45 using the ALT2 function. This will take BSC1 (SDA1 and SCL1) off the GPIO header and feed it to CAM1 and DSI1 instead. GPIO2 and GPIO3 will still, of course, be connected to the header.
CAM1 and DISP1 are considered as the primary display connectors as they are the interfaces used on the other Pi variants (see the docs - cam and display).

The normal configuration for these connectors is to use BSC0 and pin muxing option ALT1 on GPIOs 44&45. The software will dynamically switch BSC0 between the two sets of GPIOS (0&1 or 44&45) depending on which device is to be used.
CM4 signal names SDA0 and SCL0. See section 2.9 of https://datasheets.raspberrypi.org/cm4/ ... asheet.pdf
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4733
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 I²C0 and I²C1 connections

Sun Jan 10, 2021 5:24 pm

I would have given you a less thorough version of 6by9's answer.

Return to “Compute Module”