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:
#!/bin/sh
. /lib/functions.sh
OVERLAY="$( grep ' /overlay ' /proc/mounts )"
case "$ACTION" in
pressed)
[ -z "$OVERLAY" ] && return 0
return 5
;;
timeout)
. /etc/diag.sh
set_state failsafe
;;
released)
if [ "$SEEN" -lt 1 ]
then
echo "REBOOT" > /dev/console
sync
reboot -f
elif [ "$SEEN" -ge 5 -a -n "$OVERLAY" ]
then
echo "FACTORY RESET" > /dev/console
jffs2reset -y && reboot &
fi
;;
esac
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!