Jump to content

Srini

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by Srini

  1. On 9/26/2018 at 10:06 PM, sgjava said:

    @Srini gpio.h should be in the downloaded kernel headers. You can sudo find / -name gpio.h to see where it is. https://github.com/sgjava/userspaceio/blob/master/libgpiod/install.sh#L38 is where the kernel header logic is. I tested this with the latest stable release for NanoPi Duo and it worked fine. It also worked on the FriendlyElec image, but I had to manually install the headers.

    @sgjava , Thank you so much, but even after I find the gpio.h from kernel source path and installed manually in /usr/src/linux-header-$(uname -r)/ , the configure script could not able to find the path of  "linux/gpio.h" but finally I could solve the compilation by exporting the C_INCLUDE_PATH in the shelling using "export C_INCLUDE_PATH=/usr/src/linux-headers-4.14.72-v7+/include/:/usr/include/" , it's working now.. I could build the libgpiod on the Raspberry CM3.

    once again thank you so much.   

    Regards,

    Srini.

     

  2. On 1/24/2018 at 12:03 PM, sgjava said:

    OK, I got it to build finally! I'm working on a how-to and will post that once I verify the steps and that it actually works, thanks!

     

    @sgjava, could you please post how you manage to get the "linux/gpio.h" file, I am running into the same problem where the autoconfig say it could not find the 'linux/gpio.h' file, Please help with your findings. Thanks. Srin.

  3. On 1/24/2018 at 1:35 PM, sgjava said:

     

    This has been replaced by: User Space IO get more details on this thread.

     

     


     

    Well, it's time to say goodbye to sysfs and hello to libgpiod! @zador.blood.stained pointed me in the right direction, but you need to do one little hack I'll explain below involving compiler_types.h. I tested this on a NanoPi Duo, but it should work on any mainline Armbian release (and other distros as well) as long as the kernel is >= 4.8. Try ls /dev/gpiochip* and see if anything is listed. If so, then proceed.

     

    I'm continuing work on my Github site https://github.com/sgjava/libgpiod-extra, so please report any issues there. There is an Armbian install script that automates the steps below :) I generated the Python wrapper, but there's a lot of functions to test, so I'm not sure of the quality. I'm working on some simple Python tests.

    • sudo armbian-config, Software, Headers
    • sudo apt-get install libtool pkg-config
    • git clone https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
    • cd libgpiod
    • mkdir -p include/linux
    • cp /usr/src/linux-headers-$(uname -r)/include/linux/compiler_types.h include/linux/.
    • ./autogen.sh --enable-tools=yes --prefix=/usr/local CFLAGS="-I/usr/src/linux-headers-$(uname -r)/include/uapi -Iinclude"
    • make
    • sudo make install
    • sudo ldconfig

    Let's try some commands:

     

    sudo gpiodetect

     

    gpiochip0 [1c20800.pinctrl] (224 lines)
    gpiochip1 [1f02c00.pinctrl] (32 lines)

     

    sudo gpioinfo | grep "\[used\]"

     

        line  10:      unnamed "nanopi:blue:status" output active-high [used]
        line 166:      unnamed         "cd"   input  active-high [used]
        line 202:      unnamed  "interrupt"   input  active-high [used]
        line 205:      unnamed      "reset"  output   active-low [used]
        line   6:      unnamed          "?"  output  active-high [used]
        line   7:      unnamed   "vcc-wifi"  output  active-high [used]
        line  10:      unnamed "nanopi:green:pwr" output active-high [used]

     

    Notice how it found the Duo's built in LEDs :)

     

    Now let's test the Duo's built in button (press and release 3 times):

     

    sudo gpiomon --num-events=3 --rising-edge gpiochip1 3

     

    event:  RISING EDGE offset: 3 timestamp: [1516774143.944174870]
    event:  RISING EDGE offset: 3 timestamp: [1516774145.123474395]
    event:  RISING EDGE offset: 3 timestamp: [1516774145.987531088]

     

    Wire up LED (the normal way) and use Duo's IOG11 then to turn on and off:

     

    sudo gpioset gpiochip0 203=0

    sudo gpioset gpiochip0 203=1

     

    Python code

    
    import time
    from libgpiod.libgpiod import *
    
    chip = gpiod_chip_open("/dev/gpiochip0")
    line = gpiod_chip_get_line(chip, 203)
    # The will set line for output and set initial value (LED on)
    if gpiod_line_request_output(line, "test", 0) == 0:
        time.sleep(3)
        # LED off
        gpiod_line_set_value(line, 1)
        gpiod_line_release(line)
    gpiod_chip_close(chip)

    More reading at https://www.cnx-software.com/2017/11/03/learn-more-about-linuxs-new-gpio-user-space-subsystem-libgpiod and https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/tree/README. Maybe @Larry Bank will work on ArmbianIO II :) It looks like in the old Github site there was a milestone to create Python and C++ wrappers https://github.com/brgl/libgpiod/milestone/3. Once I learn more about libgpiod I may just generate them like I did for ArmbianIO.

    @sgjava, could you describe how to install Linux headers for the raspberry-CM3 target, I am running the latest kernel, built and install, I cloned the kernel from "git clone --depth=1 https://github.com/raspberrypi/linux " which falls to be a kernel version 4.4.21-v7+ , I have even tried installing the header from the kernel build directory using the command "make headers_install" but still it is not installing all the required include file like "linux/gpio.h" for building the libgpiod. I noticed you were successfull in building the libgpiod on raspberry. please give some tips I am literally blocked. Appreciate your help.                                                                                                                                                              regards,Srini

×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines