Raspberry Pi 5 USB-Gadget for hamradio and programming


Raspberry PI5 USB-C Gadget

A Raspberry Pi 5 as a USB-C gadget. Power and Ethernet via a single cable for use with an iPad via VNC and SSH. The swiss army knife for ham radio.


Before you dive into this blog post, I recommend reading the following blog post first: https://dl1gkk.com/raspberry-pi-ham-radio-best-practice-2026

Importand

The first half of the blog post describes an older setup using the 32-bit version of Raspbian Bookworm, which was necessary for installing Wine/VARA. Since I no longer use that configuration, the second half of the post covers an installation using the 64-bit version of Raspbian Trixie. This makes for a cleaner and faster setup on the Raspberry Pi 5.

My heart beats digital. For over 35 years, I’ve been an entrepreneur, but my passion for technology goes much deeper. Whether as a licensed radio amateur (73 de DL1GKK!) or while coding.

My focus in everything I do is on efficiency and minimalism. That is exactly why I choose not to use an additional Mac; iPhone and iPad are completely sufficient for my daily workflow. A Windows PC is simply not an alternative for me for many reasons. If I were to start all over again today, probably I would likely go all-in on Linux from the very beginning. But i like the great hardware from Apple. However, anyone who has tried to run specialized Ham Radio software or native Linux development on iOS or iPadOS inevitably hits a wall.

Apple heavily restricts the USB-C interface of these devices, and the available apps are often just a shadow of what is possible under Linux. Whether it’s digital modes like VARA (via Wine), WSJT-X, or complex compilers – everything runs on the Raspberry Pi. Until now, getting there was a rocky road: configuring the Pi as a hotspot, using a smartphone as a bridge… more often than not, it failed due to unstable Wi-Fi connections in the field. Headless troubleshooting without a monitor? A nightmare for any portable radio operation.

The Solution: The iPad as the Terminal, the Pi 5 as the Powerhouse

I have found the perfect solution to tear down that wall: the Raspberry Pi 5 in USB Gadget Mode. A single, high-quality USB-C data cable connects the iPad directly to the Pi. The result? The iPad provides the power, and the Pi provides a stable Ethernet signal over the cable and do all the great ham radio stuff.

It is the ultimate all-rounder:

  • On the go: True “Plug & Play” on the iPad. Full access via VNC or SSH – without unstable Wi-Fi.
  • At home: Simply plug it into a power supply and use it as a standalone server via LAN or Wi-Fi.
  • Universal: Works on any modern computer with a high-performance USB-C port that can deliver enough power.

A crucial tip from the radio shack: Not every USB-C cable is a data cable! Make sure to use high-quality cables capable of both high-speed data transfer and power delivery. Below, I will show you step-by-step how to “arm” your Pi 5 for this setup.

  • Operating System Choice: This guide covers both 32-bit and 64-bit setups. However, for Ham Radio use (especially if you plan to run VARA HF, Winlink, or Wine), I strongly recommend using the 32-bit version of Raspberry Pi OS. It is significantly more stable for these specific radio applications.
  • Prerequisite: Ensure that SSH and/or VNC are enabled in your Raspberry Pi settings (via sudo raspi-config). Important for Pi 5: You must switch the Display Backend from Wayland to X11 (Advanced Options in raspi-config), otherwise the RealVNC server will not function.
  • Login Note: Since modern OS versions no longer have a default “pi” user, remember to use the username and password you created during the initial setup with the Raspberry Pi Imager.

Maintenance Philosophy: “Never Change a Running System”

In a complex environment like this—with Wine, Vara HF, and custom Gadget scripts—a single automatic update can break your entire workflow. Operating a “Pi-Go” is like operating a specialized piece of machinery: stability is more important than having the latest version of every minor background tool.

My advice: Turn off the automatic update notifications in your taskbar. Only perform manual updates (sudo apt update && sudo apt upgrade) when you have the time to troubleshoot potential issues. Rule of thumb: No updates shortly before a field day or a DX-pedition!

Critical Maintenance & Safety Note

