Pavel Piatruk’ tech & personal blog

Quectel EC200T on OpenWRT

The issue with EC200T that it doesn’t have QMI\MBIM. It has only ECM and AT-port , so we have to start WAN connection on AT-port and use it via the WAN port.

Install some packages

opkg update
opkg install kmod-usb-net-cdc-ether kmod-usb-serial-option usbutils socat 
  • kmod-usb-net-cdc-ether for WWAN netcard device
  • kmod-usb-serial-option for /dev/ttyUSB* devices
  • usbutils for lsusb
  • socat for sending AT commands.

Plug in the module (EC200T) in USB, wait ~30sec, run lsusb, interesting line is

Bus 002 Device 005: ID 2c7c:6026 Quectel Wireless Solutions Co., Ltd. 

Vendor and Product ID are 2c7c:6026 , so bind USB-OPTION driver to the device.

echo  2c7c 6026 ff > /sys/bus/usb-serial/drivers/option1/new_id

Check if ttyUSB character devices are added:

ls /dev/ttyUSB*

Output:

crw-rw----    1 root     dialout   188,   0 Dec 16 10:46 /dev/ttyUSB0
crw-rw----    1 root     dialout   188,   1 Dec 16 10:46 /dev/ttyUSB1
crw-rw----    1 root     dialout   188,   2 Dec 16 10:46 /dev/ttyUSB2

Check if USB WWAN net card is added as usb0

ip  li  show

Output contains usb0.

For EC200T, AT port sits on /dev/ttyUSB1. Let’s talk there.

AT_PORT=/dev/ttyUSB1
SOCAT_RUN="socat - $AT_PORT,crnl"
echo ATE0 | $SOCAT_RUN
echo ATI | $SOCAT_RUN

Output:

Quectel
EC200T
Revision: EC200TEUHAR05A01M16

OK now let’s create a WAN interface with DHCP client.

Edit /etc/config/network , add

config interface 'QUECTEL_EC200T'
        option proto 'dhcp'
        option ifname 'usb0'
        option metric '200'

Then restart the network /etc/init.d/network restart , Openwrt will start sending DHCP requests on usb0 but it will not respond (yet).

Add a file /etc/init.d/quectel_EC200 and paste the content and make it 755

#!/bin/sh /etc/rc.common

START=98

start(){

set -x
echo Start

AT_PORT=/dev/ttyUSB1
DEV=usb0
SOCAT_RUN="socat - $AT_PORT,crnl"

if test -c $AT_PORT
then echo port ready
else
	echo  2c7c 6026 ff > /sys/bus/usb-serial/drivers/option1/new_id
	echo sleep till port is ready
	sleep 30
	for i in $(seq 10);
	do
	    test -c $AT_PORT && break
	    echo .
	    sleep 10
	done
fi

test -c $AT_PORT || { echo "$AT_PORT cant be found, exit"; return 22; }

echo ATE0 | $SOCAT_RUN
echo ATI | $SOCAT_RUN
echo 'AT+QCFG="usbnet"' | $SOCAT_RUN
echo at+cgdcont? | $SOCAT_RUN
echo at+cgatt? | $SOCAT_RUN
echo at+cgact? | $SOCAT_RUN
echo at+cgact=1,1 | $SOCAT_RUN
echo AT+CGCONTRDP=1 | $SOCAT_RUN
echo AT+QNETDEVCTL=1,1,1 | $SOCAT_RUN ;  sleep 1
echo AT+QNETDEVCTL=1,1,1 | $SOCAT_RUN ;  sleep 1
echo AT+QNETDEVCTL=1,1,1 | $SOCAT_RUN ;  sleep 1
echo AT+QNETDEVCTL? | $SOCAT_RUN

}

stop(){
    echo Stop
}

Run it, it will connect the module to Internet

/etc/init.d/quectel_EC200 start

and DHCP client in previous step will obtain an IP, so expect a new default gateway, with metric 200. Then check routing table

ip ro

Output:

...
default via 10.56.99.192 dev usb0  src 10.56.99.63  metric 200
...

Then enable its autostart, edit /etc/hotplug.d/usb/10-quectel_ec200.sh and paste the content and make it 755

#!/bin/sh

[ "$ACTION" = add -a "$DEVTYPE" = usb_device ] || exit 0

vid=$(cat /sys$DEVPATH/idVendor)
pid=$(cat /sys$DEVPATH/idProduct)

if [[ $vid == 2c7c ]] && [[ $pid == 6026 ]]
then	true
else	exit
fi

sleep 30 
/etc/init.d/quectel_EC200 restart 2>&1 | logger -t quectel_EC200

Reboot the router, Quectel EC200T will be online.

Summary of the flow:

  • plug in the module
  • hotplug will init the module and connect it online
  • Openwrt will detect its interface and start DHCP on it

Further reading: