RainCat1998 / Bli-PiKVM

Install Pi-KVM on BliKVM v4 Allwinner.
GNU General Public License v3.0
35 stars 1 forks source link

LED-PWR and LED-HDD Support #2

Closed blazer221 closed 1 month ago

blazer221 commented 4 months ago

Hello, First of all great project, it seems to be working flawlessly so far. One thing i didn't find a way to make it work is showing the HDD and Power indications which are on GPIO 9 for HDD and GPIO 10 for Power according to blicube website for Allwiner device, is there a possibility this functionality to be added also?

RainCat1998 commented 2 months ago

Yes. You can do it by editing the GPIO config file(/etc/kvmd/override.d/atx.yaml). Here is an example.

kvmd:
    gpio:
        scheme:
            on-off-button:
                pin: 228
                mode: output
                switch: false
                pulse:
                    delay: 0.5
                    max_delay: 2
            force-off-button:
                pin: 228
                mode: output
                switch: false
                pulse:
                    delay: 3
                    max_delay: 5
            reset-button:
                pin: 272
                mode: output
                switch: false
                pulse:
                    delay: 0.5
                    max_delay: 2
            power-led:
                pin: 234
                mode: input
            hdd-led:
                pin: 233
                mode: input

        view:
            table:
                - []
                - ["#ATX on BliKVM hardware", "power-led|green", "hdd-led|yellow"]
                - []
                - ["on-off-button|confirm|On/Off", "force-off-button|confirm|Force Off", "reset-button|confirm|Reset"]
davidcoulson commented 2 months ago

When I use this atx.yaml (vs the one in the README) I get the following errors when kvmd starts up.


Aug 31 15:25:05 unraid-pikvm systemd[1]: Started PiKVM - The main daemon.
░░ Subject: A start job for unit kvmd.service has finished successfully
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit kvmd.service has finished successfully.
░░
░░ The job identifier is 1377.
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.apps.kvmd                    INFO --- Using internal auth service 'htpasswd'
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.plugins.msd.otg              INFO --- Using OTG gadget 'kvmd' as MSD
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.plugins.msd.otg              INFO --- Probing to remount storage ...
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.plugins.msd.otg.storage      INFO --- Remounting MSD storage to RW: /usr/bin/sudo --non-interactive /usr/bin/kvmd-helper-otgmsd-remount rw ...
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- Executing helper ['/usr/bin/sudo', '--non-interactive', '/usr/bin/kvmd-helper-otgmsd-remount', 'rw'] ...
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- => Remounting /var/lib/kvmd/msd to RW-mode ...
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- => Storage in the RW-mode now
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.plugins.msd.otg.storage      INFO --- Remounting MSD storage to RO: /usr/bin/sudo --non-interactive /usr/bin/kvmd-helper-otgmsd-remount ro ...
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- Executing helper ['/usr/bin/sudo', '--non-interactive', '/usr/bin/kvmd-helper-otgmsd-remount', 'ro'] ...
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- => Remounting /var/lib/kvmd/msd to RO-mode ...
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- => Storage in the RO-mode now
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: kvmd.keyboard.keysym              INFO --- Reading keyboard layout /usr/share/kvmd/keymaps/en-us ...
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: kvmd.apps.kvmd.ugpio              INFO --- Preparing User-GPIO drivers ...
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: Traceback (most recent call last):
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:   File "/usr/bin/kvmd", line 8, in <module>
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:     sys.exit(main())
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:   File "/usr/lib/python3/dist-packages/kvmd/apps/kvmd/__init__.py", line 75, in main
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:     KvmdServer(
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:   File "/usr/lib/python3/dist-packages/kvmd/apps/kvmd/server.py", line 263, in run
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:     comp.sysprep()
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:   File "/usr/lib/python3/dist-packages/kvmd/apps/kvmd/ugpio.py", line 294, in sysprep
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:     driver.prepare()
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:   File "/usr/lib/python3/dist-packages/kvmd/plugins/ugpio/gpio.py", line 89, in prepare
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:     line.request("kvmd::gpio::outputs", gpiod.LINE_REQ_DIR_OUT, default_vals=[int(initial or False)])
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: OSError: [Errno 16] Device or resource busy
RainCat1998 commented 2 months ago

When I use this atx.yaml (vs the one in the README) I get the following errors when kvmd starts up.


Aug 31 15:25:05 unraid-pikvm systemd[1]: Started PiKVM - The main daemon.
░░ Subject: A start job for unit kvmd.service has finished successfully
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit kvmd.service has finished successfully.
░░
░░ The job identifier is 1377.
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.apps.kvmd                    INFO --- Using internal auth service 'htpasswd'
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.plugins.msd.otg              INFO --- Using OTG gadget 'kvmd' as MSD
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.plugins.msd.otg              INFO --- Probing to remount storage ...
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.plugins.msd.otg.storage      INFO --- Remounting MSD storage to RW: /usr/bin/sudo --non-interactive /usr/bin/kvmd-helper-otgmsd-remount rw ...
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- Executing helper ['/usr/bin/sudo', '--non-interactive', '/usr/bin/kvmd-helper-otgmsd-remount', 'rw'] ...
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- => Remounting /var/lib/kvmd/msd to RW-mode ...
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- => Storage in the RW-mode now
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.plugins.msd.otg.storage      INFO --- Remounting MSD storage to RO: /usr/bin/sudo --non-interactive /usr/bin/kvmd-helper-otgmsd-remount ro ...
Aug 31 15:25:08 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- Executing helper ['/usr/bin/sudo', '--non-interactive', '/usr/bin/kvmd-helper-otgmsd-remount', 'ro'] ...
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- => Remounting /var/lib/kvmd/msd to RO-mode ...
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: kvmd.aiohelpers                   INFO --- => Storage in the RO-mode now
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: kvmd.keyboard.keysym              INFO --- Reading keyboard layout /usr/share/kvmd/keymaps/en-us ...
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: kvmd.apps.kvmd.ugpio              INFO --- Preparing User-GPIO drivers ...
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: Traceback (most recent call last):
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:   File "/usr/bin/kvmd", line 8, in <module>
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:     sys.exit(main())
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:   File "/usr/lib/python3/dist-packages/kvmd/apps/kvmd/__init__.py", line 75, in main
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:     KvmdServer(
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:   File "/usr/lib/python3/dist-packages/kvmd/apps/kvmd/server.py", line 263, in run
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:     comp.sysprep()
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:   File "/usr/lib/python3/dist-packages/kvmd/apps/kvmd/ugpio.py", line 294, in sysprep
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:     driver.prepare()
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:   File "/usr/lib/python3/dist-packages/kvmd/plugins/ugpio/gpio.py", line 89, in prepare
Aug 31 15:25:09 unraid-pikvm kvmd[2340]:     line.request("kvmd::gpio::outputs", gpiod.LINE_REQ_DIR_OUT, default_vals=[int(initial or False)])
Aug 31 15:25:09 unraid-pikvm kvmd[2340]: OSError: [Errno 16] Device or resource busy

Sorry, I have missed something. The blikvm_server occupied these GPIO ports. Here is the full instruction.

RainCat1998 commented 2 months ago
  1. build kvm-main with these lines commented. (blikvm/src/blikvm_server.c) https://github.com/ThomasVon2021/blikvm
    //3. init atx module
        /*
        if(blikvm_atx_init() == 0)
        {
            BLILOG_D(TAG,"init atx success\n");
        }
        else
        {
            BLILOG_E(TAG,"init atx failed\n");
        }
        */

    make H616=1 ST7789=1 mv ./src/kvmd-main /usr/bin/blikvm/

  2. vi /etc/kvmd/override.d/atx.yaml

    kvmd:
    gpio:
        scheme:
            on-off-button:
                pin: 228
                mode: output
                switch: false
                pulse:
                    delay: 0.5
                    max_delay: 2
            force-off-button:
                pin: 228
                mode: output
                switch: false
                pulse:
                    delay: 3
                    max_delay: 5
            reset-button:
                pin: 272
                mode: output
                switch: false
                pulse:
                    delay: 0.5
                    max_delay: 2
            power-led:
                pin: 234
                mode: input
            hdd-led:
                pin: 233
                mode: input
    
        view:
            table:
                - []
                - ["#ATX on BliKVM hardware", "power-led|green", "hdd-led|yellow"]
                - []
                - ["on-off-button|confirm|On/Off", "force-off-button|confirm|Force Off", "reset-button|confirm|Reset"]
  3. reboot
davidcoulson commented 2 months ago

Great - That works!!

Is there a way to update the kernel on the H616, or is there something custom that requires it to be held back?

blazer221 commented 1 month ago

Thank you @RainCat1998, the main thing i was missing was the code that needs comment in blikvm_server.c, now everything works fine!