User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Pi400 KVM switch

Mon Oct 18, 2021 3:16 pm

This thread is followup on KVS (Keyboard Video Switch) work in Pi400 keyboard thread, where I added R+IRLED to Philip's (Gadgetoid) pi400kb (gist at that time):
viewtopic.php?f=140&t=295074&start=50#p1924474

4 days ago Philip created an enhancement issue "Simultaneous mouse support" based on my request:
https://github.com/Gadgetoid/pi400kb/issues/1
That repo allows to switch Pi400 keyboard and connected Raspberry mouse between Pi400 and computer Pi400 is connected to as USB gadget (laptop in my case).

After I figured out problems on my side, since a few hours I use fully functional KVM switch (Keyboard Video Mouse):
https://en.wikipedia.org/wiki/KVM_switch
Image
The difference to KVM switch hardware is, that Pi400 KVM switch can only switch between Pi400 and computer connected to as USB gadget.

The R+IRled added to P400, pi400kb, CTRL_ALT_Q.c and irplay make Pi400 KVM switch:
GraphvizFiddle link
pi400.KVM.FSM_.png
pi400.KVM.FSM_.png
pi400.KVM.FSM_.png (16.8 KiB) Viewed 49432 times
Pi400 with R+IRled, Raspberry mouse and IR HDMI switch:
20211018_105303.15%.jpg
20211018_105303.15%.jpg
20211018_105303.15%.jpg (53.02 KiB) Viewed 49428 times
How to build:
  1. solder 100Ω resistor to IRled and connect to pins 37+39 (GPIO26+GND)
  2. clone "feature/mouse-support" branch of Philip's now github repo, and build according instructions, and finally copy pi400kb to /usr/local/bin
    https://github.com/Gadgetoid/pi400kb/tr ... se-support
  3. clone keybinder repo and build
    https://github.com/kupferlauncher/keybinder
  4. copy CTRL_ALT_Q.c gist over keybinder/examples/main.c and do "make main". Finally copy main to /usr/bin/CTRL_ALT_Q:
    https://gist.github.com/Hermann-SW/033a ... bc408e18ad
  5. copy irplay gist to /usr/local/bin
    https://gist.github.com/Hermann-SW/7e95 ... 5f12312730
    It will work out-of-the-box with this 3-in 2-out HDMI switch with IR control:
    https://www.amazon.de/gp/product/B07KGN ... asin_title
    In case you use different HDMI switch with IR control, you need to record both relevant keys with irrp.py script (http://abyz.me.uk/rpi/pigpio/code/irrp_py.zip) and place recorded JSON file into /usr/local/bin/irplay.
  6. add this to LXDE autostart:

    Code: Select all

    pi@raspberrypi400:~ $ tail -1 /etc/xdg/lxsession/LXDE-pi/autostart 
    @CTRL_ALT_Q
    pi@raspberrypi400:~ $ 
    
  7. power Pi400 via USB-A to USB-C cable from laptop, after reboot CTRL+SHIFT+RASPBERRY and CTRL+ALT-+Q shortcuts will toggle between Pi400 and laptop

P.S:
Philip's feature/mouse-support branch allows to use other than Raspberry mice as well, will try later with my Logitech MX Ergo trackball.
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Tue Oct 19, 2021 9:41 pm

Philip (Gadgetoid) created new feature/toggle-hook branch based on feature/mouse-support branch.
Using that branch eliminates need for keybinder repo and CTRL_ALT_Q.c.

The R+IRled added to P400, pi400kb ̶,̶ ̶C̶T̶R̶L̶_̶A̶L̶T̶_̶Q̶.̶c̶ ̶ and irplay make Pi400 KVM switch:
GraphvizFiddle link
pi400.KVM.FSM_2.png
pi400.KVM.FSM_2.png
pi400.KVM.FSM_2.png (21.55 KiB) Viewed 49349 times
How to build:
  1. solder 100Ω resistor to IRled and connect to pins 37+39 (GPIO26+GND)
  2. clone "feature/toggle-hook" branch of Philip's now github repo, and build with "cmake -DHOOK_PATH=/usr/local/bin/hook.sh .." and finally copy pi400kb to /usr/local/bin
  3. store this file:

    Code: Select all

    pi@raspberrypi400:~ $ cat /usr/local/bin/hook.sh 
    #!/bin/bash
    # irplay example pi400kb hook
    # This script is given the argument 1 for grabbed, 0 for ungrabbed.
    case $1 in
        0) # Ungrabbed
    	irplay 1
            ;;
        1) # Grabbed
    	irplay 3
            ;;
    esac
    pi@raspberrypi400:~ $ 
  4. create this file:

    Code: Select all

    pi@raspberrypi400:~ $ cat /usr/local/bin/pi400kb_ 
    #!/bin/bash
    sudo pi400kb
    pi@raspberrypi400:~ $ 
  5. copy irplay gist to /usr/local/bin
    https://gist.github.com/Hermann-SW/7e95 ... 5f12312730
    It will work out-of-the-box with this 3-in 2-out HDMI switch with IR control:
    https://www.amazon.de/gp/product/B07KGN ... asin_title
    In case you use different HDMI switch with IR control, you need to record both relevant keys with irrp.py script (http://abyz.me.uk/rpi/pigpio/code/irrp_py.zip) and place recorded JSON file into /usr/local/bin/irplay.
  6. add this to LXDE autostart:

    Code: Select all

    pi@raspberrypi400:~ $ tail -1 /etc/xdg/lxsession/LXDE-pi/autostart 
    @pi400kb_
    pi@raspberrypi400:~ $ 
    
  7. power Pi400 via USB-A to USB-C cable from laptop, after reboot CTRL+RASPBERRY shortcut toggles between Pi400 and laptop

P.S:
"pi400kb_" restart edge added:
GraphvizFiddle link
Screenshot_20211020-053102_Firefox.jpg
Screenshot_20211020-053102_Firefox.jpg (46.98 KiB) Viewed 49312 times

P.P.S:
Short video of earlier KV switch in action:
https://www.youtube.com/shorts/6ileUBkbgDM
Attachments
Pi400.KV[M].switch.png.25%.jpg
Pi400.KV[M].switch.png.25%.jpg
Pi400.KV[M].switch.png.25%.jpg (5.32 KiB) Viewed 48893 times
Last edited by HermannSW on Sun Oct 31, 2021 10:31 am, edited 3 times in total.
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

RedMarsBlueMoon
Posts: 501
Joined: Mon Apr 06, 2020 3:49 am

Re: Pi400 KVM switch

Fri Oct 22, 2021 7:06 pm

Hi this seems very intersting!
I'm trying to figure out if there's a way I can combine Keyboard+Mouse signal to be output from a Raspberry (Zero W) single USB port, to be plugged into a (or two) PC usb and the PC recognizing it as the two devices, kb and mouse.

Does this project (or part of it) do that, do you know?

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Fri Oct 22, 2021 8:44 pm

RedMarsBlueMoon wrote:
Fri Oct 22, 2021 7:06 pm
Hi this seems very intersting!
I'm trying to figure out if there's a way I can combine Keyboard+Mouse signal to be output from a Raspberry (Zero W) single USB port, to be plugged into a (or two) PC usb and the PC recognizing it as the two devices, kb and mouse.

Does this project (or part of it) do that, do you know?
Gadgetoid added mouse support. So my Pi400 keyboard as well as Raspberry mouse connected to Pi400 appear as USB mouse and USB keyboard to the PC Pi400 is powered over USB as USB gadget.

For another posting I try to clarify whether pi400kb can be used with Pi4B as well (should be):
https://github.com/Gadgetoid/pi400kb/issues/12

For a Pi0[W] you have to use the USB to connect to PC, so USB multiplier is needed.
I just work with 3-USB port with ethernet for the Pi0W:
20211022_223015.10%.jpg
20211022_223015.10%.jpg
20211022_223015.10%.jpg (28.68 KiB) Viewed 49199 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

RedMarsBlueMoon
Posts: 501
Joined: Mon Apr 06, 2020 3:49 am

Re: Pi400 KVM switch

Fri Oct 22, 2021 9:58 pm

Cool thanks I supscribed to that thread.
Are you trying to control the PC with the Pi?
Or the Pi with the PC?

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Fri Oct 22, 2021 11:30 pm

I use Pi400 keyboard and Raspberry mouse for Pi400 as well as laptop. Pressing CTRL+RASPBERRY switches which computer is controlled, and via the IRled the HDMI display as well. See the state diagram in 2nd posting.
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

RedMarsBlueMoon
Posts: 501
Joined: Mon Apr 06, 2020 3:49 am

Re: Pi400 KVM switch

Tue Oct 26, 2021 9:44 pm

I'm not an engineer so will probably not be ble to do much with these but I thought the info seemed relevant so I'll just reply with some links I found,

https://lekensteyn.nl/logitech-unifying.html
https://git.lekensteyn.nl/ltunify/

I'will read through this anyway and see if I can use it somehow.

Update: There might actually be ready made solutions for what I wanted to try, Or actually, in my case I'd need to emulate the kb+m and send to the receiver. So maybe I look closer at the software above.
https://askubuntu.com/questions/113984/ ... -supported
and
https://www.amazon.com/Logitech-Unifyin ... 134&sr=8-1

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Wed Oct 27, 2021 6:18 pm

I just did a short experiment, connected Logitech unifying receiver into Pi400 and used Logitech K400+ wireless keyboard with touchpad.
No problem on the Pi400, touchpad as well as keyboard work.
But when I switch to laptop with CTRL+RASPBERRY, neither keyboard nor touchpad work with pi400kb.
Reason is that pi400kb needs to be compiled for the respective HID descriptors.
I created an issue on using unifying receiver, Gadgetoid is working on that:
https://github.com/Gadgetoid/pi400kb/issues/12
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Wed Dec 01, 2021 8:42 pm

I am working more than 10 hours with Pi400 every workday, and many hours on the weekends as well. 8 hours on workday for "work from home" on the laptop, and for personal Raspberry stuff on the Pi400.

Sometimes pressing CTRL+RASPBERRY switches keyboard+mouse, but not the display. There were two reasons for this, either a cable or something else between IR led and HDMI switch IR receiver, or the IR led went out too far outside of two female headers. Both are easy to fix, press CTRL+RASPBERRY to get control back on the displayed computer, then free space and/or put IR led back into female headers and finally press CTRL+RASPBERRY again.

Two times in the last 34 days I was able to switch display+mouse+keyboard, but Pi400 was "out of control". Nothing worked, pressing keys, ALT+TAB to switch active window, mouse button presses. Switching back to laptop worked fine. I had to power cycle the Pi400 in both cases and all was fine again. What I find remarkable is, that a Pi400 in the state described, with need to power cycle, still worked as KVM switch.
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Sat Feb 05, 2022 8:46 pm

I did use Pi400 KVM switch another 2 months daily, without issues.
Yesterday I did install new 64bit PiOS on SSD connected to Pi400, and 32bit freecad crash problems disappeared:
viewtopic.php?t=327114#p1969703
So I wanted to make 64bit PiOS a KVM switch as well.
I cloned "feature/toggle-hook" branch:
https://github.com/Gadgetoid/pi400kb/tr ... oggle-hook
Before building I had to do one diff:

Code: Select all

...
 if(NOT HOOK_PATH)
-    set(HOOK_PATH "/home/pi/pi400kb/hook.sh" CACHE STRING "Path to .sh toggle hook")
+    set(HOOK_PATH "/usr/local/bin/hook.sh" CACHE STRING "Path to .sh toggle hook")
 endif()
...

For some reason modprobing libcomposite within pi400kb.c does not work on 64bit PiOS.
I have not figured out the reason yet, and so used this slightly modified file as workaround:

Code: Select all

$ cat /usr/local/bin/pi400kb_ 
#!/bin/bash
sudo modprobe libcomposite
sudo pi400kb
$

Now "Pi400 KVM switch" works on 64bit (SSD) "side" of my Pi400 as well, nice.
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Wed Feb 16, 2022 1:09 am

Because of the right side Pi400 case I just 3Dprinted, the IRled needs to be removable (for transport):
viewtopic.php?p=1974335#p1974335
20220216_015103.16pc.jpg
20220216_015103.16pc.jpg
20220216_015103.16pc.jpg (40.06 KiB) Viewed 48105 times

Instead of superglueing the IRled holder onto Pi400 case as before, I did put a small drop of superglue on the end of the two headers. Superglueing IRled holder there makes the whole thing removable, while still working:
20220216_020255.16%.jpg
20220216_020255.16%.jpg
20220216_020255.16%.jpg (42.8 KiB) Viewed 48105 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Thu May 26, 2022 8:55 am

After a move from secondary living place to home yesterday, the IRled was lost.
I worked without, but having to use HDMI switch remote control or button on HDMI switch after pressing CTRL+RASPBERRY was not fun.

Today I searched for infrared LED, and only found red, green and many ultraviolet ones.
But then I remembered IR obstacle avoidance sensors I bought back in 2016.
I cannibalized IRled from one sensor, and although the legs are quite short, the IRled works fine.
I used this command line for LED inspection:

Code: Select all

sudo pigpiod; while true; do pigs w 26 0; sleep 1; pigs w 26 1; sleep 1; done

When I could see nothing, it was an IRled candidate, I discovered one bad LED that way.
Photo confirms that cannibalized IRled is working (which is confirmed by CTRL+RASPBERRY switching display again as well):
20220526_103754.20%.jpg
20220526_103754.20%.jpg
20220526_103754.20%.jpg (30.14 KiB) Viewed 47047 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Sat Oct 22, 2022 7:33 am

I use pi400 KVM switch for a year now. Everything is fine, and I like it.
Gadgetoid's repo has seen last commit in February, and suport for mice other than Raspberry mouse has not been added.
https://github.com/Gadgetoid/pi400kb/
But the repo is good as it is, I work with Pi400 (keyboard) and Raspberry mouse all the time.
I use my Logitech trackball for other computers.

Issues seen rarely:
  1. Mouse stops working on Pi400 side, toggling display works, as well as mouse for laptop
    I ssh into the Pi400 and kill pi400kb process, then start pi400kb_ in terminal window and continue.
  2. Mouse stops working on laptop side:
    First I remove mouse from USB2 port of Pi400 and reinsert, that mostly fixes the issue.
    If that does not work, I put it into USB3 port of Pi400.
    Only if that does not work, I kill pi400kb process and start pi400kb_ in terminal window and continue.
  3. Seen two times only in 1 year, mouse and keyboard stop working:
    I remove USB cable at laptop that powers the Pi400 and reinsert it. Then I use HDMI switch remote control to toggle to Pi400 HDMI and see the boot messages on Pi400, and continue.

This is photo just taken, same setup as before.
The USB SSD of Pi400 is vertical, and fixated by a flat 2x1 Lego piece superglued to laptop bottom:
20221022_082903.part.jpg
20221022_082903.part.jpg
20221022_082903.part.jpg (124.42 KiB) Viewed 46259 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Mon Nov 07, 2022 7:30 am

I got a new laptop which is few centimeters wider than the old. Unfortunately they used it to have a numeric keypad right of normal keyboard, which I am not used to have. Luckily using Pi400 as KVM switch hides the numerical keypad, and if in office I use an external keyboard, so no big deal.

New laptop has HDMI slot on left side, and the short HDMI cable I have to connect HDMI switcher 2nd input to it is a bit short, so that all is a bit stiff now (HDMI switcher needs to be near the IRled connected to Pi400 GPIO). Will replace it with longer cable and all should be fine again.

Unlike the old laptop, which had a higher area at the end (lipos?) and therefore had no flat surface, new T15 has flat surface and glueing small Lego piece for fixation of Pi400 USB SSD is no option because sometimes I will use the laptop alone. Will have to 3Dprint a part fixating the SSD which can be removed from T15 bottom and reinserted.
20221107_080704.part.33%.jpg
20221107_080704.part.33%.jpg
20221107_080704.part.33%.jpg (32.39 KiB) Viewed 45954 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Thu Nov 17, 2022 12:24 pm

In the last week Raspberry mouse had often problems, so that I had to switch to my Logitech Ergo MX trackball.
But since pi400kb is only able to deal with Raspberry mouse currently, I had to move trackball dongle from Pi400 to laptop and back, everytime I pressed CTRL-RASPBERRY to switch keyboard and display. Two days ago I ordered a new (7.90€+ship) Raspberry mouse which arrived today. Works fine, and feels really good — the old mouse was used more than a year >10h a day and long before that time often as well. Now KVM switch works fine again.
pi400.kvm.new_raspberry_mouse.png
pi400.kvm.new_raspberry_mouse.png
pi400.kvm.new_raspberry_mouse.png (220.43 KiB) Viewed 43686 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Wed Jan 18, 2023 9:07 am

I am still happy with the mouse.

I got a new 22" display as Christmas present, and my sons removed my old display construction and fixated display on the wall with professional mount. And they insisted that laptop has to stay on desk normally, so that it can be used as 2nd display. Works well when laptop is active, when switching to Pi400 use, display shows Pi400 and laptop still shows its content.

Lately the IR signal to HDMI switch did not always work. Now that I have more room I decided to move the HDMI switch away from between Pi400 and laptop. Inserting two pairs of 20cm Dupont lines and the IRled construction moved near the HDMI switch, where it is fixated by the HDMI switch IR remote control (that does not have a function because the switching is done by CTRL+RASPBERRY press):
20230118_094230.part2.200%.jpg
20230118_094230.part2.200%.jpg
20230118_094230.part2.200%.jpg (12.86 KiB) Viewed 32066 times

The new placement allows for more fexibility, easier to move keyboard a bit around if needed:
20230118_094230.part1.33%.jpg
20230118_094230.part1.33%.jpg
20230118_094230.part1.33%.jpg (36.63 KiB) Viewed 32066 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Wed Jan 18, 2023 12:50 pm

Our younger son called me wrt a Python issue for his bachelor thesis.
At the end of the call I pointed him to previous posting, all he said was:
Too much visible cables.
He proposed to lift the laptop and stuff everything below.

First I thought on 3D printing a laptop stand. Then I decided to prototype with Lego pieces. Finally I found 4 parts from a plastic shelf I used to lift laptop by 5cm. And really everything fits below the laptop.

You see laptop with open display this time, and Pi400 display on top.
vncviewer session to 2GB Pi4B with v2 camera allows to work with camera and preview.
vncviewer is performant enough, laptop and PIs connected to 1Gbps switch, with 1Gbps internet connectivity.
Pi400 cables from left to right:
Ethernet, red Raspberry mouse USB cable, USB3 cable to external SSD, USB cable to power Pi400 and OTG, HDMI cable to HDMI switch, Dupont cables to IRled
20230118_132626.30%.jpg
20230118_132626.30%.jpg
20230118_132626.30%.jpg (41.57 KiB) Viewed 32020 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Wed Jan 18, 2023 5:17 pm

Now that everything works and looks nice, a final 24 second video demonstrating how fast everything gets switched, from laptop (RHEL8) to Pi400 (64bit PiOS) and back:
https://www.youtube.com/shorts/7LuhGhPeybQ
Pi400.KVM_switch.yt.jpg
Pi400.KVM_switch.yt.jpg
Pi400.KVM_switch.yt.jpg (58.29 KiB) Viewed 31923 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Sat Feb 11, 2023 11:43 am

I had to replace Raspberry mouse last November with a newly bought one.
The Pi400 keyboard works still fine, no problems.

For an old computer I did need a physically connected keyboard (my wireless Logitech K400+ keyboard does not allow to enter bios).
So I did "kill two birds with one stone" (*) and bought "Raspberry keyboard and hub" and learned that way it is not a keyboard only:
https://www.raspberrypi.com/products/ra ... d-and-hub/
20230211_122501.33%.jpg
20230211_122501.33%.jpg
20230211_122501.33%.jpg (31.34 KiB) Viewed 28777 times

I will disconnect keyboard top from new keyboard and replace Pi400 keyboard whenever that will be necessary in the future …

(*)
I had to search the web for translation.
In German it is "zwei Fliegen mit einer Klappe schlagen", word-by-word translation: "flap two flies with one flap"
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Wed Jun 28, 2023 7:26 pm

I am still using Pi400 KVM switch on daily basis.
Now a new player entered the scene:
20230628_210210.part.20%.jpg
20230628_210210.part.20%.jpg
20230628_210210.part.20%.jpg (37.7 KiB) Viewed 17506 times
I bought new PC that was maximized for single core performance with not-too-high price. I did choose AMD Ryzen 5 7600X (gaming) CPU, that is rank 18 of Passmark single threaded performance list of 3100+ CPUs (Pi400 Cortex A72 CPU is rank 3513). Complete PC does cost only 619$, but runs single process with 5.306GHz and 6 processes (one on each core) with 5.019GHz. Details here:
https://github.com/Hermann-SW/7600X#details-of-pc

As can be seen in photo I use wireless Logitech K400+ keyboard and Logitech MX Ergo trackball for the new PC.
Handling two mice like shown is no problem.
I have no solution yet to extend the Pi400 KVM solution to be able to work with new PC as well.
(besides "ssh" into new PC from either Pi400 or laptop)
So when working with new PC, Logitech keyboard is in front as in photo.
If working with Pi400 or laptop, I just move Logitech keyboard onto the laptop and use the Pi400 keyboard.

The Pi400 KVM switch toggles display as well when pressing CTRL+RASPBERRY keys, by sending "1" or "3" with the connected IRled to the IR HDMI switcher. I press key "2" on that switcher to display new PC on HDMI monitor (it was a good decision to buy HDMI switcher with 3 inputs long ago). When back to work with Pi400 or laptop I press "1" or "3", and from there CTRL+RASPBERRY.

Not too bad solution for now, but since Pi400 can only be keyboard for laptop because it is powered as USB gadget of the laptop, I do not see how Pi400 keyboard can be new PC keyboard as well.


P.S:
I updated my msieve repo fork runtime table with new 7600X runtimes.
https://github.com/Hermann-SW/msieve#readme

Overclocked with 2.2GHz Pi400 did need 12:07:52h to factor 100 decimal digit number RSA-100.
7600X at 5281MHz did take only 1:32:59h.
So overclocked Pi400 takes 782% of 7600X runtime, standared 1.8GHz Pi400 takes 956% ...


P.P.S:
Price wise, Pi400 unit does cost 70$, and 9.5x faster 7600X PC 619$.
But new PC contains 6 cores, when all run Pi400 uses 9x runtime of each of the 6 cores (956/5300*5000=900%).
Pi400 has 4 cores, that makes 900%*6/4=1350% runtime for compute intensive single core computations, like factoring RSA numbers.
Or 955% for a single process running.
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Thu Jul 13, 2023 9:37 am

HermannSW wrote:
Wed Jun 28, 2023 7:26 pm
...
Now a new player entered the scene:
Image
...
2nd keyboard and trackball eliminated, and new PC moved to other side of room for now, next to 1Gbps switch.

Yes, VNC was the solution, but there were so much problems to find a pairing of Ubuntu VNC server and Raspberry PiOS client that worked AND had no poor performance.

I followed some advice on this page:
https://help.realvnc.com/hc/en-us/artic ... g-on-Linux

First I had to disable Wayland on 7600X PC Ubuntu 22.04 Desktop (no combination of VNC server/client I tried worked with it enabled):

Code: Select all

hermann@7600x:~$ head -7 /etc/gdm3/custom.conf | tail -3
[daemon]
# Uncomment the line below to force the login screen to use Xorg
WaylandEnable=false
hermann@7600x:~$ 

Next I found that x11vnc works best wrt fast display updates as VNC server on Ubuntu side. But that only worked when X server was up, which normally is not the case when running Ubuntu headless. So I enabled automatic login:

Code: Select all

hermann@7600x:~$ head -13 /etc/gdm3/custom.conf | tail -2
AutomaticLoginEnable = true
AutomaticLogin = hermann
hermann@7600x:~$ 

I did not want an unlocked X, so used lightweight "xl" github repo for locking X11 keyboard and mouse:
https://github.com/dannydulai/xl

The best performing client solution I found on the Raspberry side was no vncclient at all ;-) Instead I apt installed "novnc" app. That is a port forwarder on Ubuntu, that connects to VNC server and converts to WebRTC for use in browser. Below you see noVNC connect screen when accessing:

