Skip to content

Commit 2b21aad

Browse files
committed
Add systemd hooks for MCU power state notifications from userspace
Signed-off-by: Alexey Charkov <alchark@flipper.net>
1 parent 488dea7 commit 2b21aad

7 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
case "$1" in
3+
pre) echo suspend-request > /sys/bus/i2c/drivers/flipper-one-mcu/*/cpustate ;;
4+
esac
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=Report boot completion to the Flipper One MCU
3+
After=multi-user.target
4+
5+
[Service]
6+
Type=oneshot
7+
RemainAfterExit=yes
8+
ExecStart=/bin/sh -c 'echo online > /sys/bus/i2c/drivers/flipper-one-mcu/*/cpustate'
9+
10+
[Install]
11+
WantedBy=multi-user.target
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=Report imminent power-off to the Flipper One MCU
3+
DefaultDependencies=no
4+
Before=shutdown.target
5+
6+
[Service]
7+
Type=oneshot
8+
ExecStart=/bin/sh -c 'echo poweroff-request > /sys/bus/i2c/drivers/flipper-one-mcu/*/cpustate'
9+
10+
[Install]
11+
WantedBy=poweroff.target
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=Report imminent reboot to the Flipper One MCU
3+
DefaultDependencies=no
4+
Before=shutdown.target
5+
6+
[Service]
7+
Type=oneshot
8+
ExecStart=/bin/sh -c 'echo reboot-request > /sys/bus/i2c/drivers/flipper-one-mcu/*/cpustate'
9+
10+
[Install]
11+
WantedBy=reboot.target
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/systemd/system/flipper-one-online.service
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/systemd/system/flipper-one-poweroff.service
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/systemd/system/flipper-one-reboot.service

0 commit comments

Comments
 (0)