Usb0 interface for networking

I plan on getting an ethernet featherwing but in the meantime I would like to try to use usb0 for networking. I setup Internet sharing on my OSX machine and from my Giant Board I’ve tried ‘dhclient usb0’ which seems to eventually timeout. Trying to figure out where I’m having trouble. Has anyone been successful in setting up networking over usb0? I have no other device to try this with to try and see what end is the problem, any help would be appreciated.

Hello, welcome to forums. Unfortunately I’ve not been able to test USB networking on Mac OS as I don’t have one. I was able to get it working on Linux and windows. Maybe someone with some more Mac experience can share some ideas for getting the usb flags set so it shows the USB Ethernet device probably.

Fortunately, I got USB Tethering using macOS working. An additional Driver Called “HoRNDIS” is required.

As the official installer does not work anymore due to Changes in macOS 10.15 (Catalina) I had to use a modified version I found here:

As is is a unsigned package, you have to allow some exceptions in the Security section of the System settings. After installing the package, a network adapter called “Ethernet Adaptor (en7)” appeared in the Network settings allowing me to enable Network sharing with this interface.

On the giant board, a simple dhclient usb0 did the rest for me.

@W8LID Good luck with your networking!

Thank you very much, now have networking working.

There is a simpler way that does not require installing anything on the Mac: The Giant Board can also use the standard CDC-ECM protocol for USB Ethernet, which is also understood by macOS, instead of Microsoft’s RNDIS that the stock USB gadget scripts use.

Make a copy of /usr/bin/usbgadget-serial-eth-ms and modify it as follows:

--- usbgadget-serial-eth-ms	2020-02-29 18:47:32.000000000 +0100
+++ usbgadget-serial-ethecm-ms	2020-02-29 18:47:44.000000000 +0100
@@ -79,7 +79,7 @@
 # Add the functions
 mkdir -p "${gadget_dir}/functions/acm.GS0"
-mkdir -p "${gadget_dir}/functions/rndis.usb0"
+mkdir -p "${gadget_dir}/functions/ecm.usb0"
 mkdir -p "${gadget_dir}/functions/mass_storage.giantboard"
@@ -92,15 +92,13 @@
 echo "GiantBoard" > "${gadget_dir}/functions/mass_storage.giantboard/lun.0/inquiry_string"
-# Setup RNDIS MAC
-echo "RNDIS" > "${gadget_dir}/functions/rndis.usb0/os_desc/interface.rndis/compatible_id"
-echo "5162001" > "${gadget_dir}/functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id"
-echo ${hmac} > "${gadget_dir}/functions/rndis.usb0/host_addr"
-echo ${dmac} > "${gadget_dir}/functions/rndis.usb0/dev_addr"
+# Setup CDC-ECM MAC
+echo ${hmac} > "${gadget_dir}/functions/ecm.usb0/host_addr"
+echo ${dmac} > "${gadget_dir}/functions/ecm.usb0/dev_addr"
 # Link the functions
-ln -s "${gadget_dir}/functions/rndis.usb0" "${gadget_dir}/configs/c.1"
+ln -s "${gadget_dir}/functions/ecm.usb0" "${gadget_dir}/configs/c.1"
 ln -s "${gadget_dir}/configs/c.1" "${gadget_dir}/os_desc"
 ln -s "${gadget_dir}/functions/acm.GS0" "${gadget_dir}/configs/c.1"
 ln -s "${gadget_dir}/functions/mass_storage.giantboard" "${gadget_dir}/configs/c.1"

You can then run it from systemd like the other scripts by making and enabling a suitably modified copy of /lib/systemd/system/usbgadget-serial-eth-ms.service.

This works for me with macOS 10.14.6, the board appears as a network interface named “Giant Board” and I can share my internet connection with it.

1 Like