GPIO Interrupts Omega2



  • Hi everyone and @administrators

    I was digging and searching for all the posts in this forum about how to enable interruptions in Omega2 GPIOs, however, after much reading and understanding how the Omega2 SDK works, among other things, I was able to understand how to enable interruptions in Omega2, thanks to @Kit-Bishop because without his post this would have been almost impossible not to say impossible.

    I have managed to modify the code of @Kit-Bishop to be able to read and write in the GPIOs of the Omega2, with this also enable PWM and PULSE, the only thing missing are the interruptions, however, for this it is necessary the module "kmod-gpio-irq" which @luz has already modified to work on the Omega2 (https://github.com/OnionIoT/gpio-irq/pull/1), however, this module is not available in the official Omega2 packages, so it can not be installed using "opkg".

    I tried to compile it on my own using the Omega2 SDK following the cross-compilation tutorial (https://docs.onion.io/omega2-docs/cross-compiling.html), then install it using opkg, however it reaches a dead end, because when I compiled it with that SDK the kernel using corresponds to version 4.4.71 , however, the version running the Omega2 is 4.4.46 (as you can see in the image attached) so it can not be installed because of the incompatibility.

    I could try to use kernel 4.4.46 and compile it, however, because of the importance of this module (the interruptions are VERY important) I think it is more feasible to ask the @administrators to add it to the official packages.

    So, @administrators, could you add the package please? This was already done for Omega1 but not for Omega2.

    @Lazar-Demin @onion

    Thank you very much!!

    0_1499452707209_ErrorGPIOIRQ.png



  • @Keitaro While opening the complete setup to build matching kernel modules is definitely something @onion should do (@administrators, @Lazar-Demin, hello again…), there's a ugly workaround for this: you can just force the module to load:

    opkg install --force-depends kmod-gpio-irq_4.4.71\+HEAD-1_mipsel_24k.ipk
    

    This is not without risk - if kernel internals have changed too much between the kernel you are running and the kernel the module has been compiled for, this will crash the system or cause any other undefined behaviour.

    Having said that, the kernel APIs used by kmod-gpio-irq haven't changed between kernels 4.4.46 and 4.4.71, so it should work in this case.



  • This post is deleted!


  • @luz Hi. I tried it, but without success.

    opkg install --force-depends ./kmod-gpio-irq_4.4.74+HEAD-1_mipsel_24kc.ipk
    Installing kmod-gpio-irq (4.4.74+HEAD-1) to root...
    Configuring kmod-gpio-irq.
    Collected errors:

    • satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-gpio-irq:
    • kernel (= 4.4.74-1-aaf6d939aa2876446cc7729bf177ca18)


  • @Zerog despite the errors, the module should be installed now.
    Because --force-depends does not silence the error messages, but only causes them to be ignored.

    Try insmod gpio-irq and then have a look at dmesg and lsmod to see if the module was loaded.



  • @luz said in GPIO Interrupts Omega2:

    insmod gpio-irq

    Hi @Zerog @luz, I've managed to compile and insmod the kernel module for Omega2. Thanks to your hints 🙂
    however, I can't win the fight with the gpioirq (which is a part of this package https://github.com/KitBishop/Omega-GPIO-I2C-Arduino/tree/master/gpioirq).

    i've been trying with "toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2" recommended in PDF doc. successfully, but it doesn't work on Omega2 (giving: syntax error: unexpected "(" (expecting ")") ) , probably by architecture/binary difference. The original Omega2 toolchain can't link it (.o fileas are baked) and producing errors like:

    ./../../../mipsel-openwrt-linux-musl/bin/ld: ../libnewgpio/bin/static/libnewgpio.a(GPIOPin.o): compiled for a big endian system and target is little endian
    ./../../../mipsel-openwrt-linux-musl/bin/ld: ../libnewgpio/bin/static/libnewgpio.a(GPIOPin.o): endianness incompatible with that of the selected emulation
    ./../../../mipsel-openwrt-linux-musl/bin/ld: failed to merge target specific data of file ../libnewgpio/bin/static/libnewgpio.a(GPIOPin.o)

    Would appreciate for any recommendations!



  • success! I solve the issue 🙂

    This is what I have changed in Makefile (for both: libnewgpio and gpioirq)
    TOOL_BIN_DIR=<uor path>Omega/source/staging_dir/toolchain-mipsel_24kc_gcc-5.5.0_musl/bin
    CC=$(TOOL_BIN_DIR)/mipsel-openwrt-linux-g++

    then just compile with make (libnewgpio and gpioirq consequently)



  • Hello,

    I am not able to combile the kernel module.
    Can someone help me with this?

    @administrators This should really be directly within the repo.

    If I use the xCompile.sh with modified includes to get some required files (module.h and others) I will end up with

    INCLUDE_LINES="-I $TOOLCHAIN_USR_INCLUDE -I $TOOLCHAIN_INCLUDE -I $TARGET_USR_INCLUDE -I $TARGET_INCLUDE -I /home/onion/onion_source/build_dir/toolchain-mipsel_24kc_gcc-5.5.0_musl/linux-4.9.67/include/ -I /home/onion/onion_source/build_dir/toolchain-mipsel_24kc_gcc-5.5.0_musl/linux-4.9.67/arch/mips/include -I /home/onion/onion_source/build_dir/toolchain-mipsel_24kc_gcc-5.5.0_musl/linux-4.9.67/arch/mips/include/asm/mach-generic/ -I /home/onion/onion_source/build_dir/toolchain-mipsel_24kc_gcc-5.5.0_musl/linux-4.9.67/arch/mips/include/generated -I /home/onion/onion_source/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/linux-4.9.67/include"
    

    Which still make lots of warnings and result end in missing file
    fatal error: asm/rwsem.h: No such file or directory

    which i can not find with a suitable mips include.

    best regards,
    Christian


  • administrators

    Please try this code: https://github.com/OnionIoT/gpioIrq

    The Omega2 already supports edge detection with sysfs, the code above is an example of a C program that implements edge detection. It can be made non-blocking if used with threads.



  • Looks like this is the most recent thread on GPIO Interrupts. What's the current status on GPIO interrupt support on the Omega2?

    In particular:

    1. what are the typical latencies associated with the sysfs method?
    2. are there any advantages for the kmod-gpio-irq path?
    3. if so, is there a reliable way to use kmod-gpio-irq on the Omega2 or is it likely to end in the dead-ends reported in this thread?

    Cheers,
    Heath



Looks like your connection to Community was lost, please wait while we try to reconnect.