QMI interface using libqmi

Cellular modules that are based on the Qualcomm chipsets support the QMI interface. libqmi can be used to establish QMI interface for mini PCIe modules such as Quectel EC25, Quectel EC21, Telit LE910C4, Telit LE910C1 with the Raspberry Pi 3G, 4G/LTE Base HAT.

This is a minimal tutorial to establish the connection, Reference sites are listed at the end of the tutorial.

We are starting assuming you have done your hardware setup, if not please follow getting started.

Before we start, check the compatibility of the module.
lsusb -t
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

NOTE: In case of the driver error please refer to the driver guide of the modules.

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 with 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.

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. This will be a non-ending command.

sudo udhcpc -q -f -i wwan0

Open a new terminal and check the
ifconfig wwan0
and test the interface with
ping -I wwan0 -c 5


  1. https://www.freedesktop.org/wiki/Software/libqmi/

  2. https://www.raspberrypi.org/forums/viewtopic.php?f=36&t=224355&p=1703897&hilit=4g+module#p1703897

Updated about a month ago

QMI interface using libqmi

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.