Tuesday, 18 November 2025

Connecting Raspberry Pi 4B using USB to a Windows laptop

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

1.  Download and install the *Raspberry Pi Imager* tool on your Windows 11 PC.
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) ⚠️

If the Raspberry Pi adapter appears in Device Manager with a *yellow exclamation mark* (often under "Other devices"), manually assign the *Remote NDIS Compatible Device* driver:

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).

1.  Press *Windows Key + R, type ncpa.cpl, and press **Enter* to open *Network Connections*.
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

1.  Open *Command Prompt* or *PowerShell* on Windows 11.
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:

ssh <username>@<dynamic_ip_address>
(e.g., ssh pi@192.168.137.100)

You are now connected to your Raspberry Pi 4B and have internet access through your laptop.

Compiling and inserting wifi driver

Download and burn on a Raspberry Pi 3/4

https://downloads.raspberrypi.org/raspios_armhf/images/raspios_armhf-2021-05-28/2021-05-

07-raspios-buster-armhf.zip

Update, upgrade, reboot Raspberry Pi 3/4 using wired Ethernet (kernel version is 5.10.103-v7l+)

Blacklist onboard wifi driver

sudo nano /etc/modprobe.d/blacklist-wifi.conf
blacklist brcmfmac
blacklist brcmutil
sudo update-initramfs -u
sudo reboot

Download driver source code into home on Raspberry Pi

rtl8852BU_rtl8832BU_WiFi_linux_v1.19.21-68-gd16563cf8.20250603.tar.gz

Install kernel headers, extract source code and compile driver

sudo apt install raspberrypi-kernel-headers
tar -zxvf rtl8852BU_rtl8832BU_WiFi_linux_v1.19.21-68-gd16563cf8.20250603.tar.gz
cd rtl8852BU_rtl8832BU_WiFi_linux_v1.19.21-68-gd16563cf8.20250603
sudo make KSRC=/lib/modules/$(uname -r)/build ARCH=arm

Observe kernel object 8852bu.ko created.

To automatically load driver with default configuration

sudo mkdir -p /lib/modules/$(uname -r)/kernel/drivers/net/wireless/realtek/rtl8852bu
sudo cp 8852bu.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless/realtek/rtl8852bu/
sudo depmod -a
sudo reboot

Now insert USB wifi dongle and observe wlan0.

Configure wpa_supplicant to connect to the network.

To stream from command line you can use:

streamlink http://live.onetv-preprod.one.hu/123456789/vxfmt=dp/manifest.mpd?
device_profile=DASH_STB_CLR_LIVE_HD best &

Saturday, 1 March 2025

Raspberry Pi Imager on Chrome OS

Unfortunately the AppImages from the original github repository of Raspberry Pi Imager does not work for me on the Linux subsystem Crostini of my ARM64 Chrome OS laptop.

Fortunately precompiled arm64 deb packages of Raspberry Pi Imager that works under Linux subsystem Crostini in Chrome OS can be found in this archive:

https://archive.raspberrypi.org/debian/pool/main/r/rpi-imager/

USB drive in Chrome OS can be switched to Linux subsystem Crostini in Settings/About Chrome OS/Linux development environment/Manage USB devices

UPDATE: amd64 deb package can be found here:

https://github.com/raspberrypi/rpi-imager/releases