🛠 Console série sur USB : la Zero en port série (CDC-ACM)
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
- Zero with Raspberry Pi OS, a micro-USB data cable to the host PC
- 5 V / 1.2 A supply on the power port (the gadget port provides no power)
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
- g_ether and g_serial at the same time: only one gadget configuration unless you build a composite — don't load both blindly.
- A newline inserted in cmdline.txt: the kernel ignores everything after the first line.
- Charge-only micro-USB cables: nothing enumerates at all.
- Forgetting the power cable on the POWER port.
Other tutorials for this board
- Premier démarrage de la Zero avec écran (mini-HDMI)
- Installation headless : la Zero en carte réseau USB (g_ether)
- Alimentation et consommation : le point faible de la Zero
- GPIO en Python : LED et bouton avec gpiozero
- Camera CSI sur Zero v1.3 : le nappe 22 broches
- Sauver une Zero qui ne boot plus : le flux legacy sans EEPROM
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash