🛠 Monter un point d'accès 4G avec le module Quectel EC20 du port mini-PCIe
Objectives
The BPI-CM4IO carrier exposes PCIe, USB 2.0, and a micro-SIM slot on its mini-PCIe port: the vendor wiki explicitly documents a Quectel EC20 LTE module as a WAN gateway (qmi_wwan driver, quectel-CM tool, pppd fallback, AT port on /dev/ttyUSB2). You will install the module, create the wwan0 interface, connect to the carrier, and then enable NAT sharing to turn the BPI-CM4 into a backup 4G router.
Hardware
- BPI-CM4 + BPI-CM4IO running Armbian or the vendor image
- Quectel EC20 module in mini-PCIe format
- Data micro-SIM card (PIN disabled preferred) + 2 u.FL antennas
- Ethernet cable to the local network to serve
Complete Code
# 1) Carrier éteint : insérer l'EC20, la micro-SIM, visser les 2 antennes u.FL.
sudo apt update && sudo apt install -y usbutils ppp curl minicom
lsusb | grep -i quectel # ID vendeur 2c7c attendu
ls /dev/ttyUSB* # port AT = /dev/ttyUSB2
# 2) Diagnostic AT
sudo minicom -D /dev/ttyUSB2 -b 115200
# AT+CPIN? -> READY (sinon : AT+CPIN="1234")
# AT+CSQ -> qualité du signal (ex. 22,99)
# AT+COPS? -> opérateur enregistré
# 3) Mode QMI : charger le pilote et monter wwan0
sudo modprobe qmi_wwan
ip -br link | grep wwan
# quectel-CM : outil officiel Quectel (miroirs GitHub), compilé sur la carte
cd quectel-CM && make && sudo ./quectel-CM &
sudo dhclient wwan0
curl -s --interface wwan0 https://ifconfig.me
# 4) NAT WAN(wwan0) vers LAN(eth0)
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -A POSTROUTING -o wwan0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wwan0 -j ACCEPT
sudo iptables -A FORWARD -i wwan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
Expected Verification
AT+CSQ returns a usable signal quality (above approximately 15); wwan0 obtains an address from the carrier; curl --interface wwan0 displays the public 4G IP; a machine connected to the BPI's eth0 accesses the Internet via 4G. Throughput remains limited by the EC20 and signal strength, not by the local GbE connection.
Common Errors
- Forgetting the u.FL antennas: without them, the EC20 cannot find any cell (CSQ 99).
- SIM with a PIN code: the module remains blocked until AT+CPIN responds.
- Confusing serial ports: AT commands are not on ttyUSB0 but typically on ttyUSB2.
- Not loading qmi_wwan (or leaving the module in a non-QMI mode): no wwan0 interface appears.
- Not persisting ip_forward or iptables rules: NAT disappears after reboot — write a dedicated systemd service.
- Believing the module is connected via PCIe: the EC20 communicates over the USB 2.0 signal from the connector.
Other tutorials for this board
- Monter le module BPI-CM4 sur son carrier et réussir le premier boot
- Apprivoiser les LED et la touche ADC du carrier CM4IO
- Mesurer le stockage du BPI-CM4 : eMMC, microSD et le palier NVMe
- Activer I2C, SPI et UART sur le BPI-CM4 : env.txt ou armbianEnv.txt
- Brancher un capteur BME280 sur l'I2C1 du carrier (GPIOX_17/18)
- Déplacer le rootfs sur un SSD NVMe via le port mini-PCIe
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash