hyx0329 / openstick-failsafe-guard

a bunch of systemd services for MSM8916 devices running debian
20 stars 5 forks source link

[FAILED] Failed to start OpenStick Button Monitor Service. #3

Closed RayPS closed 1 year ago

RayPS commented 1 year ago

开机启动过程:

...
...
         Starting Hostname Service...
[  OK  ] Finished Load/Save Random Seed.
[  OK  ] Started OpenBSD Secure Shell server.
[  OK  ] Started Dispatcher daemon for systemd-networkd.
[  OK  ] Reached target Multi-User System.
[  OK  ] Listening on Load/Save RF …itch Status /dev/rfkill Watch.
[  OK  ] Stopped OpenStick Button Monitor Service.
[  OK  ] Started OpenStick Button Monitor Service.
[  OK  ] Started Hostname Service.
         Starting Load/Save RF Kill Switch Status...
[  OK  ] Started Load/Save RF Kill Switch Status.
[  OK  ] Reached target Bluetooth.
         Starting Network Manager Script Dispatcher Service...
[  OK  ] Stopped OpenStick Button Monitor Service.
[  OK  ] Started OpenStick Button Monitor Service.
[  OK  ] Started Network Manager Script Dispatcher Service.
[  OK  ] Stopped OpenStick Button Monitor Service.
[  OK  ] Started OpenStick Button Monitor Service.
[  OK  ] Stopped OpenStick Button Monitor Service.
[FAILED] Failed to start OpenStick Button Monitor Service.
See 'systemctl status openstick-button-monitor.service' for details.
[    9.274643] l13: voltage operation not allowed
[  OK  ] Started ADB Daemon.

systemctl status openstick-button-monitor.service:

● openstick-button-monitor.service - OpenStick Button Monitor Service
     Loaded: loaded (/lib/systemd/system/openstick-button-monitor.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2023-03-02 20:58:07 CST; 1 months 24 days ago
    Process: 336 ExecStart=/usr/bin/systemd-inhibit --what=handle-reboot-key --who=OpenStick Button Monitor Servic
e --why=Take over KEY_RESET /usr/sbin/openstick-button-monitor.sh (code=exited, status=1/FAILURE)
   Main PID: 336 (code=exited, status=1/FAILURE)

3月 02 20:58:07 UFI-Ubuntu systemd[1]: openstick-button-monitor.service: Scheduled restart job, restart counter is
 at 5.
3月 02 20:58:07 UFI-Ubuntu systemd[1]: Stopped OpenStick Button Monitor Service.
3月 02 20:58:07 UFI-Ubuntu systemd[1]: openstick-button-monitor.service: Start
 request repeated too quickly.
3月 02 20:58:07 UFI-Ubuntu systemd[1]: openstick-button-monitor.service: Faile
d with result 'exit-code'.
3月 02 20:58:07 UFI-Ubuntu systemd[1]: Failed to start OpenStick Button Monitor Service.

遇到这个问题,Button Monitor 服务无法启动,使用的是 @wu17481748 的 UFI-Ubuntu20.40。 另外问一下,如果我想设置短按的动作,是不是只需要定义PRESS_ACTION_SHORT环境变量就可以了呢? 感谢

hyx0329 commented 1 year ago

button monitor 有一些依赖,脚本可以直接在前台运行,看看有什么错误提示。有没有缺程序,比如 stdbufhexdump 之类。

关于设置短按动作,设置所需的 PRESS_ACTION_SHORT 变量即可,修改长按动作则对应修改 PRESS_ACTION_LONG。该环境变量的内容会直接当成 sh 环境下的命令运行。

另外看了你给的系统链接。常规流程下修改systemd服务脚本(包括其定义的环境变量)的方法是用 systemd edit 服务名称.service,然后写下需要覆盖的内容。这样软件包更新后也会保留用户做出的修改。

RayPS commented 1 year ago

感谢解答,button monitor 是否对固件有一定要求呢?例如设备树之类的

hyx0329 commented 1 year ago

button monitor 是否对固件有一定要求呢?例如设备树之类的

对设备树有一定要求,需要确实配置一个gpio button,并且按下时的keycode是408(RESET)。最初适配的设备树就包括了这个按钮,所以大多数情况下应该没问题。

不过如果有需要,按钮(输入事件来源)和keycode都可以按需修改,分别通过变量 EV_INPUTEV_KEY_CODE。如果想知道自己按下的按钮输出的是哪个keycode,可以使用 evtest 这个工具。

此外,如果你解决了之前的问题,我建议将你的解决方案以某种形式(回复,修改)添加到这个issue中,可供他人参考。

hyx0329 commented 1 year ago

assume resolved

RayPS commented 1 year ago

抱歉,前几天有点事情没有继续跟进。 我今天尝试重新使用 evtestevemu-toolslibinput-toolskbd 等工具都无法测试到按钮的事件,也许是我的方法有误? 我的板子型号是:UFI001C 系统:OpenStick/OpenStick

$ 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 Buttons"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 408 (KEY_RESTART)
Key repeat handling:
  Repeat type 20 (EV_REP)
    Repeat code 0 (REP_DELAY)
      Value    250
    Repeat code 1 (REP_PERIOD)
      Value     33
Properties:
Testing ... (interrupt to exit)
hyx0329 commented 1 year ago

我今天尝试重新使用 evtestevemu-toolslibinput-toolskbd 等工具都无法测试到按钮的事件

按钮有效的前提是设备树配置的按钮GPIO对应于实际硬件的GPIO,此后按下按钮便会产生对应事件。不同设备配置不同,已知001C和003的按钮是一样的。另需注意,那个按钮普遍配置为重启按钮,若你没inhibit这个动作,systemd会在你按下按钮的同时重启你的设备。

我翻了翻以前改的设备树,001C的按钮相关设备树内容大致如下(由dtb转换而来,源码丢了),供你参考。

gpio-keys {
    compatible = "gpio-keys";
    #address-cells = <0x01>;
    #size-cells = <0x00>;
    autorepeat;
    pinctrl-names = "default";
    pinctrl-0 = <0x94>;
    label = "GPIO Buttons";

    reset {
        label = "Restart";
        gpios = <0x3d 0x25 0x00>;
        linux,code = <0x198>;
    };
};

另外,记忆中你所使用的系统所配备的设备树有一些小错误。尽管印象里那些错误不影响使用,但还请注意一下。

RayPS commented 1 year ago

感谢解答,目前基本上可以判断我这几天测试过的多个版本固件都没有对按钮设备树进行修改导致 button-monitor 失效。 无奈我对设备树以及固件编译没有任何经验,这个 issue 我暂时关闭,后面有机会我会尝试让它工作起来并把过程补充在这里。 以下是一些有用的资料:

hyx0329 commented 1 year ago

搬运一下我在别的地方发布的系统。有点老了,不过够拿来学习交流。希望能帮到你。适用于UFI001C和UFI003。