🛠 Console série sur USB-OTG : dépanner sans réseau ni câble UART
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
- BPI-M2 Zero running Armbian (
ttyGS0already declared as a console by the board definition) - Micro-USB data cable (not a charge-only cable without data conductors)
- A Linux PC (on Windows: native CDC-ACM driver, then a terminal on the COM port)
- Initial access to the board (SSH, CON3, or an open session) to arm the gadget
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
- Plugging the cable into the "Power only" micro-USB port: no data lines, so no
ttyACM0— the OTG port is the other one. - Cheap charge-only cable without data pins: the gadget exists but nothing appears on the PC.
- Powering the board from the PC while a charger is connected to the other port: the Vbus lines of the two micro-USB connectors are linked, resulting in two sources competing for the 5 V.
- Forgetting to arm
g_serialBEFORE losing network access: if the system no longer boots, the CON3 console (115200 8N1) remains available. - Looking for
ttyGS0on the PC side:ttyGS0is the name on the board side; on the PC side, it isttyACM0.
Other tutorials for this board
- Flasher Armbian et premier boot du BPI-M2 Zero
- LED et bouton avec libgpiod sur le port 40 broches
- Wi-Fi AP6212 : le piège de l'antenne U.FL non fournie
- Activer le bus SPI0 et piloter un petit écran TFT
- Survivre avec 512 Mo : zram, swap compressé et services légers
- Câbler l'Ethernet 10/100 EMAC avec le carrier Zero-EPHY
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash