🛠 Console série sur USB : la Zero en port série (CDC-ACM)

Raspberry Pi Zero (2015) — Board Sheet · intermediaire · Schéma : IMG-zero-intermediaire-2-console-serie-usb-cdc.svg — Zero reliée au port USB d'un PC par son port données, terminal série /dev/ttyACM0 ouvert sur le PC affichant un prompt de login, alimentation externe sur le port POWER.

Goal

Turn the Zero's single data port into a USB serial console (CDC-ACM): plug it into any computer and get a real shell on /dev/ttyACM0 — no network, no display. The OTG port can emulate Ethernet, serial, MIDI or mass storage; this tutorial does the serial half of the classic 'Linux USB stick' build.

Parts

Steps

# 1) Enable the DWC2 OTG controller:
echo "dtoverlay=dwc2" | sudo tee -a /boot/firmware/config.txt

# 2) Load the serial gadget at boot — cmdline.txt stays ONE single line:
sudo sed -i 's/rootwait/rootwait modules-load=dwc2,g_serial/' /boot/firmware/cmdline.txt

# 3) Get a login prompt on the gadget serial port:
sudo systemctl enable --now serial-getty@ttyGS0.service

Reboot, plug the data port into the host, then on the host:

dmesg | tail               # new cdc_acm device
cu -l /dev/ttyACM0         # or: sudo picocom /dev/ttyACM0

Check

The host shows /dev/ttyACM0 (Linux/macOS) or a new COM port (Windows); the terminal asks for a login and uname -a runs on the Zero through it.

Pitfalls

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials