Dear community, I'm almost at my wit's end and would be so happy to receive help. It would be a great Christmas present to me if some of you take the time to read and provide inquiry, knowledge or even a solution. I tried to structure it as neatly as possible. Happy about any help!
I'll update the information to my problem if I missed something or upon your request.
I'm using a Simulink model created with MatLab 2017b.
It's being transferred to and built on a Raspberry Pi 3B running Raspbian Buster
via SSH wirelessly over local network.
The second to fourth and otherwise identical setups are running Raspbian Jessie.
Connected to the RasPi are two circuit boards using TWI / I2C protocol. One controls two motors and the voltage (from a battery pack) for the RasPi and the other board. This second one provides data from two light sensors.
(The boards are controlled by an STM32 microcontroller, the firmware for which was written by a colleague.)
The whole setup (using Jessie) was working just fine. Some random day it stopped working.
At first it just hung-up presumably when there was more data transfer than possible with the set bus frequency.
Then it stopped seconds after begin of successful transmission.
Now it doesn't respond whatsoever. The Simulink model still builds but there's no action happening.
Edit: using another fresh OS-build I got it to work for now.
Using MatLab's Log signal data and reading from the log tells me:
EXT_I2C_write/write: Remote I/O error
Trying to debug using some python code with the smbus package gives the folloving error message:
Traceback (most recent call last): File "Downloads/read_sensor.py", line 14, in <module> value1 = read_line_value(i2cbus,i2caddress,0x01) File "Downloads/read_sensor.py", line 6, in read_line_value return bus.read_word_data(dev, addr) IOError: [Errno 121] Remote I/O error
(As the script doesn't contain a lot more than what's seen in the error message, I didn't include it here.
i2caddress are simply storing address values.)
Falling back to linux command line:
i2cdetect is working just fine, showing devices (on 0x11 and 0x19)
i2cset seemed to work (or at least didn't output an error message).
Error: Read failed
Steps I tried:
- setting up the whole system from zero
- reinstalling RaspbianOS (updated to Buster) + packages necessary for MatLab = MathWorks' Raspbian version 1
- configuring network and the like, enabling i2c
- taking a first look at it with an oscilloscope. Not being used to using that I can, as of now, only tell:
i2cdetectshows a signal - this behaviour matches with the successful result
i2cgetdon't seem to cause a signal, but it appears to cause a short lag / delay in the signal
Edit: Checking up on the firmware implementation...
I found a couple somewhat similar questions/threads but nothing that helped me. Some of these include:
- problems with the wiring
- as I have four setups all showing similar problems I don't think that's the reason. Also it doesn't explain why some commands should work while others don't
- though I don't quite understand / nowhere read how that's supposed to cause the problem
- Edit: using another OS-build I got it to work for now and checked the cables and sensor-boards one by one. All are working. So there's no general problem with the hardware.
- in another seemingly similar case  it's recommended to activate the repeated start condition
- summary: create file
options i2c_bcm2708 combined=1to it
- I tried that, rebooted, does not work in my case, i2cdump still shows XX everywhere, so I removed it again.
- indicating to use this option is a missing STOP signal. I'll check for that with the oscilloscope soon.
- I'm not too fond of specifying some option I don't understand* and don't know how it interacts with other configurations, especially when "simply creating file XY" in some directory*, without afore mentioned knowledge... So if someone has detailed information or links for further reading regarding how the different config-files in different directories interact, I'd be happy about that, too. (* see links [2a-c])
- summary: create file
Generally I didn't come across a lot of posts explaining exactly why and how the proposed method causes the failure or interacts with other configurations etc.