The wake/sleep connector on the Hadron DM (NGX024/NGX027) can be used to wake the carrier from shutdown mode. By default, the CTI BSP enables the wake/sleep connector (P13) to wake the module from shutdown mode, however, if you would like to use the pin to also have the module enter shutdown mode, this will need to be configured manually.
This can be done by setting up a desktop environment (recommended) or alternatively by writing a service that detects the KEY_POWER as an input and shuts the system down.
Setting up a Desktop Environment
To set up a desktop environment, please follow our guide, Configuring NoMachine for Headless Carriers. Once a desktop environment has been successfully setup, you should be able to use the P13 connector to both shutdown and wake up the module. Note, after the successful setup of your environment you will not need to access it further, its just the initial configuration that will activate the input.
Writing a Power Service
If configuring a desktop environment is not an option for you, an alternate method to activate the shutdown capabilities of the P13 connector is to write a power service.
-
Setup
$ sudo su$ apt update$ apt install evtest -
Confirm the keycode by running
$ showkeyand then shorting the P13 connector pins-
Example:
$ showkey
kb mode was ?UNKNOWN?
[ if you are trying this under X, it might not work
since the X server is also reading /dev/console ]
press any key (program terminates 10s after last keypress)...
keycode 116 press
keycode 116 release
In this example, the keycode is 116. - Please note, the contents of the powerkey-shutdown.sh file references keycode 116, if you find you need to reference a different code, please update the file.
-
Example:
-
Write the powerkey-shutdown.sh script into /usr/local/bin/ directory with
$ vim /usr/local/bin/powerkey-shutdown.shand paste the following contents:#!/bin/bash DEVICE="/dev/input/event0" # <-- Change to correct device from evtest (Step 7) # Listen for keycode 116 event evtest "$DEVICE" | while read line; do echo "$line" | grep -q "code 116 (KEY_POWER), value 1" # <-- Change to correct keycode from showkey (Step 2) if [ $? -eq 0 ]; then sync sleep 5 /sbin/shutdown -h now fi done -
Make it executable with
$ chmod +x /usr/local/bin/powerkey-shutdown.sh -
Write powerkey.service into /etc/systemd/system/ directory with
$ vim /etc/systemd/system/powerkey.serviceand paste the following contents:[Unit] Description=Shutdown on gpio-keys KEY_POWER press After=multi-user.target [Service] ExecStart=/usr/local/bin/powerkey-shutdown.sh Restart=always RestartSec=1 StandardOutput=journal StandardError=journal [Install] WantedBy=multi-user.target -
Enable this service:
$ systemctl enable --now powerkey.service -
Confirm the powerkey-shutdown script is accessing the correct device with
$ evtest-
Look for an event called "gpio-keys" & then test KEY_POWER on that event by running
$ evtest /dev/input/event<x>and shorting the P13 connector pins-
Example:
$ evtest /dev/input/event0
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-keys"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 116 (KEY_POWER)
Event code 142 (KEY_SLEEP)
Event code 257 (BTN_1)
Properties:
Testing ... (interrupt to exit)
Event: time 1763660405.989636, type 1 (EV_KEY), code 116 (KEY_POWER), value 1
Event: time 1763660405.989636, -------------- SYN_REPORT ------------
Event: time 1763660407.215580, type 1 (EV_KEY), code 116 (KEY_POWER), value 0
Event: time 1763660407.215580, -------------- SYN_REPORT ------------
-
Example:
- Please note, the contents of the powerkey-shutdown.sh file references /dev/input/event0, if you find you need to reference a different event, please update the file
-
Look for an event called "gpio-keys" & then test KEY_POWER on that event by running