Skip to main content
DmnSd
Associate III
November 17, 2020
Question

Not able to send and receive data on I2C ports

  • November 17, 2020
  • 3 replies
  • 1869 views

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

This topic has been closed for replies.

3 replies

Olivier GALLIEN
Technical Moderator
November 17, 2020

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
Super User
November 17, 2020

Is i2c2 enabled in the device tree?

DmnSd
DmnSdAuthor
Associate III
November 17, 2020

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

Olivier GALLIEN
Technical Moderator
November 17, 2020

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.
shane mattner
Senior
November 25, 2020

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.