Welcome! Log In Create A New Profile

Advanced

Ox820: gpio-keys-polled does not provide /dev/input/eventx

Posted by Christian 
Hello all,

I habe setup a Medion NAS/Ox820 with 4.4.201-oxnas-tld-1 and Debian buster.

I try to execute a script when gpio-keys-polled reports <Key_Copy>.
By the help of 'showkey' I can see, that Keycode 133 is generated.

Now I want to use esekeyd as descibed in the thread 'NSA325 copy button event'.

But I see that esekeyd is watching on /dev/input/event and the subfolder 'event' is not present.

Maybe the Problem is that kernel is build without option '<*> Event interface'?

BR,
Christian
Me again...

I think I'm a step closer to the root cause...

I have powered up my NSA325 and there /dev/input/event0 is available.
This is, because Kernel module evdev is available in 5.2.9-kirkwood-tld-1 and loaded.

On 4.4.201-oxnas-tld-1 the evdev module is not available.
Additionally I find no hint if the Event interface itself is enabled inside this kernel 4.4.201. But I hope so...

Now my question:
Can anybody provide the evdev module (evdev.ko) from /lib/modules/4.4.201-oxnas-tld-1/kernel/drivers/input to me or do I have to compile it on my own with setting up the whole Kernel sources on my machine?!?

BR,
Christian
Re: Ox820: gpio-keys-polled does not provide /dev/input/eventx
April 19, 2020 03:09AM
Christian,


> On 4.4.201-oxnas-tld-1 the evdev module is
> not available.
> Additionally I find no hint if the Event interface
> itself is enabled inside this kernel 4.4.201. But
> I hope so...
>

> Can anybody provide the evdev module (evdev.ko)
> from
> /lib/modules/4.4.201-oxnas-tld-1/kernel/drivers/input
> to me or do I have to compile it on my own with
> setting up the whole Kernel sources on my
> machine?!?
>

Let me take a look. This kernel was built with the Pogo V3 OXNAS as a base, and there is no button on this Pogoplug box. So now you are running it with the Medion box, I'm not surprised that module is not available.

I'm building the next kernel version for this. Either kernel 5.4.x or 4.14.x, whichever is working first in that order. I will make sure the event input interface will be configured in.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Hello Bodhi,

thanks in advance!

The dts for the Medion MD86803 configures the two gpio pins for COPY-Button and Reset-Button in the right manner.
Keycode is working well!!

Hopefully with evdev module available and loaded 'Copy-Button' will create 'Event No.3' as it's already configured inside gpio-keys-polled configuration and I can execute a bash script with the help of esekeyd.

BR and stay healthy,
Christian
Hello bodhi,

great job on kernel 4.14.176!!

/dev/input/event0 is available and esekeyd works out of the box like a charm.

Within a script executed by esekeyd I unload the kernel module 'gpio_key_polled' to release the gpio line used by the kernel. Afterwards I export the line as gpio to continue working with cat command for reading the value.

When copy button is unpressed after 2 seconds (short press) I perform a reboot,
when button is still pressed after 2 seconds (long press) I shutdown the NAS.

In addition the current operating status is signalized by the blue, red and orange LEDs.

Thanks for your support!

Christian
Re: [Solved] Re: Ox820: gpio-keys-polled does not provide /dev/input/eventx
April 30, 2020 04:30PM
Christian ,

> Within a script executed by esekeyd I unload the
> kernel module 'gpio_key_polled' to release the
> gpio line used by the kernel. Afterwards I export
> the line as gpio to continue working with cat
> command for reading the value.
>

> When copy button is unpressed after 2 seconds
> (short press) I perform a reboot,
> when button is still pressed after 2 seconds (long
> press) I shutdown the NAS.

Pretty cool!

If you could share your script, or just a set of commands, I'd like to add it to the Wiki.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Hi bodhi,

no problem. Here is my script:

#!/bin/bash
#
# copybtn
#
# This script is executed by esekeyd daemon when
# "Copy-Key"/"KEY_133" gets pressed. 
#
# If button is pressed < 2sec a reboot is executed.
# If button is pressed > 2sec a shutdown is executed.
#
# Make sure that the script will "exit 0" on success or any other
# value on error.

#unload kernel module "gpio_key_polled" because it locks the  gpio line inside chardev gpiochip32/GPIO1
rmmod gpio_keys_polled

# switch off blue LED to signalize to the user, that press of copy button has been detected
echo none > /sys/class/leds/zyxel:blue:status/trigger

# export GPIO1/channel13 to make button status readable by "value"
echo 45 > /sys/class/gpio/export

# wait for 2 seconds
sleep 2

# read current status of copy button after 2 seconds
var=$(cat /sys/class/gpio/gpio45/value)

if [ "$var" = "1" ]; then
        # show "reboot" by blue LED performing "Heartbeat"
        echo heartbeat > /sys/class/leds/zyxel:blue:status/trigger
        shutdown -r now 
else
        # show "shutdown" by red LED "permanent  on"
        echo default-on > /sys/class/leds/zyxel:red:status/trigger
        shutdown -h now
fi

exit 0

BR,
Christian
Re: [Solved] Ox820: gpio-keys-polled does not provide /dev/input/eventx
May 01, 2020 05:16PM
Thanks Christian!

Up in the Wiki


Quote
https://forum.doozan.com/read.php?2,23630

Key daemon (button control)

Multimedia keyboard daemon for Linux
How to use set up button to reboot or shutdown with Key Daemon (esekeyd)

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: [Solved] Ox820: gpio-keys-polled does not provide /dev/input/eventx
May 11, 2022 01:49PM
By default in rootfs the function to shutdown when pressing the power button is present (I did not do anything and this feature is present since the beginning). I tried to find out where this is coming and I found the button-switch.sh that is ecactly this script.

However I cannot manage to have the halt or the reboot (I tried different timing for the pressing but it always shutdown and never reboot).
Also I never see the red led on during the halt.

I tried to execute the commands in terminal and when I get an error with :

root@debian:/etc/init.d# rmmod gpio_keys_polled
rmmod: ERROR: Module gpio_keys_polled is not currently loaded

Is this supposed to work with NSA325 ?

I looked into this discussion: LED on NSA325v2 but again I cannot figure out how to trigger red the power button for example.



Edited 1 time(s). Last edit at 05/11/2022 01:55PM by miazza.
Re: [Solved] Ox820: gpio-keys-polled does not provide /dev/input/eventx
May 11, 2022 03:20PM
miazza,

Each box has a different LEDs skeme so if the questions are about NSA325, it should not be asked here (will be consfusing to go back and forth).

Should be in this thread

https://forum.doozan.com/read.php?2,32460,32467#msg-32467

You will see the examples about using esekeyd to control button. And how to set up the script to shoutdown.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: