I have tried communication between RPi3 and stm32 over I2C. First of all I have installed i2c-tools and python-smbus. All in All I have used python script on the RPI as below:
import smbus
bus = smbus.SMBus(1)
address = 0x0A
data = [1,2,3,4,5,6,7,8]
bus.write_i2c_block_data(address, 0, data)
When I run script, I can see following error:
IOError: [Errno 121] Remote I/O error
STM32 is configured as I2C slave, both device are connected correctly(SDA, SCL and GND). How do I know that? I have made program using BCM2835 library. C program worked correctly. C program sent buffer without any errors. STM32 also received buffer without any errors. Can you tell me, what I have been doing wrong?
Thank you in advance.
I ran into the same problem. I figured out that error code 121 is stated when none of the slaves ACKs the command send by the Master. This happens if you are trying to contact a not used address or the command is not what the slaves expect.
In my case I tried to send a reset command to a TLC59116. These ICs expect the command "0xA5 0x5A" on address 0x6B.
So I tried to send with a similar snippet like yours:
import smbus
bus = smbus.SMBus(0)
address = 0x6B
data = [0xA5,0x5A]
bus.write_i2c_block_data(address, 0, data)
But in raw communication this command leads to a Msg [0x00 0xA5 0x5A], with leading start registeraddress, which these ICs did not allow and answer correct with NACK -> Error 121.
O.T.: I solved my problem by sending
bus.write_byte_data(address,0xA5,0x5A)