summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-01-04 21:38:19 +0300
committerMaxim Devaev <[email protected]>2022-01-04 21:38:19 +0300
commitf1662e226288c3172dad4cf5ef6a9cce8e4ba3f9 (patch)
tree146d6d749127e13acb28baea47a132690afca5cb /kvmd
parentf1d018bef4a4499655bcdd828b2c5b292dddb542 (diff)
Improved RNDIS configuration
https://github.com/ev3dev/ev3-systemd/blob/ev3dev-jessie/scripts/ev3-usb.sh https://github.com/mfunkey/kvmd/commit/d6679cebbaa3fc89b13d549aa696840c112bbfca
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/otg/__init__.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/kvmd/apps/otg/__init__.py b/kvmd/apps/otg/__init__.py
index f59f7113..f47f4ea8 100644
--- a/kvmd/apps/otg/__init__.py
+++ b/kvmd/apps/otg/__init__.py
@@ -115,6 +115,17 @@ def _create_ethernet(gadget_path: str, config_path: str, driver: str, host_mac:
_write(join(func_path, "host_addr"), host_mac)
if kvm_mac:
_write(join(func_path, "dev_addr"), kvm_mac)
+ if driver == "rndis":
+ # On Windows 7 and later, the RNDIS 5.1 driver would be used by default,
+ # but it does not work very well. The RNDIS 6.0 driver works better.
+ # In order to get this driver to load automatically, we have to use
+ # a Microsoft-specific extension of USB.
+ _write(join(func_path, "os_desc/interface.rndis/compatible_id"), "RNDIS")
+ _write(join(func_path, "os_desc/interface.rndis/sub_compatible_id"), "5162001")
+ _write(join(gadget_path, "os_desc/use"), "1")
+ _write(join(gadget_path, "os_desc/b_vendor_code"), "0xCD")
+ _write(join(gadget_path, "os_desc/qw_sign"), "MSFT100")
+ _symlink(config_path, join(gadget_path, "os_desc/c.1"))
_symlink(func_path, join(config_path, f"{driver}.usb0"))
@@ -174,7 +185,10 @@ def _cmd_start(config: Section) -> None: # pylint: disable=too-many-statements
_write(join(gadget_path, "idVendor"), f"0x{config.otg.vendor_id:04X}")
_write(join(gadget_path, "idProduct"), f"0x{config.otg.product_id:04X}")
- _write(join(gadget_path, "bcdDevice"), "0x0100")
+ # bcdDevaev should be incremented any time there are breaking changes
+ # to this script so that the host OS sees it as a new device
+ # and re-enumerates everything rather than relying on cached values.
+ _write(join(gadget_path, "bcdDevice"), "0x0101")
_write(join(gadget_path, "bcdUSB"), f"0x{config.otg.usb_version:04X}")
lang_path = join(gadget_path, "strings/0x409")
@@ -250,6 +264,9 @@ def _cmd_stop(config: Section) -> None:
logger.info("Disabling gadget %r ...", config.otg.gadget)
_write(join(gadget_path, "UDC"), "")
+ if config.otg.devices.ethernet.driver == "rndis":
+ _unlink(join(gadget_path, "os_desc/c.1"))
+
config_path = join(gadget_path, "configs/c.1")
for func in os.listdir(config_path):
if re.search(r"\.usb\d+$", func):