5 Replies Latest reply on May 15, 2014 11:22 AM by SpiderKenny

    How do I set GPIO in the Development Kit for IoT image?

    Giles_Bradshaw

      I can't get pin 13 to light an LED - I know it works because i tried it with no SD card and blink

       

      however I cannot control it either with galileo-io ( a node package)  or using sysfs as per Intel Galileo - Programming GPIO From Linux - Malinov Family Web Presence

       

       

      This is with the 200MB linux image downloaded from 

       

      IoT Developer Kit

        • 1. Re: How do I set GPIO in the Development Kit for IoT image?
          SpiderKenny

          The GPIO numbers exported in Linux are not the same as the GPIO used in Arduino.

          So 'Pin 13' does not work the LED near the battery connector.

           

          That LED (Labeled GP) is connected to the Quark GPI_SUS1_STATUS_LED pin, which as far as I can see is not exported from the gpio driver under linux.

          Check out the GPIO Mapping Reference document to understand the following:

           

          This script will flash an LED connected between GND and Arduino shield pin 8

          echo "26" >/sys/class/gpio/export

          echo "out" >/sys/class/gpio/gpio26/direction

          echo "strong" >/sys/class/gpio/gpio26/drive

          echo  "1" >/sys/class/gpio/gpio26/value

          sleep 1

          echo  "1" >/sys/class/gpio/gpio26/value

          sleep 1

          echo  "0" >/sys/class/gpio/gpio26/value

          sleep 1

          echo  "1" >/sys/class/gpio/gpio26/value

          sleep 1

          echo  "0" >/sys/class/gpio/gpio26/value

          echo "26" >/sys/class/gpio/unexport

          • 2. Re: How do I set GPIO in the Development Kit for IoT image?
            SpiderKenny

            In My example above you can see that I use GPIO number 26

            Which if you look in the Gallileo IO Mapping Document is IO8 - this refers to the Arduino shield pin number.

            The doc also shows that it is not multiplex (Muxed) with anything else so you can access it directly.

            The ones which are multiplexed with others are a little bit more difficult: as well as setting up the pin for GPIO access, you must also setup the MUX SELECTOR pin and drive it to a 1 or a 0 depending on which output of the mux you need connected to the Shield connector pin.

             

            For example, if I wanted to do SPI MOSI on pin 11, I'd need to setup GPIO access to GPIO Number 43 and drive it to a 0 to select SPI1_MOSI or a 1 to select IO11.

             

            It sounds complicated but it's easy once you get used to it. Think of it like this: Some pins have a switch attached to them. This switch selects between one signal and another being connected to the pin (In my example, between SPI1_MOSI and IO11), the switch is controlled by driving yet another GPIO line, as listed in the 'Galileo I/O Function Muxing' table in the Galileo IO Mapping document.

             

            So to further my example, if I wanted to drive IO11 on Pin11 of the shield. I would:

            • Export "25" - this is Linux's name for IO11
            • Export "43" this is Linux's name for the signal that drives the switch
            • Set the 'value' of gpio43 to 1 to switch IO11 through to Pin 11
            • Set the 'value' of gpio25 to toggle the output on that pin.

             

            Simples!

            • 3. Re: How do I set GPIO in the Development Kit for IoT image?
              Giles_Bradshaw

              Simples when you knows how

               

              I've now got the output toggling with sysfs galileo-io does not work however unless I run echo 26 > /sys/class/gpio/export first which is odd but this is definte progress

               

              Thanki yo very much

              • 4. Re: How do I set GPIO in the Development Kit for IoT image?
                SpiderKenny

                I Forgot to mention also that for some pins you need to drive yet another GPIO which enables the voltage level shifter so that 5v pins can be connected to the quarks 3.3v IO.

                • 5. Re: How do I set GPIO in the Development Kit for IoT image?
                  SpiderKenny

                  And of course you can do all of that from within 'c' programs by using open/write/read