2 Replies Latest reply on Nov 10, 2014 3:08 PM by CMata_Intel

    GPIO Mapping for GEN2?

    SpiderKenny

      I cannot find any documentation on GPIO mapping for the GNE2 board.

      Specifically, if I want to switch the I2C lines through to the headers.

      To do that I need to drive the AMUX1_IN line, in order to switch the MUX from 0 to 1, thus switching the I2C lines through to the header.

       

      The schamtic shows that AMUX1_IN comes from U2/EXP2 on page 20.

       

      But I cannot find any data that shows how to map the I/O lines from "EXP2" to GPIO numbers as required by the linux file system at :

      /sys/class/gpio/export

       

      For the GEN1 board there is an IO Mapping document, but it was last updated in February so does not cover GEN2.

      Anyone got any documentation on GEN2 IO Mapping?

        • 1. Re: GPIO Mapping for GEN2?
          SpiderKenny

          I think I may have figured this out...

          In linux, at the file system level the GPIO controls are at  /sys/class/gpio

          There you will find several directories named:

          gpiochip0

          gpiochip2,

          gpiochip8,

          gpiochip16,

          gpiochip32,

          gpiochip48

          and gpiochip64

           

          Each directory corresponds to a driver for a physical chip on the Galileo GEN2 Board.

          The numerical suffix is the indexed number of the first GPIO that it controls. This allows us to use the schematic to work out the GPIO number for any given output on any given chip.

          If you look at sheet 20 of the schematic you'll see that there are three chips named "EXP0" "EXP1" and "EXP2" - these correspond to gpiochip16, gpiochip32 and gpiochip48 respectively.

          So in my case since AMUX1_IN is on the 13th I/O of the third chip, that would make if GPIO60 (48 + 13 -1) (minus one because the 1st I/O is on 48, 2nd on 49 and so on).

           

          So now I know the GPIO number, I echo it's number to /sys/class/gpio/export like this:

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

           

          And this gives me access to it from the filesystem. A new folder will appear:

          /sys/class/gpio/gpio60

           

          Now I can set the driver strength, direction and value of the GPIO line like this:

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

          echo -n "strong" >/sys/class/gpio/gpio60/drive

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

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

           

          And when we are finished with it, unexport it by doing this:

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

           

          So you need to look at the schematic on page 20, then work out the index of the GPIO you want to control, and then figure out what it's GPIO number is.

          I will knock up a spreadsheet with the details to save some time.

           

          HOWEVER -  and this is a real bummer!

          When I was playing with this, I started to get a timeout on the writes. Looks like there is bug in the hardware driver which stops the GPIO working after a while.

          This is a known issue, it is in the release notes, and it's a problem. See section 1.9.7 of the release notes. The only fix is to completely power down the board and start again.

          • 2. Re: GPIO Mapping for GEN2?
            CMata_Intel

            Hi SpideKenny;

             

            Take a look at this link, I think you’re going to find some useful information there. And yes, that issue is in the release notes so by the meantime there is only a workaround for that, and hopefully in the future we have a complete fix.

             

            Regards.

            CMata

            1 of 1 people found this helpful