A Raspberry Pi is not a simple USB thumb drive. When using it as a USB-C Gadget, you must perform a proper shutdown (e.g., via SSH using sudo halt) before disconnecting the cable. Unplugging it while it’s running carries a high risk of corrupting the SD card’s file system, which will prevent it from booting next time.

Pro-Tip: Use the SD Card Copier tool on your Pi regularly to create a full backup on a second SD card. Field operations can be tough on gear—whether it’s technical failure, loss, or theft, having a ready-to-go backup card at home ensures you’re back on the air in minutes!


The Bookworm 32bit OS Setup (for ham radio)

Note: Operating on a 32-bit OS (essential for Wine/Vara stability) with the specific Pi 5 kernel requires a few special tweaks. Here is my field-tested, step-by-step guide so you can skip the troubleshooting and get straight to work.

Step 1: Prepare the Hardware Driver

We need to tell the Pi 5 that its USB-C port should act as a network interface rather than just a power input.

sudo nano /boot/firmware/config.txt
  • Find the line otg_mode=1 and comment it out with a #: # otg_mode=1
  • Find dtoverlay=dwc2,dr_mode=host and comment it out as well: # dtoverlay=dwc2,dr_mode=host
  • Ensure kernel=kernel8.img (required for Wine/Vara) remains active.
  • Add the following lines at the very end of the file under the [all] section:
[all]
dtoverlay=dwc2,dr_mode=peripheral

Step 2: Load Kernel Modules at Boot

Next, we enable the network emulation within the operating system. (Crucial fix: Do NOT use g_ether here as it conflicts with modern Pi 5 networking).

sudo nano /boot/firmware/cmdline.txt

Go to the end of the first line, add a space, and append the following (must stay on one single line!):

modules-load=dwc2

Step 3: Create the Gadget Script

This script defines the Pi’s identity (e.g., my callsign DL1GKK) so the iPad recognizes it consistently. We also add a small delay at the end to ensure the NetworkManager is fully awake before connecting.

sudo nano /usr/local/bin/usb-gadget.sh

Paste the following code block entirely:

#!/bin/bash
modprobe libcomposite 2>/dev/null
modprobe dwc2 2>/dev/null
mount -t configfs none /sys/kernel/config/ 2>/dev/null
cd /sys/kernel/config/usb_gadget/
mkdir -p g1 && cd g1
echo 0x1d6b > idVendor
echo 0x0104 > idProduct
echo 0x0100 > bcdDevice
echo 0x0200 > bcdUSB
mkdir -p strings/0x409
echo "fedcba9876543210" > strings/0x409/serialnumber
echo "DL1GKK" > strings/0x409/manufacturer
echo "Pi5 Gadget" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/bmAttributes
echo 500 > configs/c.1/MaxPower
mkdir -p functions/ecm.usb0
echo "00:22:82:ff:ff:01" > functions/ecm.usb0/host_addr
echo "00:22:82:ff:ff:02" > functions/ecm.usb0/dev_addr
ln -s functions/ecm.usb0 configs/c.1/
UDC_NAME=$(ls /sys/class/udc | head -n 1)
echo "$UDC_NAME" > UDC

# Enable the hardware interface
ip link set usb0 up

# Give the OS and NetworkManager 15 seconds to fully boot up 
# before forcing the connection (prevents race conditions)
sleep 15
nmcli connection up usb-ipad 2>/dev/null

Make the script executable:

sudo chmod +x /usr/local/bin/usb-gadget.sh

Step 4: Automation & Hardware Switch (CRITICAL!)

To ensure the script runs on every boot, we use rc.local.

sudo nano /etc/rc.local

Insert the following (including the Shebang if the file is empty) just above exit 0:

#!/bin/bash
/usr/local/bin/usb-gadget.sh &
exit 0

Make rc.local executable:

sudo chmod +x /etc/rc.local

IMPORTANT: A simple reboot is not enough at this stage! Shut down the Pi completely (sudo halt). Disconnect the power supply. Now, connect the Pi directly to your iPad using a high-quality USB-C data cable. The Pi will now boot using the iPad’s power.

Step 5: Bulletproof Network Initialization

Once the Pi has booted up via the iPad, access the Pi via SSH (using your local Wi-Fi/LAN connection) and run these commands once to create a rock-solid profile that locks the MAC address and IP:

sudo ip link set usb0 up
sudo nmcli con add type ethernet con-name usb-ipad ifname usb0 ip4 10.42.0.1/24 802-3-ethernet.cloned-mac-address 00:22:82:ff:ff:02 ipv6.method disabled connection.autoconnect yes
sudo nmcli con mod usb-ipad connection.zone trusted
sudo nmcli con up usb-ipad

Step 6: iPad Settings & Patience

On your iPad, navigate to Settings > Ethernet and tap the connection:

  • Configure IPv4: Manual
  • IP Address: 10.42.0.10
  • Subnet Mask: 255.255.255.0
  • Router: Leave it blank

Pro-Tip for daily use: When you plug the Pi into your iPad, give it about 45-60 seconds to boot. You will notice the Ethernet connection popping up on your iPad screen once the 15-second delay in our script finishes. This is perfectly normal and guarantees a stable connection every single time!

Note: The reason we don’t enter anything under “Router” is that we want to continue using the iPad’s Wi-Fi or 5G connection to access the internet. Once the PI5 is connected to the internet (via Wi-Fi, Ethernet, or a smartphone hotspot), you can reach it via 10.42.0.1.


RPI 5 USB GADGET INSTRUCTION
Easy digital ham radio with raspberry pi5

NEW !!! USB-C Gadget with Raspbian Trixie 64bit and Wayland

With the release of Raspberry Pi OS (Debian Trixie 64-bit), setting up the Raspberry Pi 5 as a single-cable USB-C gadget for the iPad has become much cleaner and more reliable. Instead of manual libcomposite scripts, custom dnsmasq configs, and legacy X11 workarounds, Trixie introduces the native rpi-usb-gadget package alongside the modern Wayland (labwc) desktop and WayVNC.

Because modern ham radio applications like WSJT-X, JS8Call, FLrig, Pat Winlink, and native modems (ARDOP, Mercury) run natively on 64-bit ARM without Wine overhead, this is now my recommended field-tested setup for Trixie.

Prerequisite: Flash Raspberry Pi OS Trixie (64-bit)

Use the Raspberry Pi Imager to flash a fresh SD card for your Raspberry Pi 5:

  • Operating System: Raspberry Pi OS (64-bit) – Debian Trixie Desktop
  • OS Customisation: Set your hostname (e.g., dl1gkk-pi5-go), username and password, and enter your home Wi-Fi (or iPhone hotspot) credentials so the Pi 5 is online right away.
  • Services: Enable SSH using password authentication.

Insert the SD card, power up the Raspberry Pi 5 using a standard USB-C power supply, and connect via SSH from your computer:

ssh pi@dl1gkk-pi5-go.local

Step 1: Update the System & Enable Native rpi-usb-gadget

Under Trixie, the official rpi-usb-gadget package automatically configures the USB controller (dwc2), CDC-ECM Ethernet emulation (g_ether for iPadOS/macOS), and the corresponding NetworkManager profiles:

sudo apt update && sudo apt full-upgrade -y
sudo apt install -y rpi-usb-gadget
sudo rpi-usb-gadget on

Step 2: Lock the Static DHCP Profile (USB Gadget (shared))

By default, rpi-usb-gadget runs a background service (rpi-usb-gadget-ics.service) that switches between client and shared mode. If it gets stuck in client mode, the Pi 5 and the iPad will only negotiate an unusable link-local IP address (169.254.x.x).

To ensure the Pi 5 always acts as a reliable DHCP server at 10.12.194.1 and shares its Wi-Fi or iPhone hotspot internet connection with the iPad, disable the automatic switcher and lock the shared profile:

sudo systemctl disable --now rpi-usb-gadget-ics.service
sudo nmcli connection modify "USB Gadget (client)" connection.autoconnect no
sudo nmcli connection modify "USB Gadget (shared)" connection.autoconnect yes

Optional Pro-Tip (Keep iPad on its own Wi-Fi/5G): If you want to keep the fixed 10.12.194.1 USB-C link for VNC and SSH while forcing the iPad to stay on its own Wi-Fi or cellular connection instead of routing internet traffic through the Pi, suppress the DHCP gateway and DNS options:

