OpenWrt Forum Archive

Topic: TP-Link MR3020 with Huawei E3372

The content of this topic has been archived on 31 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi everyone! I've done a lot of research and finally managed to get this combination working. So I thought sharing my experience could be helpful to others who had issues with the same configuration.

TP-Link MR3020
Huawei E3372h-153 (aka Megafon M150-2)
MicroSD card

Steps:

1. The dongle works at higher efficiency in stick mode.
Convert the dongle from HiLink mode to stick mode: http://blog.asiantuntijakaveri.fi/2015/ … -from.html 
In order to enable the TF card reader, instead of AT^SETPORT="FF;12,16", set new SETPORT value to

AT^SETPORT="FF;12,16,A2"

2. Format the SD card and create a partition in ext4 file system

3. The capacity of the built-in flash memory on the router is only 4MB. A "normal" installation of standard OpenWRT image does not leave enough space for kmod-fs-ext4.
Build a custom image to include necessary packages: https://wiki.openwrt.org/doc/howto/obta … e.generate

make image PROFILE=TLMR3020 PACKAGES="block-mount kmod-fs-ext4 kmod-usb-storage -ppp -ppp-mod-pppoe"

4. Install the custom image on the router.

5. Set computer's IP address to 192.168.1.2 and mask to 255.255.255.0

6. Change the password for root

telnet 192.168.1.1
mount_root
passwd

7. Rootfs on External Storage (extroot): https://wiki.openwrt.org/doc/howto/extroot

8. Install package

kmod-usb-net-huawei-cdc-ncm

9. Plug in the dongle

10. Add network configuration

config interface 'wan'
        option proto 'ncm'
        option device '/dev/cdc-wdm0'
        option ifname 'eth1'
        option apn 'YOUR_APN'
        option pin 'YOUR_PIN' # not necessary if PIN is disabled
        option username 'YOUR_USERNAME' # not necessary if no username is needed
        option password 'YOUR_PASSWORD' # not necessary if no password is needed

11. Include the following script in boot scripts, in order to resolve DHCP issues

echo 6000 > /sys/class/net/wwan0/cdc_ncm/tx_max
echo 0 > /sys/class/net/wwan0/cdc_ncm/min_tx_pkt

Secret sauce found here: https://lists.openwrt.org/pipermail/ope … 33997.html

12. Update zone 'wan' in firewall configurations: /etc/config/firewall

option network 'wan wan_4 wan_6'

13. Reboot

(Last edited by whatUwant on 2 Mar 2016, 23:09)

Hey, thanks for posting this!

I am using the very same Huawei stick, but am having trouble getting connected via cdc-wdm0 ( I can connect OK via /dev/ttyUSB0, but I think that may be slower?)...

Anyway, I have compiled with just the packages you outlined, and at first I was getting no new devices in /dev/

install kmod-usb-net-huawei-cdc-ncm

I think more packages are needed, such as 'chat & comgt-ncm'. When I installed those, I now get cdc-wdm0 show up.

Question, can you list your installed packages? Use this command:

opkg list-installed

Also, you mention running those echo commands in boot scripts. Can you outline exactly how you did that? Somewhere in /etc/init.d/ ?

Thanks for the help!

comgt - 0.32-25
comgt-ncm - 0.32-25
kmod-usb-net - 3.18.27-1
kmod-usb-net-cdc-ncm - 3.18.27-1
kmod-usb-net-huawei-cdc-ncm - 3.18.27-1
kmod-usb-wdm - 3.18.27-1
kmod-usb2 - 3.18.27-1
*udev - 173-1
usb-modeswitch - 2014-08-26-993a9a542791953c4804f7ddbb3a07756738e37a
*usbreset - 4
wwan - 2014-07-17-1

These are the packages I use to get my Huawei e3276 working. The ones marked * are optional. usbreset to help trigger, well, a usb reset of the device if it fails to modeswitch. udev I think has something to do with hotplugging, bit I'm not sure. Also, I am unclear if all these packages are strictly required - trying to get some clarity on this as the NCM functionality may be provided by multiple packages at the same time. Could cause conflict?

And my config is:

config interface 'wan'
    option proto 'ncm'
    option device '/dev/cdc-wdm0'
    option apn 'xxxxx'
    option pincode 'xxxxx'
    option service 'ncm'
    option delay '10'

Issuing "ifup wan" is required if the dongle is plugged in after boot. Not required if plugged in prior to boot. I added in the delay line to allow the dongle to get a signal / sort itself out prior to trying to initiate the openwrt workings. I had it as high as 30 to allow things to settle.

Thanks for that.

I compiled with the packages you outlined, and entered my config, and rebooted. It never connects for me:

Sat Mar 19 21:07:11 2016 daemon.notice netifd: wan (2881): sending -> ATZ
Sat Mar 19 21:07:12 2016 daemon.notice netifd: wan (2881): sending -> ATQ0
Sat Mar 19 21:07:13 2016 daemon.notice netifd: wan (2881): sending -> ATV1
Sat Mar 19 21:07:13 2016 daemon.notice netifd: wan (2881): sending -> ATE1
Sat Mar 19 21:07:14 2016 daemon.notice netifd: wan (2881): sending -> ATS0=0
Sat Mar 19 21:07:14 2016 daemon.notice netifd: wan (2881): sending -> AT+CGDCONT=1,"IPV4V6","3internet"
Sat Mar 19 21:07:15 2016 daemon.notice netifd: wan (2881): Error running AT-command
Sat Mar 19 21:07:15 2016 daemon.notice netifd: wan (2881): Failed to initialize modem
Sat Mar 19 21:07:15 2016 daemon.notice netifd: wan (5168): Stopping network
Sat Mar 19 21:07:17 2016 daemon.notice netifd: wan (5168): sending -> AT^NDISDUP=1,0
Sat Mar 19 21:07:18 2016 daemon.notice netifd: wan (5168): Command failed: Permission denied
Sat Mar 19 21:07:18 2016 daemon.notice netifd: Interface 'wan' is now down
Sat Mar 19 21:07:18 2016 daemon.notice netifd: Interface 'wan' is setting up now
Sat Mar 19 21:07:50 2016 daemon.notice netifd: wan (5179): sending -> 
Sat Mar 19 21:08:05 2016 daemon.notice netifd: wan (5179): Timeout running AT-command
Sat Mar 19 21:08:05 2016 daemon.notice netifd: wan (5179): Failed to connect
Sat Mar 19 21:08:05 2016 daemon.notice netifd: wan (5298): Stopping network
Sat Mar 19 21:08:07 2016 daemon.notice netifd: wan (5298): sending -> 
Sat Mar 19 21:08:10 2016 daemon.notice netifd: Interface 'wan' is now down
Sat Mar 19 21:08:10 2016 daemon.notice netifd: Interface 'wan' is setting up now

Drivers look fine to me:

# cat /sys/kernel/debug/usb/devices

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 1
B:  Alloc=  1/800 us ( 0%), #Int=  1, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 4.04
S:  Manufacturer=Linux 4.4.6 ehci_hcd
S:  Product=EHCI Host Controller
S:  SerialNumber=f1050000.ehci
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
D:  Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=12d1 ProdID=1506 Rev= 1.02
S:  Manufacturer=HUAWEI_MOBILE
S:  Product=HUAWEI_MOBILE
C:* #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=  2mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=03 Prot=12 Driver=(none)
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:  If#= 1 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=03 Prot=16 Driver=huawei_cdc_ncm
E:  Ad=83(I) Atr=03(Int.) MxPS=  16 Ivl=2ms
I:* If#= 1 Alt= 1 #EPs= 3 Cls=ff(vend.) Sub=03 Prot=16 Driver=huawei_cdc_ncm
E:  Ad=83(I) Atr=03(Int.) MxPS=  16 Ivl=2ms
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

I made a mistake in the config above. It should be:

config interface 'wan'
    option proto 'ncm'
    option apn 'XXXXX'
    option username 'XXXXX'
    option password 'XXXXX'
    option device '/dev/cdc-wdm0'
    option delay '10'

I couldn't get any 'mode' option to work, so give that a go if you have included it.

My logread is below. The difference is the command after ATS0=0. I've got "AT^NDISDUP=1,1,", you've got "AT+CGDCONT=1"

Not sure where that is coming from.

Sun Mar 20 17:45:32 2016 daemon.notice netifd: Interface 'wan' is setting up now
Sun Mar 20 17:45:44 2016 daemon.notice netifd: wan (7407): sending -> AT
Sun Mar 20 17:45:45 2016 daemon.notice netifd: wan (7407): sending -> ATZ
Sun Mar 20 17:45:46 2016 daemon.notice netifd: wan (7407): sending -> ATQ0
Sun Mar 20 17:45:46 2016 daemon.notice netifd: wan (7407): sending -> ATV1
Sun Mar 20 17:45:47 2016 daemon.notice netifd: wan (7407): sending -> ATE1
Sun Mar 20 17:45:47 2016 daemon.notice netifd: wan (7407): sending -> ATS0=0
Sun Mar 20 17:45:48 2016 daemon.notice netifd: wan (7407): sending -> AT^NDISDUP=1,1,"everywhere","eesecure","secure"
Sun Mar 20 17:45:49 2016 daemon.notice netifd: wan (7407): Connected, starting DHCP
Sun Mar 20 17:45:49 2016 daemon.notice netifd: Interface 'wan' is now up
Sun Mar 20 17:45:49 2016 daemon.notice netifd: Network device 'wwan0' link is up
Sun Mar 20 17:45:49 2016 daemon.notice netifd: Network alias 'wwan0' link is up
Sun Mar 20 17:45:49 2016 daemon.notice netifd: Interface 'wan_4' is enabled
Sun Mar 20 17:45:49 2016 daemon.notice netifd: Interface 'wan_4' has link connectivity 
Sun Mar 20 17:45:49 2016 daemon.notice netifd: Interface 'wan_4' is setting up now
Sun Mar 20 17:45:49 2016 daemon.notice netifd: wan (7407): Command failed: Unknown error
Sun Mar 20 17:45:49 2016 daemon.notice netifd: Interface 'wan_6' is enabled
Sun Mar 20 17:45:49 2016 daemon.notice netifd: Interface 'wan_6' has link connectivity 
Sun Mar 20 17:45:49 2016 daemon.notice netifd: Interface 'wan_6' is setting up now
Sun Mar 20 17:45:49 2016 daemon.notice netifd: wan (7407): Command failed: Unknown error
Sun Mar 20 17:45:49 2016 daemon.notice netifd: wan_4 (7449): udhcpc (v1.23.2) started
Sun Mar 20 17:45:49 2016 user.notice firewall: Reloading firewall due to ifup of wan (wwan0)
Sun Mar 20 17:45:49 2016 daemon.notice netifd: wan_4 (7449): Sending discover...
Sun Mar 20 17:45:52 2016 daemon.notice netifd: wan_4 (7449): Sending discover...
Sun Mar 20 17:45:52 2016 daemon.notice netifd: wan_4 (7449): Sending select for 10.87.152.96...
Sun Mar 20 17:45:52 2016 daemon.notice netifd: wan_4 (7449): Lease of 10.87.152.96 obtained, lease time 518400
Sun Mar 20 17:45:52 2016 daemon.notice netifd: Interface 'wan_4' is now up

Actually, I see that command in gcom/ncm.json under the Samsung sections.

I wonder why it's not using the Huawei section?

Do you have other dongle types installed that might conflict?

tristanc wrote:

I made a mistake in the config above.

Aha! That was the issue. It's working now, once I removed that 'service' option. Great! Here is my config for Three Ireland:

config interface 'wan'
    option proto 'ncm'
    option device '/dev/cdc-wdm0'
    option apn '3internet'
    option delay '10'
    option ipv6 '0'
    option username ''
    option password ''

I am running on a 'Linksys E4200v2 / EA4500' with kernel 4.4.6. Thanks again!

Hi everyone,

the discussion here is actually exactly what I want to achieve (MR3040 & E3372h).

My results so far (with a custom image based on trunk r49161):

Somehow gcom-ncm does not seem to work.

As far as I understand the problem is:
ncm.sh tries to identify the manufacturer via gcom, but does not receive any response from the modem.
Due to the empty response it does not choose a correct initialization command to send to the modem.
It then sends an empty string as initialization and nothing happens.

However, once I plug the stick in, an interface wwan0 shows up. If I configure that as dhcp and initiate the connection with
echo -e "AT^NDISDUP=1,1,\"drei.at\"\r" > /dev/cdc-wdm0
then everything works fine.

Does anyone have a clue why the 'official' way does not work? Why can't gcom receive anything from the modem?
I'm quite new to OpenWrt - am I missing something obvious here?

Can I join this discussion? I also need to get exactly the same setup happening (MR3020 and Huawei E3372)

So far I have managed to get the setup to work... but noticed only 3G connection. So not able to take advantage of the full speed of LTE and the ample LTE quota that my mobile provider provides.

