Using gadget mode (g_ether) on Pi Zero

Hi,

I am interested in using gadget mode on the Pi Zero to enable a network connection via micro USB lead with out a micro USB to ethernet adapter. I have used Andrew Mulholands excellent guide (http://blog.gbaman.info/?p=791) to get this working on the latest Raspbian Jessie Lite OS (May 2016). However I am struggling with this on OSMC, I followed the same steps and it boots but doesn’t display as a USB Ethernet device on my PC and after rebooting with a USB Ethernet adapter plugged in the Zero no longer picks up a DHCP lease, I don’t currently have a USB to TTL cable so I am struggling to troubleshoot.

I am currently testing by connecting to my Windows 10 PC which works with Raspbian.

So couple of questions:

Has anyone tried this and got it working?

Do I need to follow Andrews’ old guide (http://blog.gbaman.info/?p=699) and compile a new kernel with the correct modules installed?

Can anyone provide any troubleshooting tips when you can’t connect to OSMC, i.e. no keyboard, mouse or network connection?

For those wondering why use gadget mode, I want to use two Pi Zeros running OSMC connected to a Pi server as an in car entertainment system for the kids whilst minimising cables and equipment needed.

1 Like

I got a USB to Serial Console cable and running:
modprobe -n --first-time -v dwc2
Outputs:
modprobe: FATAL: Module dwc2 not found.

Further checking and I noticed Raspbian kernel has been updated to 4.4.9 whereas OSMC is 4.4.8. So I guess I will need to wait for the next update to check if this works.

That is a very minor kernel bump, so not going to really change functionality.

I will investigate this missing module, which is likely just a CONFIG_ change. I’ll see if it can be made available in the next update.

Cheers

Sam

Thanks Sam, its two modules: dwc2 and g_ether

Thanks for letting me know.

Watch the blog :slight_smile:

I am looking at trying to implement this feature however I am hampered by limited knowledge and experience. So I am looking for a little help and guidance.

I have setup Virtualbox on my Windows PC and created a Debian VM for development work, I have used the guides on the wiki to fork the OSMC source from github.

I think I need to change some of the config options in ./osmc/package/kernel-osmc/patches/rbp1-000-add-kernel-config.patch , and this webpage seems to provide a clue as to what needs amending HOWTO: Enable USB device mode on Pi Zero - Raspberry Pi Forums

However I am now stuck as how to proceed with amending this file and how to build and test. Could anyone provide me with any tips or links to useful information.

Thanks

Some info here: http://blog.gbaman.info/?p=791

A useful trick is inserting “modules-load=dwc2,g_ether” into cmdline.txt, rather than finding the right startup scripts or editing /etc/modules.

But of course, the modules will need to be built, so will need an OSMC update to work.

The file osmc/osmc/blob/master/package/kernel-osmc/patches/rbp1-000-add-kernel-config.patch has a header saying it was automatically generated and do not manually edit. Should I be manually editing this file?

You can make small manual edits, but easiest to just edit the real .config with make menuconfig

Hi,

Did you found a solution for this?

Think this is now solved in the latest update

Hi, I’ve just been trying to setup my Pi 0 W as an ethernet gadget and it won’t even boot if I add the relevant bits to cmdline.txt and config.txt. Any suggestions as to what I could do?

Just to confirm: did you add it after installing OSMC?

What changes did you make to cmdline.txt and config.txt?
What version of OSMC are you on? Found in bottom left corner of My OSMC

Sam

Hi, thanks for getting back to me I’m using OSMC October 2017 2017.10-1,

I’ve added the dtoverlay=dwc2 line to config.txt and modules-load=dwc2,g_ether to cmdline.txt

Since yesterday I have tried the SD in another Pi 0 to see if the issue was with the pi. When I plugged it into power it did boot which I didn’t do in the other pi and I thought the pi must be the issue but when I then tried the card back in the original pi it boots in that one as well now but is still not recognized as an ethernet device.

I use an iMac as my desktop and it doesn’t react at all when I plug the pi in but if I use my windows laptop it makes a noise to register the device as plugged in and a disconnected ethernet 5 interface appears in my network center. I cannot connect to this interface in any way. I thought that maybe as the pi doesn’t have an ethernet socket that it might be because the ethernet interface is disabled but I can’t seem to enable it. Each time I click on the enable adapter option I see the loading graphic for a few seconds then it disappears and ethernet remains disabled. Is there a way for me to force enable the interface? I couldn’t find where the network interface files are I don’t have a /etc/network/interfaces file nor a dhcpd one that I could find.