2
0
mirror of https://github.com/pikvm/pikvm synced 2024-11-05 00:00:28 +00:00
pikvm/docs/usb_dynamic.md

99 lines
3.4 KiB
Markdown
Raw Normal View History

2023-07-25 16:22:41 +00:00
# Dynamic USB configuration
PiKVM emulates a number of USB devices to ensure normal operation: keyboards, mouse and mass storage drive.
Also an additional [relative mouse](mouse.md) may be present (like on PiKVM V4 by default),
or a user configured [USB Ethernet](usb_ethernet.md) or [Serial port](usb_serial.md).
In rare cases, the host BIOS/UEFI may not understand such a large number of emulated devices on single USB port,
so some of them may need to be disabled. USB reconfiguration usually requires a reboot, but it is possible
to temporarily disable already configured existing emulated devices.
!!! warning
This feature is experimental. Due to the imperfections of the kernel modules, rarely a dynamic configuration change
can lead to a kernel panic and reboot.
For PiKVM V3 and V4 this is considered more secure because they have two independent watchdog systems
that can bring devices back to life after a timeout of a few minutes.
2023-08-09 22:05:42 +00:00
-----
2023-07-25 16:22:41 +00:00
## Command-line utility
The `kvmd-otgconf` utility allows you to view and modify the USB configuration on the fly.
It requires root permission and can be used for example from a web terminal.
View the config:
```
# kvmd-otgconf
+ hid.usb0 # Keyboard
+ hid.usb1 # Absolute Mouse
+ hid.usb2 # Relative Mouse
+ mass_storage.usb0 # Mass Storage Drive
```
Each line represents a device (function). First comes plus or minus sign (the device on or off), then the name of the device and its description.
Disabling the device:
```
[root@pikvm ~]# kvmd-otgconf --disable-function mass_storage.usb0
+ hid.usb0 # Keyboard
+ hid.usb1 # Absolute Mouse
+ hid.usb2 # Relative Mouse
- mass_storage.usb0 # Mass Storage Drive
```
Enabling the device:
```
[root@pikvm ~]# kvmd-otgconf --enable-function mass_storage.usb0
+ hid.usb0 # Keyboard
+ hid.usb1 # Absolute Mouse
+ hid.usb2 # Relative Mouse
+ mass_storage.usb0 # Mass Storage Drive
```
2023-08-09 22:05:42 +00:00
-----
2023-07-25 16:22:41 +00:00
## Web UI menu
Using the pseudo-GPIO driver, you can also control devices via the menu in the web interface.
Read about GPIO basics [here](gpio.md).
2023-08-09 22:05:42 +00:00
To setup the menu, use `kvmd-otgconf --make-gpio-config` to generate the configuration, and merge it
2023-07-25 16:22:41 +00:00
with your existing one in `/etc/kvmd/override.yaml` in a usual way.
2023-08-09 22:11:34 +00:00
??? example "The example of `kvmd-otgconf --make-gpio-config` output"
2023-08-09 22:05:42 +00:00
```yaml
# kvmd-otgconf --make-gpio-config
kvmd:
gpio:
drivers:
otgconf:
type: otgconf
scheme:
hid.usb0:
driver: otgconf
mode: output
pin: hid.usb0
pulse: false
hid.usb1:
driver: otgconf
mode: output
pin: hid.usb1
pulse: false
hid.usb2:
driver: otgconf
mode: output
pin: hid.usb2
pulse: false
mass_storage.usb0:
driver: otgconf
mode: output
pin: mass_storage.usb0
pulse: false
view:
table:
- ["#Keyboard", "#hid.usb0", hid.usb0]
- ["#Absolute Mouse", "#hid.usb1", hid.usb1]
- ["#Relative Mouse", "#hid.usb2", hid.usb2]
- ["#Mass Storage Drive", "#mass_storage.usb0", mass_storage.usb0]
```