🛠 Console série sur USB-OTG : dépanner sans réseau ni câble UART

Banana Pi BPI-M2 Zero (Allwinner H2+ / H3) · intermediaire · Schéma : IMG-bananapi-m2-zero-intermediaire-1-console-serie-otg-ttygs0.svg — BPI-M2 Zero reliée par un câble USB à un ordinateur portable via son port OTG ; sur l'écran du PC, un terminal picocom ouvert sur /dev/ttyACM0 ; la puce du gadget CDC-ACM est surlignée sur la carte.

Objectives

When Wi-Fi is misconfigured or the network is broken, the BPI-M2 Zero has a trump card: its micro-USB OTG port (dr_mode = "otg" in the device tree) can masquerade as a serial device. The board's Armbian configuration preloads the g_serial module and declares ttyGS0 as a console (SERIALCON="ttyS0,ttyGS0"): when connected directly to a PC, the board enumerates a CDC-ACM port — no USB-serial cable or network required. This is the rescue method to know before breaking your configuration.

Hardware

Complete Code

# Sur la carte (via SSH ou CON3) : charger le gadget et exposer un getty
sudo modprobe g_serial
sudo systemctl enable --now serial-getty@ttyGS0.service
# Rendre le module permanent pour les prochains sauvetages
echo g_serial | sudo tee /etc/modules-load.d/gserial.conf

# Sur le PC : un /dev/ttyACM0 apparaît dès que le câble OTG est branché
sudo apt install -y picocom
picocom -b 115200 /dev/ttyACM0      # invite de login du BPI-M2 Zero

# En cas de plantage réseau, vérifier côté carte quel rôle prend le port
dmesg | grep -i -e gadget -e ttyGS0

Expected Verification

As soon as the cable is inserted into the OTG port, the PC detects a USB serial device (lsusb lists it); picocom displays the login prompt; after logging in, the who command shows a session on ttyGS0. The board remains accessible even with a misconfigured wlan0.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials