Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:network:wan:wwan:ethernetoverusb_ncm [2018/03/04 16:34] – ↷ Links adapted because of a move operation docs:guide-user:network:wan:wwan:ethernetoverusb_ncm [2024/11/17 11:17] – [Network configuration] andrewz
Line 1: Line 1:
 ====== Use NCM USB Dongle for WAN connection ====== ====== Use NCM USB Dongle for WAN connection ======
  
-[[http://www.mcci.com/mcci-v5/hostside/ncm_drivers.html|NCM]] (Network Control Model) is [[https://en.wikipedia.org/wiki/Ethernet_over_USB|ethernet over USB]] protocol used by some fast speed USB modems/dongles.+[[http://www.mcci.com/mcci-v5/hostside/ncm_drivers.html|NCM]] (Network Control Model) is [[https://en.wikipedia.org/wiki/Ethernet_over_USB|Ethernet over USB]] protocol used by some USB modems.
  
-For more information about different protocols used: +The same applies to external modems connected to USB ports ("dongles") and internal models installed into M.2(NGFF) or mPCIe slots. 
-  * **ppp**, see [[docs:guide-user:network:wan:wwan:3gdongle|How to use 3g/UMTS USB Dongle for WAN connection]] + 
-  * **qmi** and **mbim**, see [[docs:guide-user:network:wan:wwan:ltedongle|How to use LTE modem in QMI mode for WAN connection]] +For more information about other protocols commonly used: 
-  * **rndis**, see [[docs:guide-user:network:wan:wwan:ethernetoverusb_rndis|How to use LTE modem in RNDIS mode for WAN connection]]+  * **PPP**, see [[docs:guide-user:network:wan:wwan:3gdongle|How to use 3g/UMTS USB Dongle for WAN connection]] 
 +  * **QMI** and **MBIM**, see [[docs:guide-user:network:wan:wwan:ltedongle|How to use LTE modem in QMI mode for WAN connection]] 
 +  * **ECM**, see [[docs:guide-user:network:wan:wwan:ethernetoverusb_cdc|Use cdc_ether driver based dongles for WAN connection]] 
 +  * **RNDIS**, see [[docs:guide-user:network:wan:wwan:ethernetoverusb_rndis|How to use LTE modem in RNDIS mode for WAN connection]]
  
 ===== Modem Preparation ===== ===== Modem Preparation =====
-You need to switch modem to provide native **NCM** interface instead of **Modem** interface.+You may need to switch your modem to provide native **NCM** interface instead of //serial// **Modem** interface.
  
 :!: Please read about [[docs:guide-user:network:wan:wwan:at_commands|AT commands]] for your modem. :!: Please read about [[docs:guide-user:network:wan:wwan:at_commands|AT commands]] for your modem.
Line 16: Line 19:
  
 ===== Router Preparation ===== ===== Router Preparation =====
-1. Install OpenWRT+1. Install OpenWrt
  
 2. Complete steps [[docs:guide-quick-start:checks_and_troubleshooting|OpenWrt Configuration]] 2. Complete steps [[docs:guide-quick-start:checks_and_troubleshooting|OpenWrt Configuration]]
Line 23: Line 26:
  
 ==== Required Packages ==== ==== Required Packages ====
-To make use of NCM protocol, package **kmod-usb-net-huawei-cdc-ncm** and **comgt-ncm** are needed.+To make use of NCM protocol, packages ''kmod-usb-net-huawei-cdc-ncm'' and ''comgt-ncm'' are needed (for Huawei modems). Other modems may require different ''kmod-*'' packages.
  
-  ***''usb-modeswitch''**    - __It will automatically issue a "special" command to the modem for switching it into the "Working" state__      +To access the PC UI Interface (AT Command port) package ''kmod-usb-serial-option'' is typically needed. Some modems may need ''kmod-usb-acm'' driver instead.
- +
-<code> +
-opkg update +
-opkg install comgt-ncm kmod-usb-net-huawei-cdc-ncm usb-modeswitch +
-</code>+
  
 ==== Optional Packages ==== ==== Optional Packages ====
-1. Add support for PC Interface (ttyUSB0) +1. Install ''usb-modeswitch'' __if__ that is needed for switching the modem into a “working” state. More about: [[docs:guide-user:network:wan:wwan:usb-modeswitching|USB mode switch]] 
-  ***''kmod-usb-serial''** + 
-  ***''kmod-usb-serial-option''** +2. A terminal program like ''picocom'' will be needed to manually send AT commands.
-  ***''kmod-usb-serial-wwan''** +
-<code> +
-opkg update +
-opkg install kmod-usb-serial kmod-usb-serial-option kmod-usb-serial-wwan +
-</code>+
  
 3. Add support for FlashCard of your dongle - refer to: [[docs:guide-user:storage:usb-drives|USB Storage]] 3. Add support for FlashCard of your dongle - refer to: [[docs:guide-user:storage:usb-drives|USB Storage]]
  
 ===== Installation ===== ===== Installation =====
-1. Install all the needed packages+1. Install all the needed packages either in Luci → System → Software or via command line: 
 + 
 +  * For Huawei modems: 
 <code> <code>
-opkg update +root@OpenWrt:~# opkg update 
-opkg install comgt-ncm kmod-usb-net-huawei-cdc-ncm usb-modeswitch+root@OpenWrt:~# opkg install kmod-usb-net-huawei-cdc-ncm luci-proto-ncm picocom
 </code> </code>
  
-:!: If your have not enough space on your device - think of installing [[docs:guide-user:additional-software:extroot_configuration|Rootfs on External Storage (extroot)]]+  * other modems may require different packages, this is an example for Mikrotik modems:
  
-:!: Another option is Hardware memory upgrade. Refer to your router Forum thread for possibility and instructions. 
- 
-2. Reboot the router 
 <code> <code>
-reboot+root@OpenWrt:~# opkg update 
 +root@OpenWrt:~# opkg install kmod-usb-net-rndis kmod-usb-acm luci-proto-ncm picocom
 </code> </code>
  
-3. Check that everything is OK and you got new device:+Additional packages will be automatically installed as //dependencies//
 + 
 +You can also add the necessary packages when building a new image with [[https://firmware-selector.openwrt.org/|Firmware Selector]]. 
 + 
 +:!: If your have not enough space on your device - think about upgrading your hardware or installing [[docs:guide-user:additional-software:extroot_configuration|Rootfs on External Storage (extroot)]]. Refer to your router wiki page or forum thread for possibility and instructions. 
 + 
 +2. Reboot the router by executing ''reboot'' on the console. 
 + 
 +3. Check if you got new //device//:
 <code> <code>
-ls -l /dev/cdc-wdm0+root@OpenWrt:~# ls -l /dev/cdc*
  
 crw-r--r--    1 root     root      180, 176 Oct  1 12:03 /dev/cdc-wdm0 crw-r--r--    1 root     root      180, 176 Oct  1 12:03 /dev/cdc-wdm0
 </code> </code>
  
-If you have no such device - try to find out what went wrong+If there is no such device found, there is a possibility that completely different name is in use by the device driver, like ''usb0'' or ''eth1''. Try to get more details
- +  * Open System Log from Luci web interface and see what it shows regarding newly discovered USB device(s) 
-try **dmesg** to read kernel logs on USB init+  execute ''dmesg'' on the console and see if any relevant information is present in the kernel log 
 +  check the details about USB devices detected by the system by running ''cat /sys/kernel/debug/usb/devices'' on the console:
 <code> <code>
-dmesg +[...] 
-</code+T:  Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 0 
-or look info about USB devices and interfaces present in the system+D:  Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1 
-<code> +P Vendor=12d1 ProdID=1506 Rev= 1.02 
-cat /sys/kernel/debug/usb/devices +S:  Manufacturer=HUAWEI_MOBILE 
- +S:  Product=HUAWEI_MOBILE 
-FIXME+C:* #Ifs= 5 Cfg#= 1 Atr=80 MxPwr=  2mA 
 +I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=03 Prot=10 Driver=(none) 
 +E:  Ad=82(I) Atr=03(Int.) MxPS=  10 Ivl=32ms 
 +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= 2 Cls=ff(vend.) Sub=03 Prot=12 Driver=option 
 +E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms 
 +E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms 
 +I:  If#= 2 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=03 Prot=16 Driver=huawei_cdc_ncm 
 +E:  Ad=85(I) Atr=03(Int.) MxPS=  16 Ivl=2ms 
 +I:* If#= 2 Alt= 1 #EPs= 3 Cls=ff(vend.) Sub=03 Prot=16 Driver=huawei_cdc_ncm 
 +E:  Ad=85(I) Atr=03(Int.) MxPS=  16 Ivl=2ms 
 +E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms 
 +E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms 
 +I:* If#= 3 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage 
 +E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms 
 +E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=125us 
 +I:* If#= 4 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage 
 +E:  Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms 
 +E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=125us
 </code> </code>
  
Line 84: Line 106:
 ===== Configuration ===== ===== Configuration =====
 ==== Protocol Configuration ==== ==== Protocol Configuration ====
-[[docs:guide-user:base-system:uci|UCI]] is supporting **NCM** network protocol configuration. The detailed explanation about NCM network configuration is explained [[doc:uci:network#protocol.ncm.usb.modems.using.ncm.protocol|here]].+[[docs:guide-user:base-system:uci|UCI]] is supporting **NCM** network protocol configuration.  
 + 
 +^ Name      ^ Type       ^ Required  ^ Default          ^ Description                                                                                                                  ^ 
 +| device    | file path  | yes       | (none)           NCM device node, usually ''/dev/ttyUSBx'' or ''/dev/ttyACMx''                                                                | 
 +| apn       | string     | yes       | (none)           | APN to use                                                                                                                   | 
 +| pincode   | number     | no        | (none)           | PIN code to unlock SIM card                                                                                                  | 
 +| username  | string     | no        | (none)           | Username for PAP/CHAP authentication                                                                                         | 
 +| password  | string     | no        | (none)           | Password for PAP/CHAP authentication                                                                                         | 
 +| auth      | string     | no        | (none)           | Authentication type: **pap**, **chap**, **both**, **none**                                                                   | 
 +| mode      | string     | no        | (modem default)  | Used network mode, not every device support every mode: **preferlte**, **preferumts**, **lte**, **umts**, **gsm**, **auto** 
 +| pdptype   | string     | no        | IP               | PDP Context Type, **IP** (for IPv4), **IPV6** (for IPv6) or **IPV4V6** (for dual-stack)                                      | 
 +| profile   | number     | no        | 1                | PDP Context Identifier                                                                                                       | 
 +| delay     | number     | no        | 0                | Seconds to wait before trying to interact with the modem (some modems require up to 30 s.)                                   | 
 + 
 +You can configure the interface manually using [[docs:techref:uci|uci command line]] or [[docs:guide-user:base-system:user.beginner.cli#editing.filestext editor]] or with [[docs:techref:luci| Luci]] package **luci-proto-ncm**.
  
-You can configure UCI manually using [[docs:techref:uci|uci command line]] or [[docs:guide-user:base-system:user.beginner.cli#editing.files| text editor]] or with [[docs:techref:luci| Luci]] package **luci-proto-ncm**.+ :!If option "mode" is set, the corresponding AT command is sent to the modem on every connection attemptMost of modems (at least all Huawei models) store this setting in internal flashSo on each connection OpenWrt writes to modem flashIt is recommended to not use this option after the required mode is set once.
              
 ==== Network configuration ===== ==== Network configuration =====
-Now you should add new **Interface** to /etc/config/network+ 
 +Using Luci web interface: navigate to Network → Interfaces → Add new interface… → Protocol : NCM, Interface: "ttyUSB1" 
 + 
 +The interface selected above is the "AT Command Port" or "PCUI" in Huawei terms, ''ttyUSB1'' is shown here as an example only, different modems have different port assignments like ''/dev/ttyUSBx'' or ''/dev/ttyACMx''. The //data// interface like ''wwan0'' and corresponding device like ''/dev/cdc-wdm0'' will be discovered by the connection script automatically. 
 + 
 +Enter your APN and select the 'IP Protocol' as instructed by the carrier. 
 + 
 +Assign the firewall zone (wan) on 'Firewall Settings' tab.\\  
 +\\  
 +Alternatively you can edit the configuration files with any text editor like ''vi'' or ''nano'': 
 + 
 +  * add new **Interface** in ''/etc/config/network'':
 <code> <code>
 config interface 'wwan' config interface 'wwan'
         option proto 'ncm'         option proto 'ncm'
-        option ifname 'wwan0+        option device '/dev/ttyUSB1
-        option device '/dev/cdc-wdm0'+        option pdptype 'IP'
         option apn 'internet'         option apn 'internet'
-        option mode 'preferlte' 
-        option pincode '0000' 
-        option delay '5' 
 </code>  </code> 
  
-You can do this using the vi text editor, but if you're not comfortable with that, point your browser to 192.168.1.1 again, choose Network -Interfaces and click Add new interface. +  * add the same interface name to the "wan" firewall zone in ''/etc/config/firewall'': 
- +<code
-Write **wwan** as the name of the interface and make it cover the **wwan0** interfaceChoose **ncm** as the protocol. +config zone 
- +    option name 'wan' 
-FIXME Insert a screenshot of LUCI add Interface+    [...] 
- +    list network 'wwan' 
-==== Firewall configuration ===== +</code
-The only thing that is left - Add **wwan** interface to **WAN zone** +
- +
-Using LUCI: +
-  * go to Network -Firewall, scroll down to wan and click the Edit button +
-  * add a checkmark to the **wwan** box under Covered networks heading, click **Save & Apply**+
  
-FIXME Insert a Screen Shot from LUCI. 
  
 ==== Additional Info ===== ==== Additional Info =====
Line 131: Line 169:
  
 ===== Troubleshooting ===== ===== Troubleshooting =====
-__**My router is not detecting the dongle. What should I do?**__+==== My router is not detecting the modem. What should I do? ====
  
-Try the following commands+Get the information about  USB devices with ''cat /sys/kernel/debug/usb/devices'' 
-<code> + 
-usbmode -l +Find a section for your device, look for "Manufacturer" and/or "Product" lines corresponding to your modem, for example
-</code> + 
-It should respond with a message about your USB device is detected. If it does, issue the next command. If it doesn'tyou might want to get help from the forum. +  S:  Manufacturer=HUAWEI_MOBILE 
-<code> +  S:  Product=HUAWEI_MOBILE 
-usbmode -s + 
-</code> +See if necessary drivers are loaded for your device
-Then wait for the dongle to get issued an IP from your ISP.+ 
 +  I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=03 Prot=12 Driver=option 
 +  [...] 
 +  I:  If#= 2 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=03 Prot=16 Driver=huawei_cdc_ncm 
 + 
 +If the drivers are missinginstall the missing packages and/or change the operating mode of the modem to expose the necessary interfaces.  
 + 
 +Finally, ask in the forum. 
 +==== My modem doesn't reconnect after it loses the connection ==== 
 + 
 +This script [[https://github.com/oilervoss/openvpnForNordvpn/tree/master/etc/init.d|GitHub oilervoss]] will check the connection pinging a public IP and, under failure, it will send AT commands to the serial interface of the modem restarting it.
  
-__**I have to issue //usbmode -l// and //usbmode -s// every time I reboot my router to detect my USB device. How can I automate it?**__+To achieve continuous monitoring of the connection, it must be called recurrently through a cron job as:
  
-Include the following codes into ///etc/rc.local// just before //exit 0//: 
 <code> <code>
-/sbin/usbmode -l +#/etc/crontabs/root 
-/bin/sleep 2 +#min    h   day  mon  week  command 
-/sbin/usbmode -s+*/20    *    *    *    *    /etc/init.d/ncm-fix start
 </code> </code>
  
-__**I am using 'huawei_cdc_ncm' module and the /dev/cdc-wdm0 does not respond. What do I do?**__+==== I am using 'huawei_cdc_ncm' module and the /dev/cdc-wdm0 does not respond. What do I do? ====
  
 This is probably related to ticket #18673 ([[https://dev.openwrt.org/ticket/18673]]). This is probably related to ticket #18673 ([[https://dev.openwrt.org/ticket/18673]]).
Line 159: Line 206:
 AT^NDISDUP=1,1,"your_apn_address" AT^NDISDUP=1,1,"your_apn_address"
 </code> </code>
-It is possible to automate this task using [[docs:techref:hotplug|hotplug]]. Below are some scripts fetched from [[http://forum.ixbt.com/post.cgi?id=print:14:59307&page=4]]. Do not forget to modify them to your needs. The scripts are for Huawei modems obviously.+It is possible to automate this task using [[docs:techref:hotplug_legacy|hotplug]]. Below are some scripts fetched from [[http://forum.ixbt.com/post.cgi?id=print:14:59307&page=4]]. Do not forget to modify them to your needs. The scripts are for Huawei modems obviously.
  
 ///etc/init.d/ncm-network//: ///etc/init.d/ncm-network//:
Line 232: Line 279:
 </code> </code>
  
-Some modems does not reconnect after loosing connection.+Some modems does not reconnect after losing connection.
 Here is a connection check sh script which checks if it can ping remote servers with time intervals. If all pings fail, it tries to start the network by executing ///etc/init.d/ncm-network start// Here is a connection check sh script which checks if it can ping remote servers with time intervals. If all pings fail, it tries to start the network by executing ///etc/init.d/ncm-network start//
 <code> <code>
Line 271: Line 318:
 done done
  
 +</code>
 +
 +If your SIM receives a voice call. It will downgrade to CS network which means you will downgrade into 3G mode.
 +To avoid this, set the stick to use only PS network by creating `/etc/hotplug.d/iface/99-ifupwwan` file with following code.
 +Make sure to modify it to use correct serial interface and correct AT command for your device.
 +<code>
 +[ "$ACTION" = "ifup" -a "$INTERFACE" = "wwan" ] && {
 +    logger "iface wwan up detected..."
 +    # We need to set this to stop the card from receiving phone calls
 +    # This is for EC-25
 +    #echo -ne "\r\nAT+QCFG=\"servicedomain\",1,1\r\n" > /dev/ttyUSB2
 +    # This is for Huawei
 +    echo -ne "\r\nAT^SYSCFGEX=\"00\",3FFFFFFF,1,1,7FFFFFFFFFFFFFFF,,\r\n" > /dev/ttyUSB2
 +}
 </code> </code>
  • Last modified: 2024/11/20 12:02
  • by andrewz