WRTnode2P 19.07.02 reset button not support short press function

Hi, Team:

I add a reset button on WRTnode2P (19.07.2 r10947-65030d81f3 MT7628AN), I modified .dts(~/openwrt/target/linux/ramips/dts/WRTNODE2P.dts) and add some code as follow:

	keys {
		compatible = "gpio-keys-polled";
		poll-interval = <20>;

		reset {
			label = "reset";
			gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;

When I press the key quickly, it performs FACTORY RESET, that seems very strange.

I checked the relevant code of reset button and I found the reset file(/openwrt/package/base-files/files/etc/rc.button/reset),it's code as follow:


. /lib/functions.sh

OVERLAY="$( grep ' /overlay ' /proc/mounts )"

case "$ACTION" in
	[ -z "$OVERLAY" ] && return 0

	return 5
	. /etc/diag.sh
	set_state failsafe
	if [ "$SEEN" -lt 1 ]
		echo "REBOOT" > /dev/console
		reboot -f 
	elif [ "$SEEN" -ge 5 -a -n "$OVERLAY" ]
		echo "FACTORY RESET" > /dev/console
		jffs2reset -y && reboot &

return 0

According to the logic of the above code, when I press the key quickly and release it, REBOOT should be executed instead of FACTORY RESET.
What's more, I echo "$SEEN" value , Its value is greater than 5(about 200),however I just press shortly and release.

Somebody gives me a hand?

Best Wishes!

Maybe the button logic is inverted (active low vs. active high)?

To debug this:

  • create the file /etc/hotplug.d/button/buttons
logger "button $BUTTON $ACTION"
  • run logread -f
  • press the button

Hi, mpa:

Thanks for your suggest, I will try.

Best Wishes