https://howchoo.com/pi/raspberry-pi-gadget-mode HomeInterestsSign UpSign In [ ] HomeInterests Share FacebookRedditTwitterPinterestEmailText message Discuss 6 Favorite 2 You'll Need HomeInterestsRaspberry Pi Connect to Your Raspberry Pi Over USB Using Gadget Mode Raspberry Pi Gadget ModeRaspberry Pi Gadget Mode Program your Pi without a keyboard, monitor, or network connection JohnJohn John (304) Apr 6, 2021 20 minutes Share FacebookRedditTwitterPinterestEmailText message Discuss Favorite 6 You'll Need 2 We've written previously about how to configure WiFi and SSH on your Raspberry Pi without having to connect any peripheral devices (headless). As long as you're comfortable on the command line, this makes it much easier to work with your Pi. How to Set up WiFi on Your Raspberry Pi Without a Monitor (Headless) How to Set up WiFi on Your Raspberry Pi Without a Monitor (Headless) How to Set up WiFi on Your Raspberry Pi Without a Monitor (Headless) No monitor, keyboard, or mouse? No problem. How to Enable SSH on Raspberry Pi OS Without a ScreenHow to Enable SSH on Raspberry Pi OS Without a Screen How to Enable SSH on Raspberry Pi OS Without a ScreenThe SSH protocol is disabled by default. Now, I've been doing projects with Raspberry Pi's since the first version, and I only recently found out about a Linux feature that allows you to connect to the Pi directly over USB: it's called USB gadget mode. With "gadget mode" enabled, we don't need to configure the WiFi network or connect any peripheral devices, we simply connect the Pi to our computer with a USB cable, and now we've got SSH access. In this guide, I'll show you how enable gadget mode and connect to your Pi via USB. Note: I believe this feature was initially enabled for the Pi Zero, and it does not work on earlier versions of the Pi. I have, however, tested with the Raspberry Pi 4, and it works as long as you connect via the USB-C connector. What You'll Need Interests Raspberry Pi Zero WRaspberry Pi Zero W Raspberry Pi Zero W x 1 Micro-USB to USB-C cable, 6"Micro-USB to Micro-USB to USB-C x 1 USB-C cable, 6" cable, 6" Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links. Table of Contents Jump to step: 1. Flash Raspberry Pi OS onto your SD card 2. Edit config.txt on the boot partition 3. Enable SSH 4. Edit cmdline.txt 5. Connect over USB and boot the Pi Share FacebookRedditTwitterPinterestEmailText message Discuss 6 Favorite 2 You'll Need In these interests [zjnjmgiyot][place] Subscribe Raspberry Pi h/pi * 253 guides [mjazogi2nz][place] Subscribe Linux h/linux * 41 guides 1 Flash Raspberry Pi OS onto your SD card First we need to flash Raspberry Pi OS onto an SD card. If you need help with this process, please follow our guide on how to install Raspberry Pi OS on your Raspberry Pi. How to Install Raspberry Pi OS on Your Raspberry PiHow to Install Raspberry Pi OS on Your Raspberry Pi How to Install Raspberry Pi OS on Your Raspberry PiGet the new official Raspberry Pi OS on your Pi. 2 Edit config.txt on the boot partition With Raspberry Pi OS installed on the SD card (and the SD card still mounted on your computer), you can use Finder or a shell to navigate to the boot directory. Now edit the file called config.txt, and append the following: dtoverlay=dwc2 Save and exit. 3 Enable SSH We can SSH by simply adding an empty file called ssh directly in the boot directory. On the command line, you can navigate to the boot directory and run: touch ssh Note: The file must be called "ssh" not "SSH" or "ssh.txt" or anything other than "ssh". 4 Edit cmdline.txt Now, edit the file called cmdline.txt. Look for rootwait, and add modules-load=dwc2,g_ether immediately after. Note the formatting of cmdline.txt is very strict. Commands are separated by spaces, and newlines are not allowed. Here's an example of what my cmdline.txt file looks like, but you should not copy this. Simply add the required command mentioned above. console=serial0,115200 console=tty1 root=PARTUUID=6c586e13-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet init=/usr/lib/raspi-config/init_resize.sh Save and exit. 5 Connect over USB and boot the Pi That's it for configuration! Now you can eject the SD card, and insert it into the the Pi. Using a USB cable, connect to the Raspberry Pi from your computer. After the Pi boots up (this will take a while initially), the Pi should appear as a USB Ethernet device, and you can SSH into it using: ssh pi@raspberrypi.local Enjoy! Share FacebookRedditTwitterPinterestEmailText message Discuss Favorite You'll Need NEXT UP How to Setup a Raspberry Pi Wireless Access Point Raspberry Pi Wireless Access PointRaspberry Pi Wireless Access Point BenBen Ben (11) Nov 19, 2020 0 Most users will be looking to use the on-board Wi-Fi to connect a Raspberry Pi to existing wireless networks. Continue reading Share FacebookRedditTwitterPinterestEmailText message Discuss Favorite You'll Need Share this guide! * Facebook * Twitter * Reddit * Email * Text * Pinterest John's profile pictureJohn's profile pictureJohn Joined in 2015 304 guides Software Engineer and creator of howchoo. Related to this guide: Raspberry Pi Wireless Access PointRaspberry Pi Wireless Access Point How to Setup a Raspberry Pi Wireless Access Point Most users will be looking to use the on-board Wi-Fi to connect a Raspberry Pi to existing wireless networks. Ben's profile pictureBen's profile picture BenView guide In these interests: routerpi Raspberry Pi SSHRaspberry Pi SSH How to Connect to a Raspberry Pi Remotely via SSH The preferred (and most common) method of connecting to your Pi to run commands. John's profile pictureJohn's profile picture JohnView guide In these interests: linuxpi Setting up Bluetooth on a Raspberry PiSetting up Bluetooth on a Raspberry Pi How to Set Up Bluetooth on a Raspberry Pi The only Raspberry Pi Bluetooth guide you'll ever need. Ben's profile pictureBen's profile picture BenView guide In these interests: pi People also read: Raspberry Pi commandsRaspberry Pi commands The Most Common Raspberry Pi Commands (And What They Do) Taking control of your Pi is easy! [zdjiymm1yt][placeholde] How to Set Up a New Raspberry Pi Start using that brand new Pi! How to Boot Your Raspberry Pi 4 From a USB DriveHow to Boot Your Raspberry Pi 4 From a USB Drive How to Boot Your Raspberry Pi 4 From a USB Drive [default-sq][placeholde] How to Change Raspberry Pi Hostname (Rename Your Pi) Raspberry Pi 3, Pi Zero, and USB WiFi dongleRaspberry Pi 3, Pi Zero, and USB WiFi dongle How to Set up WiFi on Your Raspberry Pi Without a Monitor (Headless) No monitor, keyboard, or mouse? No problem. [yzjhyzfknt][placeholde] How to Set up Your Raspberry Pi Without a Keyboard, Monitor, or Mouse Raspberry Pi vintage computer emulationRaspberry Pi vintage computer emulation Retro Computing on the Raspberry Pi: Vintage Computers You Can Emulate We're gonna compute like it's 1989. Raspberry Pi all-in-one keyboardRaspberry Pi all-in-one keyboard Hacking the Official Raspberry Pi Keyboard: Build a Battery-Powered All-In-One Pi Keyboard! Talk about compact. [ytkzzdg0zd][placeholde] Create a Raspberry Pi MIDI keyboard synthesizer Start your digital music career today. Raspberry Pi power buttonRaspberry Pi power button How to Add a Power Button to Your Raspberry Pi Because you should always safely shut down your Pi. Posted in these interests: pipi ExploreSubscribe Raspberry Pi h/pi * 253 guides The Raspberry Pi is a small, inexpensive computer developed by the Raspberry Pi Foundation in the United Kingdom. linuxlinux ExploreSubscribe Linux h/linux * 41 guides Discuss this guide! Discover interesting things! Explore Howchoo's most popular interests. Explore ExploreShopJobsWrite for us!Our teamContact us Follow @howchoo and learn cool things: FacebookYouTubeInstagramTwitter Are you a passionate writer? We're hiring! Write for Howchoo Like what we do? Donate (c)2023 Howchoo, LLC SitemapTerms of usePrivacy policyDMCA requestsDo not sell my personal information Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.