Blog Archives

QMI-powered broadband connections in OpenWRT

Linux 3.2 kernel with QMI support

When I started to develop the QMI support in OpenWRT, latest trunk was based on the 3.2 kernel series. By the time you read this, OpenWRT may already have a recent enough kernel (>= 3.4), so this custom setup may not be needed any more, so keep it just for reference.

The ‘v3.2.5-qmi’ branch in the Lanedo stable kernel tree contains a set of patches on top of the 3.2.5. Linux kernel release. These patches add support for QMI ports (updated ‘cdc-wdm’ and new ‘qmi_wwan’ driver) in the 3.2 stable series:


OpenWRT with QMI support

The same set of patches was then added to the ‘qmi-support’ branch of the Lanedo openwrt tree, enabling OpenWRT builds with QMI support:

When you compile this OpenWRT build, make sure you configure the kernel with the QMI-specific requirements enabled:


For reference, you can find here the .config I used for the ar71xx-nand builds (installable in a RouterBoard 433UAH).


libqmi-glib and qmi4g

‘libqmi-glib’ and ‘qmi4g’ are two new packages added to the ‘qmi-support’ branch of the Lanedo openwrt-packages tree:

This repository can be added to your OpenWRT build by creating a new ‘feeds.conf‘ with the following contents:
src-git packages git://;qmi-support

The new packages, in detail:

  • libqmi-glib: This package provides a preliminary version of libqmi-glib, as released unofficially by me. This package will provide the libqmi-glib library, the qmicli command line utility and the qmi-network script.
  • qmi4g: This package registers a new ‘qmi4g‘ network protocol, which takes care of launching the network start/stop requests through QMI.

If you’re using the precompiled OpenWRT images I gave above, you can just install these packages using ‘opkg’ once you’ve added the ‘latest’ Lanedo repository.


Configuring qmi4g

Once the qmi4g package is installed, you are then allowed to include the
following configuration under /etc/config/network:

config 'interface' 'broadband'
option 'ifname' 'wwan0'
option 'proto' 'dhcp'
option 'auto' '0'

config 'interface' 'wdm0'
option 'proto' 'qmi4g'
option 'wdmif' '/dev/cdc-wdm0'
option 'wwanif' 'broadband'

The configuration is split into 2 interfaces:

  1. First, the configuration for the ‘wwan0‘ interface. This interface needs to be set with ‘auto‘ equal to ‘0‘, so that it is never brought up automatically; and with ‘dhcp‘ as the protocol to be used. You should never ifup/ifdown this interface manually.
  2. Second, a virtual interface using the new ‘qmi4g‘ protocol, which needs 2 options set: ‘wdmif‘ with the cdc-wdm port to use for the QMI protocol, and ‘wwanif‘ with the uci-interface-name of the wwan iface to use.


Start/Stop the network

Once the qmi4g setup is added in /etc/config/network, you can now then just:
$> ifup wdm0

That command will internally first launch the network start QMI command, and if succeeds it will itself ifup wwan0. The wwan interface can be used as any other eth-based interface now, it can be added as part of multiwan or in a vlan or in a bonding, or anything.

Once the connection is no longer wanted, you can just:
$> ifdown wdm0

That command will stop the network with QMI and also ifdown wwan0.



Once the network configuration is in place, the connection can also be started via web. Just log in to LUCI, go to Network interfaces and you’ll see both the wwan interface (“broadband“) and the virtual “wdm0“. Starting/Stopping the “wdm0” interface via LUCI should work. As said before, you shouldn’t touch the wwan interface directly.