This guide provides a comprehensive, step-by-step process for flashing your SD card, editing the necessary configuration files on your Windows 11 PC, configuring Internet Connection Sharing (ICS), and connecting to your Raspberry Pi 4B (RPi4B) using a USB-C to USB-C cable.
## 1\. 🖥️ Prepare the SD Card on Windows 11
### Step 1: Flash the SD Card with Raspberry Pi Imager
2. Insert your microSD card into your PC's card reader.
3. Launch Raspberry Pi Imager.
4. Click *"Choose OS"* and select the latest *Raspberry Pi OS (64-bit)* or the version you prefer.
5. Click *"Choose Storage"* and select your microSD card.
6. *Crucially:* Press *Ctrl+Shift+X* (or click the gear icon in newer versions) to open the *Advanced Options* menu.
7. In the Advanced Options, configure your desired *Hostname* (e.g., myraspi), set a *Username and Password, and enable **SSH*. This ensures the Pi is ready for headless access.
8. Click *"Write"* and wait for the process to complete.
## 2\. ⚙️ Edit Configuration Files for Gadget Mode
After flashing, the Imager will eject the SD card. You may need to remove it and re-insert it into your PC to make the boot partition accessible.
### Step 1: Locate the Boot Partition
On Windows 11, only the small, FAT-formatted *Boot partition* of the SD card will be visible. It will appear as a drive letter (e.g., E:\).
### Step 2: Modify config.txt
1. Open the file config.txt located in the root of the Boot partition (e.g., E:\config.txt).
2. Add the following line to the end of the file to enable the USB gadget driver:
dtoverlay=dwc2
### Step 3: Modify cmdline.txt
1. Open the file cmdline.txt located in the root of the Boot partition (e.g., E:\cmdline.txt).
2. The file contains a single, long line of text. *Append* the following text to the *end of that single line*, ensuring there is a single space before it:
modules-load=dwc2,g_ether
3. *Save* both files and safely *eject* the SD card from your Windows PC.
## 3\. 🔌 Windows 11 & Pi Connection Setup
### Step 1: Boot the Raspberry Pi and Connect
1. Insert the prepared SD card into your RPi4B.
2. Connect the *USB-C to USB-C cable* between the *RPi4B's USB-C power/data port* (not the display ports) and your Windows 11 laptop's USB-C port.
3. The RPi will boot up and be recognized by Windows as a new device.
### Step 2: Optional Driver Installation (If Needed) ⚠️
1. Open *Device Manager* (search for it in the Start Menu).
2. *Right-click* on the unknown device and select *Update driver*.
3. Select *Browse my computer for drivers*.
4. Select *Let me pick from a list of available drivers on my computer*.
5. Select *Network adapters, click **Next*.
6. Select *Microsoft* as the Manufacturer and *Remote NDIS Compatible Device* as the Model.
7. Click *Next* to install the driver.
### Step 3: Enable Internet Connection Sharing (ICS)
ICS automatically enables a DHCP server and provides the RPi with an IP address (in the 192.168.137.x range).
2. Identify your adapters:
* *Internet Adapter:* Your *Wi-Fi* connection (the one with internet access).
* *RPi Adapter:* The new adapter, usually the *Remote NDIS based Internet Sharing Device*.
3. *Right-click* on your *Internet Adapter* (Wi-Fi) and select *Properties*.
4. Go to the *Sharing* tab.
5. Check the box: *"Allow other network users to connect through this computer's Internet connection."*
6. In the dropdown, select the *RPi Adapter*.
7. Click *OK. Windows sets the RPi Adapter's IP to **192.168.137.1*.
## 4\. 🔑 SSH Connection
The Pi will automatically receive an IP address from Windows ICS.
Use ssh to access Raspberry Pi 4B:
1. Open *Command Prompt* or *PowerShell* on Windows 11.
2. Run the command:
ssh <username>@<hostname>.local
If this fails to determine the dynamic IP address alternatively you can use this method:
### Step 1: Determine the Pi's Dynamic IP
2. Run the command:
arp -a
3. Look for the interface with the IP address *192.168.137.1* (your laptop's side).
4. Scan the entries under that interface for another IP address in the *192.168.137.x* range (e.g., 192.168.137.100) that has a *Dynamic* type. This is the *Raspberry Pi's IP*.
### Step 2: Connect via SSH
Use the IP address you found in Step 1, along with the username you set in the Imager:
(e.g., ssh pi@192.168.137.100)
You are now connected to your Raspberry Pi 4B and have internet access through your laptop.
