mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 00:22:56 -05:00
The USB network gadget (rndis.usb0 / ncm.usb0) is created without dev_addr or host_addr, so the kernel picks a random MAC for both the device side and the host side on every bind. S10uuid later pins the device-side usb0 via 'ip link set', but the host_addr -- the MAC the attached PC's RNDIS/NCM adapter uses -- stays random and changes on every re-enumeration/reboot. The host then registers a brand-new network adapter each time, piling up stale adapters/MACs (e.g. ~10 after a few reboots) and breaking anything that keys off the MAC. Derive both MACs from the chip UID (same scheme S10uuid already uses for eth0 and usb0), before binding the gadget: dev_addr = 48:da:35:6e:<uid> host_addr = 48:da:35:6d:<uid> Verified on a NanoKVM Cube: host_addr went from random a6:3f:5d:8a:7d:52 to a stable 48:da:35:6d:26:62, identical across two reboots. Fixes #740 Co-authored-by: BeaconCat <BeaconCat@users.noreply.github.com>