1 2 Previous Next 22 Replies Latest reply on Apr 18, 2016 7:51 AM by Intel Corporation

    I²C bus freezes randomly



      I'm having strange issues with I²C freezing after a random period of time (on the scale of perhaps half a minute to five or ten minutes generally). I'm trying to communicate with an MPU9250 breakout board (with a level converter in-between) on I2C-6 using libmraa. For the record I've tried it with a different breakout board with an MPU6050 and had the same issue (or at least the same symptoms).


      Looking at SDA and SCL with an oscilloscope it all looks good until it freezes, at which point SDA gets stuck low and SCL high. What's interesting is that if I short SDA to VCC it gets kickstarted into working again, until the next freeze minutes later. My assumption is that one or the other doesn't ACK properly or misses an edge and it gets into a sort of catch-22 with the Edison waiting for SDA to become high and the MPU9250 for SCL to become low, which is why forcing SDA high kicks it all back into action... I'm very far removed from anything like an expert on serial communications so this is pure speculation.


      I would appreciate any input from someone more experienced with I²C or the MPU9250 that can help or even give hints about how to troubleshoot the issue. Thanks!

        • 1. Re: I²C bus freezes randomly

          Hey nemrod

          Curious if this is the same issue we have been having in this thread with SPI MRAA SPI - kernel panic when writing buffers at >25KHz

          Can you try something...

          Connect to the terminal and look at the process list via the TOP or PS command. Locate your running application(im not sure if you are using an Arduino sketch, c, or Node) Once located keep an eye on it....When you notice the i2c buss die, check if the process has been put in D (dead zombie) mode....

          • 2. Re: I²C bus freezes randomly

            Hey LeonY, thanks for the reply!

            I checked the process status and you're right; under normal circumstances it switches between S and D (and presumably R) but after a freeze it appears to be stuck at D. After my shorting 'fix' it resumes normal operation. This can be in line with my previous assumption about a signal catch-22 where the Edison gets stuck waiting for a specific signal and not getting it (hence D---waiting for I/O), but since it's affecting you and others with other devices and even a different protocol, it could as well be an underlying issue with the Edison hardware/software that bugs it out or makes it miss the signal it's waiting for... Tricky. :/


            According to the linked thread it seems to work up to about 25kHz; it would be interesting to see if this solves my issue as well to verify if it's really the same thing happening. Do you know of a way to set the I²C speed lower than what's provided by libmraa (MRAA_I2C_STD, 100kHz)?


            PS. I use C++ but if I recall correctly the issue occured with C as well.

            • 3. Re: I²C bus freezes randomly

              hey nemrod

              this is bad!

              have a look at the C++ reference for mraa http://iotdk.intel.com/docs/master/mraa/classmraa_1_1_i2c.html

              The Method

              mraa_result_tfrequency (mraa_i2c_mode_t mode)

              Allows you to change the frequency, try it at 20khz and see if this stops....

              I would really like to know if these 2 issues are related.

              FYI according to intel, the Edison "simulates" i2c and SPI via software

              PS. I use C++ but if I recall correctly the issue occured with C as well.

              If this is the same problem, then it doesn't matter what language you are using, its a kernel driver problem. I have tested the SPI issue with an Arduino Sketch, C++, Node and Python and verified the same issue on all languages, even when NOT using mraa.

              • 4. Re: I²C bus freezes randomly

                LeonY, unfortunately that function takes an enum for an argument, and the enum only lists from 100kHz and up: mraa: /var/lib/jenkins/workspace/mraa-doc/api/mraa/types.h File Reference


                typedef enum {
                    MRAA_I2C_STD = 0,
                    MRAA_I2C_FAST = 1,
                    MRAA_I2C_HIGH = 2
                } mraa_i2c_mode_t;
                • 5. Re: I²C bus freezes randomly

                  oh i see....sorry I'm out of ideas then.

                  • 6. Re: I²C bus freezes randomly

                    I reseached some more and ended up at /sys/bus/i2c/devices/i2c-6/device/i2c_dw_sysnode/mode, but it only takes std, fast and high, so it seems the preset speeds are implemented at quite a low level. Do we have any Intel engineers that can comment on if it's possible to set more specific I²C speeds?

                    • 7. Re: I²C bus freezes randomly

                      Hey nemrod if you want to try something drastic, downgrade your Edison to the previous V2 release.

                      I flash the previous version today and it resolved the issue i had with SPI. It may resolve your issue as well..

                      • 8. Re: I²C bus freezes randomly

                        LeonY, I'll try doing that once I'm done with some other things, I hope it'll work. Meanwhile, I measured the actual frequency with an oscilloscope and STD is indeed 100kHz as the doc states, FAST is somewhere between 300 and 400kHz and subjectively seems to freeze quicker, and HIGH doesn't work at all.

                        • 9. Re: I²C bus freezes randomly

                          I flashed release 2.0 from IoT - Intel® Edison Board Download | Intel® Developer Zone but things seem broken and APIs outdated, can't get anything to compile and/or link... Sigh

                          • 10. Re: I²C bus freezes randomly

                            Managed to get the code running on 2.0 by updating mraa; but unfortunately the issue persists. LeonY, did you also update mraa? If not, that could be the difference (and where the real issue is, instead of or in combination with the Yocto release). If yes, then our issues may be different (though they could still be related).


                            Still hoping someone can chime in with information about limiting the I²C bus speed or any other information related to this issue!


                            edit: upon further testing it doesn't seem to freeze; maybe that first time was some sort of anomaly or caused by something else, because it's been running for over 10 minutes now without a freeze. Seems to me that there's been a bug/regression introduced with 2.1! I hope it stays stable, if it freezes again I'll report back.

                            • 11. Re: I²C bus freezes randomly

                              Hey mate

                              Our issue relating to spi is 100% not mraa and has been confirmed by intel to be the kernel drivers.

                              • 12. Re: I²C bus freezes randomly

                                LeonY, yeah, that makes sense since it seems to work now, even with the latest mraa. But since it works in 2.0 can't we just look at the changes made in the relevant kernel drivers between 2.0 and 2.1 to find the regression? Are they open source?

                                • 13. Re: I²C bus freezes randomly

                                  Have a look at my previous post, It seems that Intel is not too fussed that their latest software release completely crippled the Edisons io

                                  • 14. Re: I²C bus freezes randomly

                                    Indeed LeonY, but if the drivers are open source we can potentially identify and correct the issue ourselves and submit a patch to mainline. There are source packages downloadable on the downloads page (IoT - Intel® Edison Board Download | Intel® Developer Zone), but whether they include the relevant parts I don't know. Unfortunately I don't have the time to spend at the moment considering it's working on 2.0, but it's something worth looking into.

                                    1 2 Previous Next