Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!

Ben Hardill Pens a New Guide to Getting a Raspberry Pi 5 Talking in USB Gadget Mode

With new hardware and a new operating system comes a new way to do things — but USB Gadget support is still very much on the table.

Gareth Halfacree
12 months agoHW101

Developer Ben Hardill has penned a guide to using the new Raspberry Pi 5 as a USB Type-C Gadget — after the release of both the new hardware and the Debian Bookworm-based Raspberry Pi OS rendered old guides obsolete.

The USB Type-C port on a Raspberry Pi 5, released late last year as a major upgrade for the popular single-board computer family and boasting a considerably more powerful processor and new PCI Express connectivity for high-speed peripherals, is typically used to provide power to the board — but hides a secondary function: the ability to work in USB Gadget mode, connecting the Raspberry Pi to a host computer over USB.

The functionality has existed in Raspberry Pi models for years, but the Raspberry Pi 5 hardware coupled with the new version of Raspberry Pi OS released at the same time means existing guides for configuring USB Gadget mode don't apply. That's where Hardill's new guide, brought to our attention by Adafruit, comes in.

Hardill's updated guide provides full step-by-step instructions on using USB Gadget mode on any Raspberry Pi 5 model using the official Debian Bookworm-based Raspberry Pi OS software — starting with updating the firmware and including configuring the kernel and configuring libcomposite. A Bash script is provided for creating two USB Ethernet interfaces, which are then managed using NetworkManager — the new OS having moved away from dhcpd.

"I'm working on updating my script that automatically updates Raspberry Pi OS SD Card images with these changes before they are flashed to the card," Hardill notes, "but I'm having problems getting the new images to boot in the dockerpi containers (this runs the image in an Arm emulator so we can run the install scripts properly for dnsmasq). I'll probably post again if/when I get it working."

Hardill's full guide is available on his website.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles