9 Replies Latest reply on Jan 2, 2015 1:04 AM by firmwarengineer

    GPIO access from linux can crash the GEN2

    SpiderKenny

      I've found the hard way that using GPIO from the linux command line (or from a script, or C program) can crash the GPIO driver, requiring a complete cold reboot.

      This simple script should toggle the MUX for extending the I2C Bus out to the SDA and SCL pins on the header:

       

      echo -n "60" >/sys/class/gpio/export

      echo -n "out" >/sys/class/gpio/gpio60/direction

      echo -n "1" >/sys/class/gpio/gpio60/value

      sleep 2

      echo -n "0" >/sys/class/gpio/gpio60/value

      sleep 2

      echo -n "60" >/sys/class/gpio/unexport

       

      However it causes the I2C to lock up after the direction of GPIO60 is changed to "out".

      (The I2C is used for all GPIO on the Gen 2 Galileo.)

       

      The console said this, during the running of that script:

      [  293.589431] pca953x 0-0027: failed writing register

      [  295.610407] intel_qrk_gip 0000:00:15.2: i2c_dw_handle_tx_abort: lost arbitration

      [  295.617921] pca953x 0-0027: failed writing register

      [  298.630123] intel_qrk_gip 0000:00:15.2: controller timed out

      [  298.635899] pca953x 0-0027: failed writing register

      [  301.650124] intel_qrk_gip 0000:00:15.2: controller timed out

      [  301.655899] pca953x 0-0027: failed writing register

       

      I believe this is the same issue as is described in the release notes, section 1.9.7, but it's quite an issue if we can't use I2C from Linux.

       

      Unless of course I am doing something silly here, but I'm pretty certain that GPIO60 is the correct GPIO for the MUX to take SDA and SCL to the arduino pin-headers.

      What I suspect is happening is that there is a bug in the pca953x driver.

        • 1. Re: GPIO access from linux can crash the GEN2
          SpiderKenny

          Just a quick follow up....

          The hang-up only seems to happen if there is any kind of corruption on the SDA line - anything which gives a "NACK".

          We can work around this by ensuring we don't get NACKs on the SDA line, but surely the driver should be resilient enough to recover from a NACK on a particular I2C device?

          • 2. Re: GPIO access from linux can crash the GEN2
            Intel_Alvarado

            Hi,

            We will investigate on your issue and contact you as soon as we have more information.

            Regards

            Sergio

            • 3. Re: GPIO access from linux can crash the GEN2
              Intel_Peter

              Hello SpiderKenny,

               

              I checked the code you posted above and I think I found what's causing you problems, or at least some info that can actually be of help. If you check this link you will find a table that explains the mapping for the Gen2 MUX, according to it you should select the value for gpio60 on LOW instead of HIGH and there's no need of unexporting it. You can check the link above there's a lot of info you can find of help there.

               

              Regards,

                          Peter

              • 4. Re: GPIO access from linux can crash the GEN2
                SpiderKenny

                I too checked the information at that link and find that it is in error.

                Looking at the schematic, on page 24 of 28, it's clear that to extend SCA and SCL to the Arduino header, GPIO60 (AMUXIN_1) has to be high.

                 

                What is also clear from my testing is that anything which causes data corruption on the SDA line, even briefly, renders the entire I2C system unusable until a cold-reboot.

                I can understand that data corruption, say from shield which is slow to start up, or which is not initialized until some command is sent to it, could cause temporary faults on I2C, but then the system should recover from that once the fault condition is removed.

                 

                Also, I know there is no need to un-export the GPIO, but it is cleaner to do so, and the errors occur before then anyway!

                 

                **EDIT**
                Sorry, my mistake - I checked the datasheet for TS5A23159 chip and found that you are correct, no need to drive the GPIO high, just LOW.

                The rest still applies though!

                • 5. Re: GPIO access from linux can crash the GEN2
                  SpiderKenny

                  What I have here is an experimental audio processor board. (See picture below of it sitting on top of Galileo GEN2).

                  It has 4 channels of Audio input (2 x Stereo Phone, 2 x Stereo 3.5mm Jack), and 1 x Stereo 20+20W Class D Amp speaker output.

                  It has an OLED Display, Serial TX/RX at true RS232 level, separate RS485, and a DAB Radio header for a Venice-9 Module.

                  It works really well (despite the wrong PCB footprint for the TDA7440D, which I had to hand-solder with enamel wire).

                   

                  However it is still in development, and occasionally I send a wrong command on I2C, or I short the SDA line with my oscilloscope probe, or when attaching/removing the logic analyzer.

                  It's a pain that when this happens I have to cold-reboot the Galileo! That makes for a long day :-)

                   

                  I also have an experimental FPGA board, which is a proof of concept, running quadrature encoders, IR Receivers, One wire temperature and humidity sensors, 1-Wire iButtons and an OLED display all in hardware, just to show what can be done with a low cost FPGA on top of Galileo.

                   

                  I am a great fan of Galileo, GEN1 and GEN2 and am using them in my work towards my Masters Degree, as well as my day job.

                   

                  Thanks for everything, the support here is great!

                   

                  Screen Shot 2014-11-12 at 10.07.43.png

                  • 6. Re: GPIO access from linux can crash the GEN2
                    Intel_Peter

                    Hello SpiderKenny,

                     

                    I think you're right, what's happening to you is the known issue you pointed out, and the only workaround is to cold reset the board. The only solution is to wait until it get fixed on a future software release but there's no ATA for it.

                     

                    Regards,

                                Peter

                    • 7. Re: GPIO access from linux can crash the GEN2
                      SpiderKenny

                      I think you're right, what's happening to you is the known issue you pointed out, and the only workaround is to cold reset the board. The only solution is to wait until it get fixed on a future software release but there's no ATA for it.


                      That's no big deal, it's a small price to pay!

                      I still like the Galileo board a great deal.


                      Also, thanks for your time looking at this.


                      • 8. Re: GPIO access from linux can crash the GEN2
                        Intel_Peter

                        Hello SpiderKenny,

                         

                        I'm sorry I don't have a better answer for you, but I'm happy I helped. As always if you have any other doubts, don't hesitate to ask.

                         

                         

                        Regards,

                                    Peter

                        • 9. Re: GPIO access from linux can crash the GEN2
                          firmwarengineer

                          Well I really cannot accept the cold reset method.

                          It shouldn't be this way. Any error should be able to recover unless it is a hardware error.