Code: Select all

http://7600x:5800/vnc.html

To make all working automatically I created this file:

Code: Select all

hermann@7600x:~$ cat .xsessionrc 
x11vnc -forever -display :0 -auth guess -passwd passwd &
novnc --listen 5800 --vnc localhost:5900 &
export XLPASSWD=foobar
xl &
hermann@7600x:~$ 
So after connecting to headless started PC in browser with "passwd" password, I have to enter "foobar" and ENTER to terminate xl.

That worked fine, until I powered off the PC and disconnected the HDMI cable before move to new location. A test just showed black screen. Last weekend I bought a 1920x1080 EDID emulator for 6.54$ as mentioned in RealVNC link:
https://www.amazon.de/dp/B07YKGGQTJ?ref ... ct_details
Inserting that into HDMI connector of PC made everything work (PC now thinks a 2K display is connected), see photo on right:
noVNC.10_26min_UPS.66%.plus.png.jpg
noVNC.10_26min_UPS.66%.plus.png.jpg
noVNC.10_26min_UPS.66%.plus.png.jpg (77.83 KiB) Viewed 16194 times

I plan to use the 7600X PC for factoring big numbers (it did factor RSA-140 in just 11.1h sofar), and doing inherently sequential multi months(!) computation. In order to secure such long computation I bought 750W UPS on Primeday with 33% discount for 44.64$:
https://www.amazon.de/dp/B01MYBSF09?psc ... ct_details

I had measured that PC did have low power consumption before, but wanted to know how long PC can continue running without mains power.

I use small Ikea power switch (near clock) to simulate "mains power off", the cable in it is UPS input cable. I had verified that ground lines on both sides of power switch are connected, regardless whether switch state is "1" or "0". That was a precondition for UPS use, always keeping UPS grounded, even in case of power outage.

The power meter you see is plugged into one of the two UPS output lines, and the cable in it is PC power cable.

As can be seen in previous screenshot, I had two ssh sessions into "7600x" PC, one showing "top" command updating every second, and displaying all 12 hardware threads [AMD Bios SMT (Symmetric Multi Threading) enabled for six core 7600X]. In second ssh session I started "stress -c 12" directly after turning Ikea power switch off to simulate mains outage.

UPS did a small beep every 10 seconds to indicate that mains is off until 9:38min, and then beeped once per second until exhausted after 10:26min (see previous screenshot). Power meter showed that PC with 12 threads of 100% CPU draws only 94W:
20230713_005744.part.16%.plus.jpg
20230713_005744.part.16%.plus.jpg
20230713_005744.part.16%.plus.jpg (53.19 KiB) Viewed 16194 times


For months long comptations PC and UPS will move to basement.
But for now PC is next to 1Gbps switch.
I replaced the 10m ethernet cable to where PC was before with 1m cable, and now testmy.net reports >900Mbps:
924Mbps.50%.png
924Mbps.50%.png
924Mbps.50%.png (49.68 KiB) Viewed 16194 times

