UDOO X86 Braswell GPIOs

Discussion in 'UDOO X86' started by johncompo, Sep 11, 2017.

Tags:
  1. johncompo

    johncompo New Member

    Joined:
    Aug 30, 2017
    Messages:
    2
    Likes Received:
    0
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    It is enabled by default. Just follow the instructions on that GPIO page to read for example gpio350:
    cat /sys/class/gpio/gpio350/value

    For more information the documentation already refers to the Linux GPIO Sysfs Interface for Userspace that can be used to access and control GPIO on a Linux system including the Udoo X86

    What kind of GPIO handling do you want to do?
     
  3. Ion Dulgheru

    Ion Dulgheru New Member

    Joined:
    May 4, 2017
    Messages:
    3
    Likes Received:
    0
    On Fedora 26 the gpio folder is empty:

    [root@udoo ~]# ls /sys/class/gpio
    ls: cannot access '/sys/class/gpio': No such file or directory
    [root@udoo ~]# cat /etc/redhat-release
    Fedora release 26 (Twenty Six)
    [root@udoo ~]# uname -a
    Linux udoo 4.11.9-300.fc26.x86_64 #1 SMP Wed Jul 5 16:21:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
     
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    In Ubuntu 16.04 LTS (default installation) there is, so you have to search why Fedora is not supporting gpio by default.


    udoox86@UDOO-x86:~$ ls /sys/class/gpio
    export gpiochip318 gpiochip373 gpiochip397 gpiochip456 unexport
     
  5. TGo1

    TGo1 New Member

    Joined:
    Jan 3, 2018
    Messages:
    26
    Likes Received:
    0
    Hello all,
    @waltervl , it's not possible for me to used :
    echo 497 > /sys/class/gpio/export
    Console send me a : permission non accordée
    it's the same with sudo !!!
    Have you an idea for use this command line ?
    Please, thank you
    Thierry
     
  6. Markus Laire

    Markus Laire Active Member

    Joined:
    Mar 9, 2017
    Messages:
    225
    Likes Received:
    91
    sudo echo 497 > /sys/class/gpio/export doesn't work because of how sudo and redirection works in Linux - sudo doesn't affect the redirection here.

    You can use for example: echo 497 | sudo tee /sys/class/gpio/export

    Command "tee" works a bit like redirection ">" does, except that you can use "sudo" with it.
     
  7. waltervl

    waltervl UDOOer

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

    TGo1 New Member

    Joined:
    Jan 3, 2018
    Messages:
    26
    Likes Received:
    0
    Big Thanks @Markus,
    Now it work fine

    Thank you too @waltervl
     
    Last edited: Jan 4, 2018
  9. TGo1

    TGo1 New Member

    Joined:
    Jan 3, 2018
    Messages:
    26
    Likes Received:
    0
    Last edited: Jan 5, 2018
  10. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    UART is a serial communication protocol that normally runs over 2 GPIO Pins (TX/TR).
    So if you want to check if there is serial communication over the UART bus than you use serial modules of the programming language you are working with. PySerial for example when using Python.
    Or you can write it yourself but it is difficult. The interrupt will be somehere in the PINCRTL lib you mentioned. But if you do not understand that now I would advise to keep it simple and use a higher level programming language
     
  11. TGo1

    TGo1 New Member

    Joined:
    Jan 3, 2018
    Messages:
    26
    Likes Received:
    0
    A high level programming don't give me interrupt access ...
    USB, not UART, is working fine, i saw it in ECLIPSE console, but now i want integrated in ROS application.
    I know it's pinctrl-cherryview.c source file to use, but comment are small ...
    I will find !
     
    Last edited: Jan 8, 2018
  12. Taras

    Taras New Member

    Joined:
    Dec 13, 2017
    Messages:
    6
    Likes Received:
    0
    Hi!
    does anybody know how to use gpio directly ?
    regs = ioremap(0xdead0000, 4); like this
    Or how to learn base memory address to use gpio?
     
  13. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    You can review the kernel driver code to understand how control a gpio pin. However beware this may not be possible from user space as direct access to the memory region might be protected. Also note the gpio pins are configured by the UEFI BIOS.
     
  14. Taras

    Taras New Member

    Joined:
    Dec 13, 2017
    Messages:
    6
    Likes Received:
    0
    Im going to compile LKM . And i need use pin 330 for example. Its not clear for me - how to get address ?
     
  15. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    There is little reason to access gipo through manipulating the registers yourself as that is the feature of the existing kernel driver. From LKM you can use the standard gpio api's for access.
     
    Last edited: Mar 9, 2018
  16. Taras

    Taras New Member

    Joined:
    Dec 13, 2017
    Messages:
    6
    Likes Received:
    0
    Now i use
    fd = open("/sys/class/gpio/gpio330/value",0_WRONLY);
    and then
    write(fd,"1",1) or write(fd,"0",1) it works , but i wish do it faster (as quickly as possible)
    maybe ioctl works faster ?
     

Share This Page