sudo mkdir -p /etc/NetworkManager/dnsmasq-shared.d
sudo tee /etc/NetworkManager/dnsmasq-shared.d/no-gateway.conf > /dev/null << 'EOF'
dhcp-option=3
dhcp-option=6
EOF

Step 3: Hardware Fix for the iPad in the Bootloader EEPROM (CRITICAL!)

When a Raspberry Pi 5 boots while connected directly to an iPad via USB-C, the Pi’s bootloader sends an incomplete USB Power Delivery (USB-PD) request. To protect its battery, iPadOS immediately shuts down the USB 2.0 data lines (D+/D-), leaving usb0 stuck at NO-CARRIER and preventing Ethernet from appearing on the iPad.

Adding PSU_MAX_CURRENT=3000 to the Pi 5 bootloader EEPROM bypasses this negotiation so the iPad enables the USB data link immediately:

rpi-eeprom-config > /tmp/bootconf.txt
grep -q '^PSU_MAX_CURRENT=' /tmp/bootconf.txt && sed -i 's/^PSU_MAX_CURRENT=.*/PSU_MAX_CURRENT=3000/' /tmp/bootconf.txt || echo "PSU_MAX_CURRENT=3000" >> /tmp/bootconf.txt
sudo rpi-eeprom-config --apply /tmp/bootconf.txt

Step 4: Desktop Autologin, WayVNC & Jump Desktop Fix

Trixie runs its desktop on Wayland and uses WayVNC instead of RealVNC. For Jump Desktop on the iPad to connect smoothly in headless mode without TLS/VeNCrypt handshake errors—and with an iPad-friendly 4:3 screen resolution (1366x1024)—apply these four settings:

# 1. Enable Desktop Autologin (required for WayVNC in headless mode)
sudo raspi-config nonint do_boot_behaviour B4

# 2. Enable the WayVNC server
sudo raspi-config nonint do_vnc 0

# 3. Force a compact 1366x1024 resolution for the iPad display
sudo sed -i 's/$/ video=HDMI-A-1:1366x1024@60D/' /boot/firmware/cmdline.txt

# 4. Disable WayVNC encryption/auth so Jump Desktop connects cleanly
sudo sed -i 's/^enable_auth=true/enable_auth=false/' /etc/wayvnc/config

Step 5: Reboot to Flash EEPROM & Perform a Full Cold Boot

IMPORTANT: A simple reboot at the end is not enough—the USB-C controller on the Pi 5 must lose power completely to renegotiate its role with the iPad.

  1. First, reboot the Pi so the EEPROM update is physically written to the bootloader and WayVNC initializes:
    sudo reboot
  2. Wait about 30 seconds, reconnect via SSH, and perform a full shutdown:
    sudo shutdown -h now
  3. LED Check: Wait 1 to 2 minutes until the green activity LED stops blinking completely and only the red power LED stays solid, then unplug the power supply.

Step 6: Connect to the iPad & Launch Jump Desktop

  1. Connect the unpowered Raspberry Pi 5 directly to your unlocked iPad using a high-quality USB-C data cable (do not use a hub or adapter in between).
  2. Wait about 45 seconds for the Pi 5 to boot using the iPad’s power.
  3. Open Settings → Ethernet on your iPad: Raspberry Pi USB Gadget will appear and automatically receive an IP address in the 10.12.194.2–14 range via DHCP.
  4. Open Jump Desktop on your iPad and create a new VNC connection:
    • Address: 10.12.194.1 (or dl1gkk-pi5-go.local)
    • Username & Password: Your Raspberry Pi login credentials (leave the VNC password blank)

Pro-Tip for portable operation: Whenever your Raspberry Pi 5 is connected to your home Wi-Fi or your iPhone’s Personal Hotspot in the field, your iPad automatically receives full internet access through the single USB-C cable while running Jump Desktop and SSH at full wired speed.

Disclaimer: This setup was developed in collaboration with Gemini AI. While we’ve worked hard to make this guide as “bulletproof” as possible, tech is always evolving—errors may occur, or specific functions might need a bit of extra tweaking.

The solution? Don’t hesitate to ask Gemini yourself if you get stuck. Good luck with your build!