GPIO Output Pins Not Changing State

Discussion in 'UDOO X86' started by nhenault, Aug 9, 2018.

  1. nhenault

    nhenault New Member

    Joined:
    Jun 12, 2018
    Messages:
    6
    Likes Received:
    0
    Hello,
    I have encountered this issue on two separate and new UDOO x86 Ultras so I don't believe it is from board damage. When I set GPIO pins, for example GPIO 344 which is physical pin 26, as outputs I am unable to get them to change states from 0 to 1. The voltage at the pin just sits at 3.3V. I am setting up the pin using the process:
    Code:
    echo 344 > /sys/class/gpio/export
    echo out > /sys/class/gpio/gpio344/direction
    echo 0 > /sys/class/gpio/gpio344/value
    I don't know if there is something I have to install or configure before I am able to do this, but it seems like everything should come preinstalled. I have already checked in the UEFI BIOS and assured that the LPC Buss is disabled so that the pins I am trying to use function as GPIO pins.
     
  2. ccs_hello

    ccs_hello UDOOer

    Joined:
    Apr 15, 2017
    Messages:
    536
    Likes Received:
    194
    re: GPIO34 pin just sits at 3.3V
    Strange. Braswell is a 1.8V device. Logic HIGH should have been 1.8V...
     
  3. nhenault

    nhenault New Member

    Joined:
    Jun 12, 2018
    Messages:
    6
    Likes Received:
    0
    I know, this was throwing me off as well, but I am getting the same 3.3V reading on multiple separate UDOO x86 Ultra boards. They are also new so it seems to me that it shouldn't be something that I have damaged on them.
     
  4. nhenault

    nhenault New Member

    Joined:
    Jun 12, 2018
    Messages:
    6
    Likes Received:
    0
    Here is some more information if it helps:
    1. I tried the Braswell GPIO pins on CN12, specifically physical pins 43-46 which are pins 329, 330, 333, and 336 internally. They all sit at 1.8V whether or not they have been exported, but I am still unable to set them low using the method described in my original post.
    2. When I configure a pin as an input, its voltage remains at 1.8V but every time I try to read its value it says the pin is low.
    3. This may or may not be what is supposed to happen, but when I restart the UDOO all of the folders which are created during exporting (such as /sys/class/gpio/gpio330) get erased even though I never unexport them.

    If anyone knows anything about these issues please let me know
     
  5. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
  6. nhenault

    nhenault New Member

    Joined:
    Jun 12, 2018
    Messages:
    6
    Likes Received:
    0
    When I initially booted up the computer I got this:
    Code:
    ~$ ls /sys/class/gpio
    export       gpiochip228  gpiochip341  unexport
    gpiochip225  gpiochip314  gpiochip414
    
    Then I entered:
    Code:
    echo 344 > /sys/class/gpio/export
    echo 347 > /sys/class/gpio/export
    echo 349 > /sys/class/gpio/export
    Then I ran the same ls command and I got this:
    Code:
    ~$ ls /sys/class/gpio
    export   gpio347  gpiochip225  gpiochip314  gpiochip414
    gpio344  gpio349  gpiochip228  gpiochip341  unexport
    
    So the gpio folders are being created when I export certain pins and I can see the value and direction files inside each folder along with their contents (out/in or 0/1) changing when I do the echo commands to change them. However, when the values change in the folders they do not change in hardware.

    I am currently running 64-bit Ubuntu 16.04 which I believe should work with gpio, is there a good way to confirm whether or not gpio is enabled on my OS?
     
  7. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Looks like it works. Did you try it as superuser root (su)?
     
  8. nhenault

    nhenault New Member

    Joined:
    Jun 12, 2018
    Messages:
    6
    Likes Received:
    0
    Yes, I have been using sudo -i before running all of these commands because only super user can actually alter the files.
     
  9. Maarten

    Maarten New Member

    Joined:
    Nov 27, 2017
    Messages:
    2
    Likes Received:
    0
    I'm having exactly the same problem.
    I can export gpio's and read them, but the value never changes.
    Using Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-36-generic x86_64) .

    Any updates on this?
     
  10. fajar.adianto

    fajar.adianto New Member

    Joined:
    Oct 31, 2018
    Messages:
    1
    Likes Received:
    3
    Hello,
    I had the same problem. I am using Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-38-generic x86_64).

    After hours of trials and errors, I found that GPIO number listed in (https://www.udoo.org/docs-x86/Hardware_&_Accessories/GPIOs.html) are different from my UDOO x86 (not sure if it is hardware or OS related).

    In my case, I did the following to find the correct GPIO number.

    1. With super user access, list all GPIOs in every gpiochip using:
    Code:
    cat /sys/kernel/debug/pinctrl/INT33FF:00/pins
    
    cat /sys/kernel/debug/pinctrl/INT33FF:01/pins
    
    cat /sys/kernel/debug/pinctrl/INT33FF:02/pins
    
    cat /sys/kernel/debug/pinctrl/INT33FF:03/pins
    I am not actually familiar with linux, but I think the INT33FF:0x part might be in different names for others.​

    2. From the lists, find the pin you want to use by its Processor PAD name and look at the corresponding pin number in its gpiochip.
    for example, looking at the braswell pinout,
    [​IMG]
    I want to use pin 30 which, based on (https://www.udoo.org/docs-x86/Hardware_Reference/Pinout_Braswell.html), has Processor PAD name (ILB_SERIRQ). Using the list I got from "cat /sys/kernel/debug/pinctrl/INT33FF:03/pins" :
    Code:
    cat /sys/kernel/debug/pinctrl/INT33FF:03/pins
    registered pins: 55
    pin 0 (MF_PLT_CLK0) GPIO 0x00118180 0x05c00000
    pin 1 (PWM1) GPIO 0x00118102 0x05c00000
    pin 2 (MF_PLT_CLK1) GPIO 0x00118180 0x05c00000
    pin 3 (MF_PLT_CLK4) GPIO 0x00118180 0x05c00000
    pin 4 (MF_PLT_CLK3) GPIO 0x00118180 0x05c00000
    pin 5 (PWM0) GPIO 0x00118100 0x05c00000
    pin 6 (MF_PLT_CLK5) GPIO 0x00138180 0x05c00000
    pin 7 (MF_PLT_CLK2) GPIO 0x00118180 0x05c00000
    pin 15 (SDMMC2_D3_CD_B) GPIO 0x00918201 0x05c00000
    pin 16 (SDMMC1_CLK) mode 1 0x00110381 0x05c00000
    pin 17 (SDMMC1_D0) mode 1 0x00910381 0x05c00000
    pin 18 (SDMMC2_D1) GPIO 0x00918201 0x05c00000
    pin 19 (SDMMC2_CLK) GPIO 0x00918201 0x05c00000
    pin 20 (SDMMC1_D2) mode 1 0x00910381 0x05c00000
    pin 21 (SDMMC2_D2) GPIO 0x00918201 0x05c00000
    pin 22 (SDMMC2_CMD) GPIO 0x00918201 0x05c00000
    pin 23 (SDMMC1_CMD) mode 1 0x00910381 0x05c00000
    pin 24 (SDMMC1_D1) mode 1 0x00910381 0x05c00000
    pin 25 (SDMMC2_D0) GPIO 0x00918201 0x05c00000
    pin 26 (SDMMC1_D3_CD_B) mode 1 0x00910381 0x05c00000
    pin 30 (SDMMC3_D1) mode 1 0x00910380 0x05c00000
    pin 31 (SDMMC3_CLK) mode 1 0x00110380 0x05c00000
    pin 32 (SDMMC3_D3) mode 1 0x00910380 0x05c00000
    pin 33 (SDMMC3_D2) mode 1 0x00910380 0x05c00000
    pin 34 (SDMMC3_CMD) mode 1 0x00910380 0x05c00000
    pin 35 (SDMMC3_D0) mode 1 0x00910380 0x05c00000
    pin 45 (MF_LPC_AD2) GPIO 0x00918201 0x05c00000
    pin 46 (LPC_CLKRUNB) mode 1 0x00910301 0x05c00000
    pin 47 (MF_LPC_AD0) GPIO 0x00918201 0x05c00000
    pin 48 (LPC_FRAMEB) GPIO 0x00918201 0x05c00000
    pin 49 (MF_LPC_CLKOUT1) mode 1 0x00010300 0x05c00000
    pin 50 (MF_LPC_AD3) GPIO 0x00918201 0x05c00000
    pin 51 (MF_LPC_CLKOUT0) GPIO 0x00918201 0x05c00000
    pin 52 (MF_LPC_AD1) GPIO 0x00918201 0x05c00000
    pin 60 (SPI1_MISO) mode 1 0x00910301 0x05c00000
    pin 61 (SPI1_CSO_B) mode 1 0x00910301 0x05c00000
    pin 62 (SPI1_CLK) mode 1 0x00910300 0x05c00000
    pin 63 (MMC1_D6) mode 1 0x00910381 0x05c00000
    pin 64 (SPI1_MOSI) mode 1 0x00910300 0x05c00000
    pin 65 (MMC1_D5) mode 1 0x00910381 0x05c00000
    pin 66 (SPI1_CS1_B) mode 1 0x00910301 0x05c00000
    pin 67 (MMC1_D4_SD_WE) mode 1 0x00910381 0x05c00000
    pin 68 (MMC1_D7) mode 1 0x00910381 0x05c00000
    pin 69 (MMC1_RCLK) mode 1 0x00110380 0x05c00000
    pin 75 (USB_OC1_B) mode 1 0x00910301 0x05c00000
    pin 76 (PMU_RESETBUTTON_B) mode 1 0x00910301 0x05c00000
    pin 77 (GPIO_ALERT) mode 1 0x00910300 0x05c00000
    pin 78 (SDMMC3_PWR_EN_B) mode 1 0x00110301 0x05c00000
    pin 79 (ILB_SERIRQ) GPIO 0x00918201 0x05c00000
    pin 80 (USB_OC0_B) mode 1 0x00910301 0x05c00000
    pin 81 (SDMMC3_CD_B) GPIO 0x00918200 0x05c00003
    pin 82 (SPKR) mode 1 0x00910300 0x05c00000
    pin 83 (SUSPWRDNACK) mode 1 0x00110300 0x05c00000
    pin 84 (SPARE_PIN) mode 1 0x00110300 0x05c00000
    pin 85 (SDMMC3_1P8_EN) mode 1 0x00110300 0x05c00000
    I see that (ILB_SERIRQ) in my system is in (INT33FF:03 pin 79). Note this information.
    3. Find each gpiochip base number using
    Code:
    cat /sys/kernel/debug/gpio
    .
    which in my case return the following output.
    Code:
    cat /sys/kernel/debug/gpio
    gpiochip4: GPIOs 225-227, parent: platform/INT0002:00, INT0002 Virtual GPIO:
     gpio-227 (                    |ACPI:Event          ) in  lo IRQ
    
    gpiochip3: GPIOs 228-313, parent: platform/INT33FF:03, INT33FF:03:
     gpio-309 (                    |80860F14:01         ) in  lo IRQ
    
    gpiochip2: GPIOs 314-340, parent: platform/INT33FF:02, INT33FF:02:
    
    gpiochip1: GPIOs 341-413, parent: platform/INT33FF:01, INT33FF:01:
    
    gpiochip0: GPIOs 414-511, parent: platform/INT33FF:00, INT33FF:00:
    
    The base number is the first number after the word "GPIOs". In my case I have gpiochip3 (INT33FF:03) base number of 228.

    4. To Find the correct GPIO number, add the pin number in its gpiochip with the gpiochip's base number.
    Following the example in step 2, the (ILB_SERIRQ) GPIO number is (79 + 228 = 307). Note that it is 307 instead of 366 like the UDOO x86 docs stated.
    After you get the correct GPIO number, you can follow the example stated in (https://www.udoo.org/docs-x86/Hardware_&_Accessories/GPIOs.html) using the correct GPIO number.

    I hope this is clear enough to help someone with similar problem.
     
    waltervl, Laura and Maarten like this.
  11. Maarten

    Maarten New Member

    Joined:
    Nov 27, 2017
    Messages:
    2
    Likes Received:
    0
    Perfect answer! This explains it completely.
    I'm also running Ubuntu 18.04.1 LTS and the number correspond with yours.
    But where your answer really shines is in the way you explain how you got there :).

    thanks a lot!
     
  12. sirrab

    sirrab UDOOer

    Joined:
    Jul 26, 2014
    Messages:
    264
    Likes Received:
    32
    And I thought computers was supposed to make life easier for humans!
     
  13. Laura

    Laura UDOOer

    Joined:
    Apr 22, 2016
    Messages:
    374
    Likes Received:
    156
    Seems that starting from 4.16 Linux kernel that the numbers are changed. We are going to update the documentation to reflect this. Thank you guys for bringing this to our attention!
     
  14. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580

Share This Page