cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to send and receive data on I2C ports

DmnSd
Associate III

Hi,

I'm trying to send and receive data over an I2C port.

Working with STM32MP15 ecosystem release v2.0.0 (concrete STM32MP157F-EV1 and openstlinux 5.4 dunfell) and i2c-tools.

I want to access I2C2 on MB1262C IO EXPANSION connector CN21.

Following this post I have done this steps:

root@stm32mp1:~# i2cdetect -l
i2c-1   i2c             STM32F7 I2C(0x40015000)                 I2C adapter
i2c-2   i2c             STM32F7 I2C(0x5c002000)                 I2C adapter
i2c-0   i2c             STM32F7 I2C(0x40013000)                 I2C adapter
root@stm32mp1:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
40: -- -- UU -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@stm32mp1:~# 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@stm32mp1:~# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@stm32mp1:~#

My I2C slave has the address 0x77 and normally I can read some data from register 0xD0.

But I can't see this in the output above?

So I tried to manually access the I2C slave:

root@stm32mp1:~# i2cget -f -y 0 0x77 0xd0
Error: Read failed
root@stm32mp1:~# i2cget -f -y 1 0x77 0xd0
Error: Read failed
root@stm32mp1:~# i2cget -f -y 2 0x77 0xd0
Error: Read failed

What am I doing wrong?

I'm not able to measure any data on the pins on CN21 with my oscilloscope. Seems that no data is sent to any I2C port?

Thanks for help.

Kind regards,

Dmn

6 REPLIES 6
Olivier GALLIEN
ST Employee

Hi @DmnSd​ ,

Did you already refer to I2C related wiki pages:

https://wiki.st.com/stm32mpu/wiki/I2C_overview

https://wiki.st.com/stm32mpu/wiki/I2C_device_tree_configuration

Any hint / help there ?

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
KnarfB
Principal III

Is i2c2 enabled in the device tree?

Dear @Community member​ ,

dear @KnarfB​ ,

thanks for your answers.

I read through the links mentioned above:

Linux kernel is configured correct.

CONFIG_I2C=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_STM32F7=y
CONFIG_I2C_SMBUS=y

Kernel uses the default device tree "stm32mp157f-ev1.dtb" in which i2c is configured correctly, isn't it?

I also have written a user space C application to access i2c -> no success.

I will dig a little bit deeper in device tree file.

But as I asked before: Device tree should be correct?

Kind regards,

Dmn

Hi @DmnSd​ 

IP available on expansion connector are possibly not enabled by default.

Better to have a check.

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
DmnSd
Associate III

Hi @Community member​ ,

hi @KnarfB​ ,

I modified device tree as follows:

I want to access I2C2 on MB1262C on GPIO expansion CN21.

As the schematics show I2C2 is on pin PH4 and PH5.

Device tree says I2C2 is at 0x40013000.

i2c2: i2c@40013000 {

So I modified device tree file stm32mp157f-ev1.dts:

diff --git a/arch/arm/boot/dts/stm32mp157f-ev1.dts b/arch/arm/boot/dts/stm32mp157f-ev1.dts
index 0c18333c0..e8e9fc390 100644
--- a/arch/arm/boot/dts/stm32mp157f-ev1.dts
+++ b/arch/arm/boot/dts/stm32mp157f-ev1.dts
@@ -65,17 +65,16 @@
 };
 
 &i2c2 {
-       gt9147: goodix_ts@5d {
-               compatible = "goodix,gt9147";
-               reg = <0x5d>;
-               panel = <&panel_dsi>;
-               pinctrl-0 = <&goodix_pins>;
-               pinctrl-names = "default";
-               status = "okay";
-
-               interrupts = <14 IRQ_TYPE_EDGE_RISING>;
-               interrupt-parent = <&stmfx_pinctrl>;
-       };
+       pinctrl-names = "default", "sleep";
+       pinctrl-0 = <&i2c2_pins_a>;
+       pinctrl-1 = <&i2c2_pins_sleep_a>;
+       i2c-scl-rising-time-ns = <185>;
+       i2c-scl-falling-time-ns = <20>;
+       st,smbus-alert;
+       st,smbus-host-notify;
+       status = "okay";
+       /delete-property/dmas;
+       /delete-property/dma-names;
 };
 
 &m_can1 {

From stm32mp15-pinctrl.dtsi I get this pins for I2C2:

i2c2_pins_a: i2c2-0 {
	pins {
		pinmux = <STM32_PINMUX('H', 4, AF4)>, /* I2C2_SCL */
			 <STM32_PINMUX('H', 5, AF4)>; /* I2C2_SDA */
		bias-disable;
		drive-open-drain;
		slew-rate = <0>;
	};
};
 
i2c2_pins_sleep_a: i2c2-1 {
	pins {
		pinmux = <STM32_PINMUX('H', 4, ANALOG)>, /* I2C2_SCL */
			 <STM32_PINMUX('H', 5, ANALOG)>; /* I2C2_SDA */
	};
};

So I think the pins are configured correct?

After compiling and flashing the pins 27 and 28 on CN21 are now high in idle. As I expected.

But reading from a I2C slave show the same error anyway and there is no data on my oscilloscope:

root@stm32mp1:~# i2cdetect -l
i2c-1	i2c       	STM32F7 I2C(0x40015000)         	I2C adapter
i2c-2	i2c       	STM32F7 I2C(0x5c002000)         	I2C adapter
i2c-0	i2c       	STM32F7 I2C(0x40013000)         	I2C adapter
root@stm32mp1:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- UU -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- 
40: -- -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- 5d -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@stm32mp1:~# i2cget -f -y 0 0x77 0xd0
Error: Read failed
root@stm32mp1:~# i2cget -f -y 0 0x77 0xd0
Error: Read failed

Any idea how I can configure the GPIO expansion correct?

Dmn

shane mattner
Senior

Using Buildroot I added this to the DTS file to make the I2C work for the DK2:

&i2c5 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&i2c5_pins_a>;
};

Your configuration is much more complex. Perhaps try this simple configuration and see if that works.