Cellular modules that are based on the Qualcomm chipsets support the QMI interface. The libqmi can be used to establish QMI interface for mini PCIe modules such as Quectel EC25, EG25-G, EC21, UC20-G and Telit LE910C1, LE910C4 with the Raspberry Pi 3G/4G & LTE Base HAT.
This is a brief tutorial to establish the connection, reference sites are listed at the end of the tutorial.
Please note that the below tutorial assumes that you have already completed your hardware setup, if not please follow getting started.
Before we start, check the compatibility of the module.
should return driver information such as qmi-wwan(opensource) or GobiNet(provided by Qualcomm) as shown below. Both drivers work fine with the libqmi.
|__ Port 4: Dev 6, If 4, Class=Vendor Specific Class, Driver=qmi_wwan, 480M
Before running the PPP/QMI make sure the module is configured to the right settings.
For Quectel Modules:
AT+QCFG="usbnet" should return 0, otherwise,send AT+QCFG="usbnet",0 then reboot the module after 10 seconds AT+CFUN=1,1
For Telit Modules:
AT#USBCFG? should return 0, otherwise,send AT#USBCFG=0 then reboot the module after 10 seconds ,AT#REBOOT
For sending AT commands, you may check the Sending AT Commands tutorial.
First, install the required packages.
sudo apt update && sudo apt install libqmi-utils udhcpc
libqmi-utils installs two main utilities (qmi-cli tool and qmi-network helper script), these are used for interaction with the modem (for more details check man qmi-cli)
Now make sure the module is ready, this can be done using the following command.
sudo qmicli -d /dev/cdc-wdm0 --dms-get-operating-mode
This should return online if not try
sudo qmicli -d /dev/cdc-wdm0 --dms-set-operating-mode='online'
Now configure the network interface for the raw-ip protocol.
sudo ip link set wwan0 down
echo 'Y' | sudo tee /sys/class/net/wwan0/qmi/raw_ip
sudo ip link set wwan0 up
One can confirm the data format using
sudo qmicli -d /dev/cdc-wdm0 --wda-get-data-format
Once the wwan0 is up, connect the mobile network by changing the apn='YOUR_APN',username='YOUR_USERNAME',password='YOUR_PASSWORD' part of the line according to the information of your SIM & operator. If username and password are not required, delete those parameters.
sudo qmicli -p -d /dev/cdc-wdm0 --device-open-net='net-raw-ip|net-no-qos-header' --wds-start-network="apn='YOUR_APN',username='YOUR_USERNAME',password='YOUR_PASSWORD',ip-type=4" --client-no-release-cid
Lastly, configure the IP address and the default route with udhcpc.
sudo udhcpc -q -f -i wwan0
Now check the assigned IP address and test the connection.
It is worth reading we recommend going through the section on troubleshooting as it covers the more common issues with establishing and maintaining a network connection. Please check out the troubleshooting guide.