Open RaubCamaioni opened 2 months ago
If dev_addr
or host_addr
are None they are not written to functionfs and should be assigned automatically by the kernel, hopefully unique.
I tried setting the host_addr to None, allowing the kernel to assign a random mac address. Both interfaces get a random mac address in their configuration files. cat /sys/kernel/config/usb_gadget/usb-gadget0/functions/ncm.usb-gadget0-0/host_addr: f2:b8:41:90:dd:10 cat /sys/kernel/config/usb_gadget/usb-gadget0/functions/ncm.usb-gadget0-1/host_addr: 4a:04:0a:2a:3d:04
Unfortunately, the client side enumerates both gadgets with the same mac address: Both interfaces received function1 mac address 4a:04:0a:2a:3d:04. I have seem function2 mac address assigned to both before too.
The client side getting the same mac addresses happens on windows and linux. I believe this is a linux kernel or linux gadgets module bug, the configuration files generated by Rust are all correct.
Tests preformed on pi4 model B kernel: 6.6.20+rpt-rpi-v8
Composite configurations with two net devices, with the same drivers, assign the same host mac address to both devices. I believe this is an error with the Linux gadget module / kernel and not an issue with this repo.
When reviewing the files generated by rust, the host_addr variables are properly assigned, unique to each function. I have the same issue when manually creating the configuration without this repo.
Is this the proper way, using this library, to configure a composite Linux device with two functions with the same driver? Both devices enumerate on a windows machine. They have identical mac addresses. Raising as an issue here to track the limitation in Linux gadget kernel capabilities.
I have been looking through the Linux kernel gadgets implementation and have not found any obvious culprits. Working from the "gether_setup_name" function that assigns the host and dev addresses. https://github.com/torvalds/linux/blob/20cb38a7af88dc40095da7c2c9094da3873fea23/drivers/usb/gadget/function/u_ether.c
Post on stack overflow tracking this error: https://stackoverflow.com/questions/78270075/linux-gadget-universal-device-controller-dual-cdc-ecm-or-dual-rndis-ethernet
Code showing roughly how the rust library is being used.