I have also tried to do the same modem (E3372) with a used Huawei HG556a router, all with unfortunately the same result (only 3G is active).

Will try your settings and inform what happens soon. Thanks!

During the last months I have been playing around quite a bit with this and have now reached a configuration which works great for me:

I'm using current trunk with an MR3040, GL-AR150 and an Archer C7:

1. Set the Huawei Stick up in Non-HiLink Mode and only activate the necessary Ports (see 1st post here):

AT^SETPORT="FF;12,16,A2"

The additional SD-Cardreader (A2) might be useful at one point even if I'm not using it yet.

2. Build a custom Image without PPP and IPv6 and include the modules for the Huawei (i choose both the ones for HiLink and Non-HiLink, just in case).
For my the MR3040 the basics are:

make image PROFILE="TLMR3040" PACKAGES="luci kmod-usb-net-huawei-cdc-ncm kmod-usb-net-rndis -ip6tables -odhcpd -odhcp6c -ppp -ppp-mod-pppoe"

(for the 16MB-devices I don't delete the packages and build in some other useful stuff)

3. In current trunk both the proto 'wwan' and proto 'ncm' do not work for me. With the above minimum package selection they are not even installed. (The package comgt-ncm would provide everything if someone wants to test)
See the issue I filed for details: github .com/openwrt/openwrt/issues/84 (sorry, no links allowed)
Therefore I decided to brew my own connection script, it is rather quick&dirty, but works fine so far.

I called it ncm2.sh and it has to go under /lib/netifd/proto/

#!/bin/sh

. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"

proto_ncm2_init_config() {
    available=1
    proto_config_add_string "device:device"
    proto_config_add_string apn
    proto_config_add_boolean defaultroute
    proto_config_add_boolean peerdns
    proto_config_add_int metric
}

proto_ncm2_setup() {
    local config="$1"
    local iface="$2"

    local device apn defaultroute peerdns metric
    json_get_vars device apn defaultroute peerdns metric

    [ -n "$device" ] || {
        echo "No control device specified"
        proto_notify_error "$config" NO_DEVICE
        proto_set_available "$config" 0
        return 1
    }
    [ -e "$device" ] || {
        echo "Control device not valid"
        proto_set_available "$config" 0
        return 1
    }
    [ -n "$apn" ] || {
        echo "No APN specified"
        proto_notify_error "$config" NO_APN
        return 1
    }

    echo -e "ATZ\r" >$device
    sleep 5
    echo -e "AT^NDISDUP=1,1,\"$apn\"\r" >$device
    sleep 5

    echo "Connected, starting DHCP on $iface"

    proto_init_update "$iface" 1
    proto_send_update "$config"

    json_init
    json_add_string name "${config}_4"
    json_add_string ifname "@$config"
    json_add_string proto "dhcp"
    [ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute"
    [ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns"
    [ -n "$metric" ] && json_add_int metric "$metric"
    ubus call network add_dynamic "$(json_dump)"
}

proto_ncm2_teardown() {
    local config="$1"

    local device
    json_get_vars device

    [ -n "$device" ] || {
        echo "No control device specified"
        proto_notify_error "$config" NO_DEVICE
        proto_set_available "$config" 0
        return 1
    }
    [ -e "$device" ] || {
        echo "Control device not valid"
        proto_set_available "$config" 0
        return 1
    }

    echo "Stopping network"

    echo -e "AT^NDISDUP=1,0\r" >$device

    proto_init_update "*" 0
    proto_send_update "$config"
}

add_protocol ncm2

I don't use a PIN with my sim, so I don't have that included in the script, but this could easily be added.
Refer to
github .com/openwrt/openwrt/blob/master/package/network/utils/comgt/files/ncm.sh
and
github .com/openwrt/openwrt/blob/master/package/network/utils/comgt/files/ncm.json
for how the connection-string should be made up.

Finally i put the following in my /etc/network/config

config interface 'lte'
    option ifname 'wwan0'
    option proto 'ncm2'
    option device '/dev/cdc-wdm0'
    option apn 'drei.at'

and because my provider disconnects every 24h, I have a daily 5AM reboot in my crontab.
(Disconnecting and reconnecting the Stick with AT^NDISDUP=1,0 and 1,1 does not get it reconnected. Sending AT^RESET does as it reboots the stick, but I thought a daily router-reboot might be good anyway)

The discussion might have continued from here.