P.S:
I don't say that the VNC solution I came up with is what others should use.
It is just good enough and working for me ...


P.P.S:
Before buying UPS I had opened PC and verified that its 400W power supply has no active PFC (Power Factor Correction), because the UPS description explicitly asked for that.


P.P.P.S:
I tested single thread computation I am really interested in:
"./sqrtm1 8" computes "sqrt(-1) (mod p)" for largest known prime "p=1 (mod 4)" with 9,383,761 decimal digits (rank 9 overall):
https://t5k.org/primes/lists/all.txt

I determined upper bound of computation time as just under 75 days ...:
https://gmplib.org/list-archives/gmp-de ... 06189.html

Single thread running 100% displays 59W only for 7600X CPU PC.
1s interval beeps started at 16:53min, PC dead after 17:58min — not bad:
Image
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Thu Jul 13, 2023 7:13 pm

Now that PC is located more than 4m distant, I searched for an option to power on PC from my Pi400 — and the option is called wakeonlan.

"PCIE Devices Power On" was already enabled in my PC AMD Bios:
20230713_185057.part.10%.jpg
20230713_185057.part.10%.jpg
20230713_185057.part.10%.jpg (14 KiB) Viewed 16074 times

I followed this instruction on persisting wakeonlan on Ubuntu, with interface name determined by:
https://www.golinuxcloud.com/wake-on-lan-ubuntu/

