Using USB Gadget Mode on Raspberry Pi Zero for SSH/RDP Access on Windows 11#

The Raspberry Pi Zero is a versatile device that can be configured to act as a USB Ethernet gadget, allowing you to connect to it via SSH or RDP over a single USB cable. This is especially useful when you want a direct network connection without additional hardware. In this article, we will guide you through setting up the Pi Zero in USB gadget mode and installing the necessary Windows 11 drivers for seamless connectivity.

What is USB Gadget Mode?#

USB Gadget mode allows the Raspberry Pi Zero to emulate various USB devices, including an Ethernet adapter. When configured as a USB Ethernet gadget, the Pi Zero appears as a network device to your computer, enabling network communication over USB.

Setting Up Raspberry Pi Zero in USB Gadget Mode#

Prerequisites#

  • Raspberry Pi Zero (any variant)
  • MicroSD card with Raspberry Pi OS Lite (Bullseye or newer)
  • USB OTG cable (micro-B to USB-A)
  • Windows 11 PC

Step 1: Prepare the Boot Configuration#

  1. Insert the microSD card into your computer.
  2. Open the config.txt file located in the boot partition and add the following line at the end:
dtoverlay=dwc2
  1. Open the cmdline.txt file in the same partition. This file contains a single line of text. Find the word rootwait and immediately after it, add:
modules-load=dwc2,g_ether

The line should look similar to this (all in one line):

console=serial0,115200 console=tty1 root=PARTUUID=xxxx-xxxx rootwait modules-load=dwc2,g_ether

Step 2: Enable SSH#

To enable SSH on boot, create an empty file named ssh (without any extension) in the boot partition:

touch /boot/ssh

If you are preparing the card on another system, simply create an empty file named ssh in the boot folder.


Installing Windows 11 Drivers for RNDIS USB Gadget#

Windows 11 may not automatically recognize the Raspberry Pi Zero as a network device. You need to install the Remote NDIS (RNDIS) driver manually.

Download Drivers#

Installing the Driver#

  1. Connect your Raspberry Pi Zero to the Windows 11 PC via USB.
  2. Open Device Manager.
  3. Look for an unrecognized device, usually under “Other devices” or “Network adapters” with a yellow warning icon.
  4. Right-click the device and select Update driver.
  5. Choose Browse my computer for drivers.
  6. Point to the folder where you extracted the downloaded driver files.
  7. Select Remote NDIS Compatible Device when prompted.
  8. Complete the installation.