In case anyone is wondering how I did it, the easy and most direct answer is to just copy the
gadget.sh script on this page and you can tweak it to your liking (renaming the manufacturer to Pine64 and the product to PinePhone for example). Mine looks like this:
Code:
#!/bin/bash
ID_VENDOR="0x1d6b"
ID_PRODUCT="0x0104"
cd /sys/kernel/config/usb_gadget/
mkdir g2
cd g2
echo "0x0200" > bcdUSB
echo "0x02" > bDeviceClass
echo "0x00" > bDeviceSubClass
echo "0x3066" > bcdDevice
echo $ID_VENDOR > idVendor
echo $ID_PRODUCT > idProduct
echo "1" > os_desc/use
echo "0xcd" > os_desc/b_vendor_code
echo "MSFT100" > os_desc/qw_sign
mkdir strings/0x409
echo "9112473" > strings/0x409/serialnumber
echo "Pine64" > strings/0x409/manufacturer
echo "PinePhone" > strings/0x409/product
mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "RNDIS" > configs/c.1/strings/0x409/configuration
mkdir functions/rndis.usb0
echo "RNDIS" > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
echo "5162001" > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
ln -s functions/rndis.usb0 configs/c.1
ln -s configs/c.1 os_desc
echo "musb-hdrc.4.auto" > UDC
exit 0
I named my gadget directory g2 because I already had a USB gadget created automatically in the /sys/kernel/config/usb_gadget/ directory when I installed pinephone-dev-tools which is how I got SSH through USB working on my Linux computer. musb-hdrc.4.auto comes from /sys/class/udc/ and it represents the USB-C connection, there should only be one there. When the USB-C cable is plugged into the computer it will enable the gadget.sh script and emulate a RNDIS device for Windows to see. On Windows 7 the device was not recognized, it still had a yellow exclamation mark in Device Manager, I right-clicked it, went to Properties -> Update Driver... -> Browse my computer for driver software -> Let me pick from a list of device drivers on my computer. Then I scrolled down to Network adapters clicked Next, scrolled down and selected Microsoft Corporation from the Manufacturer list, then finally selected Remote NDIS Compatible Device from the Network Adapter list and clicked Next. This will create a new adapter that Windows can see. Hold Windows+r and enter "ncpa.cpl". You should see a new adapter with "PinePhone" under it. Right-click it -> Properties -> "Internet Protocol Version 4 (TCP/IPv4) -> Propeties. From there select "Use the following IP address" and enter "10.66.0.5" (for example), then hit Tab and the Subnet mask will automatically be filled in, click OK. Next (we're almost there) open your PinePhone, type
select Edit a connection and look for a usbX device to identify it, select it. For IPv4 CONFIGURATION select <Manual> and for address enter 10.66.0.1/8 and exit by selecting OK at the bottom. Select Activate a connection and select usbX to enable the connection. Lastly enter
and look for the 10.66.0.1/8 address. Enter that into your SSH client on your Windows machine and fingers crossed it works.
Now I finished doing this at 4 o'clock in the morning and after having to painstakingly use the on-screen keyboard for way too long I was getting a bit flustered but hopefully I explained it well enough. It works for me and hopefully it works for you.
Relevant links:
https://xnux.eu/devices/feature/usb-gadget.html
https://01.org/linuxgraphics/gfx-docs/dr...figfs.html#
https://gist.github.com/Gadgetoid/c52ee2...77360011e2
https://learn.adafruit.com/turning-your-...net-gadget