PINE64
DC Power IN Power-ON Switch Reset Switch -- Batt Required - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PINE A64(+) (https://forum.pine64.org/forumdisplay.php?fid=4)
+--- Forum: Pine A64 Hardware, Accessories and POT (https://forum.pine64.org/forumdisplay.php?fid=32)
+---- Forum: DC Power In (https://forum.pine64.org/forumdisplay.php?fid=35)
+---- Thread: DC Power IN Power-ON Switch Reset Switch -- Batt Required (/showthread.php?tid=1505)



DC Power IN Power-ON Switch Reset Switch -- Batt Required - MarkHaysHarris777 - 06-24-2016

   

I have a couple of tips regarding the DC IN Power-ON & Reset switches. First off, they are right-angle switches which have a beefy frame (say heatsink) and therefore require a 40 watt iron to solder in (your little 15 or 25 watt iron isn't going to cut it). 

Secondly, and maybe most importantly, the power-on switch is not going to work without the DC batt plugged in and fully charged. The PMIC detects that the batt isn't there and immediately shuts down the system; this is why several of you are reporting that your switch isn't working. The reset does just that (a reset) not a good thing to do without a clean shutdown first. Holding the power-on button for a while will do a hard power-off if that were required (like any notebook computer, &c). Otherwise, the power-on button sends a keycode to the kernel (I have not been able to verify but I think its 116; let you know). This could be trapped to signal a clean poweroff. With a fully charged batt plugged in the power-on button will power-up the device without removing the main power plug. Not sure if a small backup battery would be enough; will have to test.

marcus

PS ... click the thumbnail above to get a larger view/


RE: DC Power IN Power-ON Switch Reset Switch -- Batt Required - xalius - 06-24-2016

You can test if your powerbutton sends a keycode with evtest, the driver basically registers the button like another keyboard:


Code:
ubuntu@pine64:~$ sudo apt-get install evtest

Reading package lists... Done
Building dependency tree
Reading state information... Done
evtest is already the newest version (1:1.33-1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

ubuntu@pine64:~$ sudo evtest

No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      sunxi-keyboard
/dev/input/event1:      axp81x-supplyer
/dev/input/event2:      sunxi-ths
/dev/input/event3:      audiocodec sunxi Audio Jack
/dev/input/event4:      sunxi_ir_recv
/dev/input/event5:      MCE IR Keyboard/Mouse (sunxi-rc-recv)

Select the device event number [0-5]: 1

Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "axp81x-supplyer"
Supported events:
 Event type 0 (EV_SYN)
 Event type 1 (EV_KEY)
   Event code 116 (KEY_POWER)
 Event type 2 (EV_REL)
Properties:
Testing ... (interrupt to exit)
Event: time 1466799328.888825, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1466799328.888825, -------------- SYN_REPORT ------------
Event: time 1466799328.999256, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1466799328.999256, -------------- SYN_REPORT ------------
Event: time 1466799329.630542, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1466799329.630542, -------------- SYN_REPORT ------------
Event: time 1466799329.798206, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1466799329.798206, -------------- SYN_REPORT ------------

ubuntu@pine64:~$



RE: DC Power IN Power-ON Switch Reset Switch -- Batt Required - MarkHaysHarris777 - 06-24-2016

(06-24-2016, 02:15 PM)xalius Wrote: You can test if your powerbutton sends a keycode with evtest, the driver basically registers the button like another keyboard:

Thank you, xalius !

... yes, the keycode is in fact 116; and it works great-- I've only tested it on the xenial ubuntu image, signals a shutdown just like clicking 'shutdown'... 59 seconds later down we go; of course, that may be canceled too.

So, now I need a 3.7v backup batt to check the power-on /

marcus


RE: DC Power IN Power-ON Switch Reset Switch -- Batt Required - xalius - 06-24-2016

Yeah I want to play with the battery charger too, but Tl Lim needs to find some time to translate the datasheet of the one they sell in the shop so I can get something similar. Just dont make it too small since the default charge current is quite high if I remember correctly...


RE: DC Power IN Power-ON Switch Reset Switch -- Batt Required - MarkHaysHarris777 - 06-24-2016

(06-24-2016, 02:42 PM)xalius Wrote: Yeah I want to play with the battery charger too, but Tl Lim needs to find some time to translate the datasheet of the one they sell in the shop so I can get something similar. Just dont make it too small since the default charge current is quite high if I remember correctly...

Thanks, this is good to know-- I have a little small batt from my Intel Edison, which I won't be plugging after all... I'll wait till I have the official one !

Tnx

Grüß


RE: DC Power IN Power-ON Switch Reset Switch -- Batt Required - pfeerick - 06-24-2016

(06-24-2016, 02:15 PM)xalius Wrote: You can test if your powerbutton sends a keycode with evtest, the driver basically registers the button like another keyboard:


Code:
ubuntu@pine64:~$ sudo apt-get install evtest

Reading package lists... Done
Building dependency tree
Reading state information... Done
evtest is already the newest version (1:1.33-1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

ubuntu@pine64:~$ sudo evtest

No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      sunxi-keyboard
/dev/input/event1:      axp81x-supplyer
/dev/input/event2:      sunxi-ths
/dev/input/event3:      audiocodec sunxi Audio Jack
/dev/input/event4:      sunxi_ir_recv
/dev/input/event5:      MCE IR Keyboard/Mouse (sunxi-rc-recv)

Select the device event number [0-5]: 1

Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "axp81x-supplyer"
Supported events:
 Event type 0 (EV_SYN)
 Event type 1 (EV_KEY)
   Event code 116 (KEY_POWER)
 Event type 2 (EV_REL)
Properties:
Testing ... (interrupt to exit)
Event: time 1466799328.888825, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1466799328.888825, -------------- SYN_REPORT ------------
Event: time 1466799328.999256, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1466799328.999256, -------------- SYN_REPORT ------------
Event: time 1466799329.630542, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1466799329.630542, -------------- SYN_REPORT ------------
Event: time 1466799329.798206, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1466799329.798206, -------------- SYN_REPORT ------------

ubuntu@pine64:~$

Thanks for that! Now I know my button is working! Smile

So, next my next question is : Do you know any (simple!) way to get the pine64 to respond to it? I'm using debian, and would like to make it trigger a shutdown. I keeps seeing mention of xbindkeys seeming to be able to do this, but I want a headless machine to be able to do this, not one with X11.

Edit: So, after a little more digging, and coming across a wiki page about udev and sleep buttons, I sort of followed the instructions and ended up with this for a udev rule, and it works!


Code:
pfeerick@pine64:~$ more /etc/udev/rules.d/70-power-switch-my.rules
ACTION=="remove", GOTO="power_switch_my_end"
SUBSYSTEM=="input", KERNEL=="event1", ATTRS{name}=="axp81x-supplyer", TAG+="power-switch"
LABEL="power_switch_my_end"

I then executed the following commands to freshen things up, and voila... pressing the power button causes the pine64 to instantly start shutting down! Now to see if I can make it trigger a delayed shutdown - say with 1 minutes grace...  Smile


Code:
sudo systemctl restart systemd-udevd
sudo udevadm trigger
sudo systemctl restart systemd-logind


As a side-note, connecting the battery can be annoying - when the battery is connected, when I tell the pine64 to poweroff / halt, it powers itself back up again.


RE: DC Power IN Power-ON Switch Reset Switch -- Batt Required - xalius - 06-25-2016

Nice one on the use of udev ... I used the package trigger-happy which can monitor multiple input devices at once and is also useful to bind the buttons of the IR remote to commands... as for the Pine turning back on with the battery connected... I think we need to check on the PMIC driver there....