Code: Select all

hermann@7600x:~$ ifconfig -a | grep MULTICAST | cut -f1 -d:
enp6s0
hermann@7600x:~$ 

After powering on the PC, this command verified that wakeonlan is enabled (the "g" in last line):

Code: Select all

hermann@7600x:~$ sudo ethtool enp6s0 | grep Wake-on
[sudo] password for hermann: 
	Supports Wake-on: pumbg
	Wake-on: g
hermann@7600x:~$ 

It is necessary to know the mac address of the PC interface:

Code: Select all

hermann@7600x:~$ ifconfig -a | grep ether | cut -b15-31
9c:6b:00:15:bd:c2
hermann@7600x:~$ 
My home network is 192.168.178.0/24.
After "sudo apt install wakeonlan" on my Pi400, this command successfully powered on my PC:

Code: Select all

pi@pi400-64:~ $ wakeonlan -i 192.168.178.255 9c:6b:00:15:bd:c2
Sending magic packet to 192.168.178.255:9 with 9c:6b:00:15:bd:c2
pi@pi400-64:~ $ 

This lazy command does work as well, which is fine because I only have 1 subnet:

Code: Select all

pi@pi400-64:~ $ wakeonlan 9c:6b:00:15:bd:c2
Sending magic packet to 255.255.255.255:9 with 9c:6b:00:15:bd:c2
pi@pi400-64:~ $ 

What does wakeonlan "cost" from energy perspective?
After shutdown of the PC, power meter displayed 4W for 30 seconds, then 0W after that.
I will do a long time test to determine the (low) cost.
wakeonlan_after_shutdown.jpg
wakeonlan_after_shutdown.jpg
wakeonlan_after_shutdown.jpg (37.06 KiB) Viewed 16074 times

Summary:
  • Pi400 KVM allows to switch Keyboard+Video+Mouse between Pi400 and laptop with CTRL+RASPBERRY
  • opening a browser in any of those and opening http://7600x:5800/vnc.html allows for browser VNC session to PC
  • normally I will ssh into the 7600X PC, if no GUI is needed
  • executing "wakeonlan 9c:6b:00:15:bd:c2" on Pi400 powers PC on
  • "sudo shutdown 0" in PC ssh session turns it off

P.S:
After all that, lots of space again:
20230713_213427.part.25%.jpg
20230713_213427.part.25%.jpg
20230713_213427.part.25%.jpg (36.45 KiB) Viewed 16066 times

P.P.S:
What does wakeonlan "cost" from energy perspective?
After shutdown of the PC, power meter displayed 4W for 30 seconds, then 0W after that.
I will do a long time test to determine the (low) cost.
I disconnected power meter to reset it, and after some time 4W was displayed all the time.
And after a bit more than 2.5h power meter displays 0.01KHw as sum, which matches (4W*2.5h).
So the cost of keeping computer powered off and its network interface listen to wakeonlan is 1KWh in more than 10 days.
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Thu Aug 24, 2023 8:48 pm

I run Pi400 64bit OS on USB SSD for years.

Few months ago some functionality got lost.
I found workarounds to live with that.

Later the GUI did not come up in addition.
After login into GUI whole screen showed sngle color, likely some green.
I had to press CTRL+ALT+F1 to get into 1st console.
There I executed this script:

Code: Select all

DISPLAY=:0 lxpanel --profile LXDE-pi &
DISPLAY=:0 pcmanfm --desktop --profile LXDE-pi &
DISPLAY=:0 xscreensaver -no-splash &
DISPLAY=:0 pi400kb_ &
Then I pressed CTRL+RASPBERRY to get Pi400 keyboard back, CTRL+ALT+F7 and GUI started up.
Not nice, but worked.

Then I wanted to start PrusaSlicer and some libs for that were missing.
So I installed fresh 64bit PiOS on SD card.
When I disconnected USB SSD on boot, the SD card was booted and all was fine.
But I had no pi400kb installed there.

Today everything broke on USB SSD OS, while GUI starts by the method described, no window manager got started.
I can open one browser, then one terminal above the browser, but cannot move that terminal to work with browser again.
I had to close the lxterminal, and decided that now has come the point to make SD card boot fully KVM capable.
And after that, do fresh 64bit PiOS install on USB SSD.

I found nearly everything needed to get KVM working on the SSD card OS in this thread.
But I had to jump between different postings.
And I realized that I missed to state a required step.
In 2nd posting of this thread after step (2), step (2b) is needed:
"cd libusbgx" and follow instructions in "INSTALL" to install libusbg gadget library.

Now that I have again a fully functional Pi400 KWM switch, I need to save data from USB SSD, and then figure out how to install OS on USB SSD (perhaps as simple as connect and run rpi-imager?).
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Sun Nov 26, 2023 9:55 am

HermannSW wrote:
Sat Feb 11, 2023 11:43 am
For an old computer I did need a physically connected keyboard (my wireless Logitech K400+ keyboard does not allow to enter bios).
So I did "kill two birds with one stone" (*) and bought "Raspberry keyboard and hub" and learned that way it is not a keyboard only:
https://www.raspberrypi.com/products/ra ... d-and-hub/
...
I will disconnect keyboard top from new keyboard and replace Pi400 keyboard whenever that will be necessary in the future …
Last night while programming some sparkling mineral water did hit Pi400 keyboard just above Raspberry key :-(

I had coffee on Pi400 keyboard 1.5y ago, but that was resolved easily:
viewtopic.php?t=329833

Since I use my Pi400 as KVM switch, and I worked on an interesting algorithm from 1884 on Pi400 with PARI/GP last night (https://pari.math.u-bordeaux.fr/archive ... 00061.html ), an immediate solution was neeeded to continue working. After removing fluid from keyboard as good as possible without opening keyboard, every key I pressed resulted in multiple keys showing in terminal window. So I connected the "Raspberry keyboard and hub" and continued programming. Plan was to power off the Pi400 after having finished programming, and then let it time over night to become dry again until now. The setup definitely does not look nice, but worked, see photo below. And allowed me to keep programming.

Now in the morning I powered up the Pi400. Since the KWM switch automatically switches to PC, I did need to press CTRL+RASPBERRY to switch back to Pi400. I tried that on attached keyboard, but that did not work. Luckily pressing CTRL+RASPBERRY on the Pi400 keyboard did work, and Pi400 desktop did show up on HDMI display.

Now I tested single key presses for each key of the Pi400 keyboard, and most did work flawlessly. These problems remainded:
ESC-> y
g-> gv
G-> GV
h-> hm
x-> <x
v-> gv plus enable Num Lock (that is annoying!)
m-> hm
,-> , plus activate browser address line (annoying)

I have a German keyboard Pi400 and German "Raspberry keyboard and hub".
The German umlaute keys work flawlessly on the Pi400.

So current plan is to give the Pi400 more time to self heal.
But perhaps I will be forced to at least open the Pi400, and finally having to replace the Pi400 keyboard.

I use my Pi400 for over 2 years now as KVM switch (>10h/day), and wanted to replace it with new keyboard computer.
From Eben videos it is clear that they work on a Pi500(?), but that can arrive before either this or next Christmas.
So maybe keyboard replacement will be needed.
But for the next days I will work with the current setup and hope for Pi400 self healing ...

On top of laptop you can see the 40 pages print of 1884 German language paper with the algorithm: https://pdfhost.io/v/~OwxzpPNA_KUNERTH_1878
IMG_20231126_000110_MP.15%.jpg
IMG_20231126_000110_MP.15%.jpg
IMG_20231126_000110_MP.15%.jpg (42.69 KiB) Viewed 4920 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

User avatar
HermannSW
Posts: 6250
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany

Re: Pi400 KVM switch

Mon Nov 27, 2023 7:50 pm

After 2 days a bit of self healing happened (strikethru).
HermannSW wrote:
Sun Nov 26, 2023 9:55 am
Now I tested single key presses for each key of the Pi400 keyboard, and most did work flawlessly. These problems remainded:
ESC-> y
g-> gv
G-> GV
h-> hm
x-> <x
v-> gv ̶p̶l̶u̶s̶ ̶e̶n̶a̶b̶l̶e̶ ̶N̶u̶m̶ ̶L̶o̶c̶k̶ ̶(̶t̶h̶a̶t̶ ̶i̶s̶ ̶a̶n̶n̶o̶y̶i̶n̶g̶!̶)̶
m-> hm
,-> , plus activate browser address line (annoying)
New or not reognized Saturday:
SPACE -> SPACE plus enable Num lock
NUM LOCK->NUM LOCK plus SPACE

My Pi400 KVM switch uses pi400kb, and that can only deal with Pi400 keyboard and not with "Raspberry keyboard and hub". So currently I use Logitech K400+ keyboard for laptop, and "Raspberry keyboard and hub" for the Pi400. Only shared device is Raspberry mouse. So currently I have a " ̶K̶VM" switch only :-(


P.S:
Too many keyboards when using " ̶K̶VM" switch ...
too_many_keyboards.jpg
too_many_keyboards.jpg
too_many_keyboards.jpg (107.95 KiB) Viewed 4732 times
https://github.com/Hermann-SW/RSA_numbers_factored
https://stamm-wilbrandt.de/GS_cam_1152x192@304fps
https://hermann-sw.github.io/planar_graph_playground
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/

Return to “Raspberry Pi 400”