Skip to content

Instantly share code, notes, and snippets.

@shantur
Last active December 20, 2023 04:04
Show Gist options
  • Save shantur/71e4931438f61ab6386e7672f6a2cf50 to your computer and use it in GitHub Desktop.
Save shantur/71e4931438f61ab6386e7672f6a2cf50 to your computer and use it in GitHub Desktop.
PiKVM on RockPro installation
# For installing PiKVM on RockPro64 with HDMI-USB Capture device.
# Install Manjaro linux
# Run this script as sudo pikvm-install.sh
# Enable Otg on USB-C Port
pacman -Syu --noconfirm dtc
fdtput -t s /boot/dtbs/rockchip/rk3399-rockpro64.dtb /usb@fe800000/usb@fe800000 dr_mode peripheral
export PIKVM_REPO_KEY=912C773ABBD1B584
export PIKVM_REPO_URL=https://pikvm.org/repos
export BOARD=rpi4
export ARCH=arm
export WEBUI_ADMIN_PASSWD=admin
export IPMI_ADMIN_PASSWD=admin
export PLATFORM=v2-hdmiusb
mkdir -p /etc/gnupg
echo standard-resolver >> /etc/gnupg/dirmngr.conf
pacman-key --keyserver hkps://keyserver.ubuntu.com:443 -r $PIKVM_REPO_KEY \
|| pacman-key --keyserver hkps://keys.gnupg.net:443 -r $PIKVM_REPO_KEY \
|| pacman-key --keyserver hkps://pgp.mit.edu:443 -r $PIKVM_REPO_KEY \
pacman-key --lsign-key $PIKVM_REPO_KEY
echo -e "\n[pikvm]" >> /etc/pacman.conf
echo "Server = $PIKVM_REPO_URL/$BOARD-$ARCH" >> /etc/pacman.conf
echo "SigLevel = Required DatabaseOptional" >> /etc/pacman.conf
pacman -Syu kvmd
systemctl enable kvmd-nginx
curl -o /etc/kvmd/main.yaml https://raw.githubusercontent.com/pikvm/kvmd/master/configs/kvmd/main/v2-hdmiusb-rpi4.yaml
echo libcomposite > /etc/modules-load.d/99-kvmd.conf
modprobe libcomposite
curl -o /etc/sudoers.d/99-kvmd https://raw.githubusercontent.com/pikvm/kvmd/master/configs/os/sudoers/v2-hdmiusb
curl -o /etc/udev/rules.d/99-kvmd.rules https://raw.githubusercontent.com/pikvm/kvmd/master/configs/os/udev/v2-hdmiusb-rpi4.rules
udevadm control -R
udevadm trigger
printf "kvmd:\n msd:\n remount_cmd: /bin/true\n" >> /etc/kvmd/override.yaml
mkdir /var/lib/kvmd/msd/images
mkdir /var/lib/kvmd/msd/meta
chown kvmd:root /var/lib/kvmd/msd/images
chown kvmd:root /var/lib/kvmd/msd/meta
systemctl enable kvmd-otg
sed -i 's/) exit 1;;/) exit 0;;/g' /usr/bin/kvmd-udev-hdmiusb-check
curl -o /opt/vc/bin/vcgencmd https://raw.githubusercontent.com/Yura80/os/master/pikvm/vcgencmd
pacman -S --noconfirm git make gcc libevent libjpeg-turbo libutil-linux libbsd
git clone https://github.com/pikvm/ustreamer.git
cd ustreamer
make
cp ./ustreamer /usr/bin/ustreamer
systemctl enable kvmd
echo "Your system is all set to reboot now"
# Reboot system
@Avni22
Copy link

Avni22 commented Feb 2, 2022

Hi,

I am working on piKVM porting and trying to findout how piKVM works.

for that I am looking for software arcitechure of piKVM to get clear view of how they actually transferring the OTG Event(Keybaord, mouse etc) from local system server that is attached with piKVM.

if you have any idea on how actual it work, could you please help me to understand. it will be very helpfull for me to start. Actualy i am porting it for another hardware IMX8.

I also try to get help from piKVM DISCORD channel.

Thanks
Ashvin Makwana

@shantur
Copy link
Author

shantur commented Feb 2, 2022

PiKVM uses Linux kernel USB Gadget framework for acting as a usb device.
You can find some info here https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt and on google.

@Avni22
Copy link

Avni22 commented Feb 2, 2022

Hi

Thank you for your response.

I am looking on it and got that point.

PiKVM uses Linux kernel USB Gadget framework for acting as a usb device.

My confusin is here,

As all mouse or keyboard event is sent from " local pc " to piKVM via some network or web interface. not sure which method are being used.

how respective data is converted at piKVM end point, after that conversion they send it over OTG Gadget framework to server.

how to manage forth & back communication between piKVM & local pc ?

if you have any idea about this, can you share it here please?

Thanks

@shantur
Copy link
Author

shantur commented Feb 2, 2022

The communication flow is

Web Interface (Browser) -> Web Socket -> PiKVM (kvmd) -> Linux Kernel Gadget -> USB -> Remote Server.

If you are porting it to iMX8, then you don't need to worry about this but

  1. Make sure Linux Kernel for iMX8 and iMX8 has USB Gadget ( OTG ) support
  2. Enable Linux USB Device Mode for iMX8
  3. Install arch linux based distro
  4. Install pikvm using my script.

Rest all will be taken care of.

Once you reach this point then, you can start thinking of hardware accelerated encoding on iMX8 for ustreamer

@Avni22
Copy link

Avni22 commented Feb 7, 2022

Hi

As per your suggestions I have tried your script for building os for iMX8 board, got some error affter running your script and working on resolving the error.

Also,
I am working on to creating software architecture of piKVM. I have made a basic skeleton for architecture, would you please have a look into it and help me for better understanding it.

Could you please suggest If I missed anything in this.

piKVM drawio

@shantur
Copy link
Author

shantur commented Feb 7, 2022

My script is quite old so might not be compatible with recent changes.
As far as my undertstanding goes the diagram looks ok to me.
I would suggest you jump onto PiKVM Discord and discuss there. You would find many people who can answer your queries.

@FallenDawn
Copy link

rror: failed retrieving file 'pikvm.db' from pikvm.org : The requested URL returned error: 404

@richardbergen
Copy link

rror: failed retrieving file 'pikvm.db' from pikvm.org : The requested URL returned error: 404

You need to update your pacman pikvm config to the following:
[pikvm]
Server = https://files.pikvm.org/repos/arch/rpi4-arm
SigLevel = Required DatabaseOptional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment