Jump to content

Clearfog push buttons


Learnincurve

Recommended Posts

Hi again,

 

The Clearfog base has two push buttons, but these don't seem to be hard-wired to any hardware functionality.

 

Does anyone know how to find them in the system and monitor them for events? They could then be used for example to reboot or power down the system.

 

BR.

 

--Marius--

 

Link to comment
Share on other sites

One button is hardwired as a reset button (rectangular one near the power connector) and another one should be configured as a gpio-keys button with code BTN_0: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/arch/arm/boot/dts/armada-388-clearfog-base.dts#n63

You just need to find a software solution that would let you run commands on key press events.

Link to comment
Share on other sites

Sorry if this is stupid.

This is what I found so far:

 

  From the dts file link that zador posted:

 

	gpio-keys {
		compatible = "gpio-keys";
		pinctrl-0 = <&rear_button_pins>;
		pinctrl-names = "default";

		button_0 {
			/* The rear SW3 button */
			label = "Rear Button";
			gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
			linux,can-disable;
			linux,code = <BTN_0>;
		};
	};
};

 

Then  doing cat /sys/kernel/debug/gpio and looking for "Rear Button", I find that that is on pin 44:

 

 grep -i "Rear Button" /sys/kernel/debug/gpio

 gpio-44  (Rear Button         ) in  hi (act lo) - IRQ edge  (clear  )

 

but if I try to export pin 44, I get device or resource busy:

 

root@clearfogbase:~# echo 44 > /sys/class/gpio/export
-bash: echo: write error: Device or resource busy

 

I compiled gpio_watch from http://blog.oddbit.com/2014/07/26/gpiowatch-run-scripts-in-respo/

 

which I though looked like a good way to do what I wanted.

 

What am I doing wrong?

 

BR.

 

--Marius--

 

Link to comment
Share on other sites

You can not use "gpio-keys" and "plain sysfs gpio" at the same time. You need to choose on or the other.

With "gpio-keys", you can check events with "evtest".

To use your "gpio_watch" application, you will need to remove all the things you've added to DTS.

 

Link to comment
Share on other sites

For information, I sorted this using "triggerhappy":

 

Apt installed

created a "triggerhappy" system user and modified the init script to use it.

crated a trigger configuration for the button press event (BTN_0 1)

creted a simple script invoking systemctl poweroff -I

modified sudoers accordingly.

 Tested:. Buttonpress shuts down the system even if users are currently logged in.

The system can be started again by pressing the other, rectangular switch by the power intake, which as zador.blood.stained correctly pointed out, is hardwired as reset.

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines