How to use BPI-4G LTE module with BPI-R2

31383737168841878

1.Firstly, use R2 connects LTE module by USB or 14pin Headers. then execute command "lsusb" to have a look if R2 have drove the module. The red box is the id of 4G module.

image

After seeing this, execute command "ls /dev/ttyUSB*" to make sure the 4G module have been recognised as USB devs.

image

2. Execute the "./ppp1.sh &"

image

then execute command “ifconfig -a”,you will see ppp0

image

3. Execute command ”wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py” to download speed test tool.

image

4. Execute command "chmod +x speedtest-cli",  then execute "./speedtest-cli"

image

ppp1_success_log.txt (5.7 KB)

1.FAQ

(1) You could get ppp1.sh from here : https://pan.baidu.com/s/1yu0nTNQKPNPzprVPjhOPUA

(2) Q: What should I do, if you meet this "expect (OK) ^M alarm Failed " image

A:The root cause is the Modem.service has used the module usbserial, so the 4G module can’t use usbserial; we can solve the problem by using command "systemctl disable ModemManager.service " or "systemctl stop ModemManager.service "

(3) Q:How to test the communication between SIM card and 4G module?

A:Use minicom, ”minicom -D /dev/ttyUSB2”,and then use AT commands to test, such as ”at”,”at+csq”,“at+ccid”,if you get response without error,that means the communication is OK.

(4) Q: How to install libqmi?

A: Download from here: http://www.linuxfromscratch.org/blfs/view/cvs/general/libqmi.html ; then make and make install.

If you meet this:

image

you need to install libgudev-1.0-dev, then make and make install again.

(5) Q:How to use qmi-wwan

A:There is a very easy way to use,I’ve put quectel-CM in home path of root,just execute “./quectel-CM &”,then execute “dhclient wwan0”,now you have finished the configurations.

(6) Q:How to use GPS

A:BPI-4G module supports GPS and BeiDou,execute “minicom -D /dev/ttyUSB2”,then input AT commands like this:

image

if you want to use BeiDou,just input AT commands like this:

image

(7) Here are kernel configurations and driver patch for kernel 4.14.

config (120.3 KB) patch (6.6 KB)

(8) Support areas:

  • EC25-E support: EMEA/Thailand/India/South Korea

  • EC25-AU support: Australia

  • EC25-V/-A support:North America

(9) Openwrt Supported:

A. Clone the source code from this link : BPI-R2 OpenWrt(LEDE) Souce code : 2018-04-11

B. Add qmi-wwan driver to this project :

  • Execute “./scripts/feeds/ install minicom” to install minicom to openwrt project

  • Execute “./scripts/feeds/ install python” to install python to openwrt project

  • Execute “make menuconfig”

  • Add minicom “Utilities —> Terminal —> minicom”

  • Add python “Languages —> Python”

  • Add driver “Network —> wwan …Genetic OpenWrt 3G/4G proto handler”

  • Add "Kernel modules —> USB Support —>

    kmod-usb-core

    kmod-usb-net —> kmod-usb-net-qmi-wwan

    kmod-usb-ohci

    kmod-usb-serial —> kmod-usb-serial-option , kmod-usb-serial-wwan

    kmod-usb-uhci

    kmod-usb2-*

  • Use these source files to replace your openwrt project source files (“build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-mediatek_32/linux-4.9.44/drivers/usb(or net)/…”) : image

C. Image & Stuff Link :

D. Cross-Compile quectel-CM

  • Copy “quectel-CM” to Linux host PC,and change “Makefile” under the “quectel-CM”,change tools like this:

    The tools are under openwrt project,you can find them according to the following picture.

    image

  • If ping Domain name fail,add “nameserver 8.8.8.8” to /etc/resolv.conf

    image

    image

(10) If you use mPCIE interface 4G module to connect R2 by 14 pin header,use these cmds to enable 4G module,after you did these steps,USB0 port will be disable.

  • cd /sys/class/gpio/
  • echo 266 > export 【# 266(gpio_offset) = 232(base) + 34(GPIO_34)】
  • cd gpio266/
  • echo out > direction
  • echo 1 > value
2 Likes

Good writeup, however you are operating the modem in PPP mode, which limits the maximum speed you will be able to achieve. This modem is a LTE Cat.4 modem capable of 150MBps downlink speed, with PPP you will probably max out between 10-20 MBps.

This is too broad of a topic for me to elaborate in greater detail, but to achieve better performance you need to have the qmi-wwan driver recognize the modem, which should result in a ‘wwan0’ interface. You should also have a /dev/cdc-wdm0 device file. Next, make sure to install libqmi and use qmicli to start a network connection. ModemManager can actually do all this for you automatically, however I’m not sure from which kernel onwards the Quectel EC25 LTE module is supported. My guess is that kernel 4.14 might work out of the box…

wow,you are cool,are you skilled about this part? thanks for your advice,EC25 support qmi-wwan, I will have a try.

I have added qmi-wwan driver,I will do more test about this.:wink:

image

image

I know a bit about this, but I don’t have an EC25 modem. A few pointers:

  • I highly recommend trying this with a 4.14 kernel. The wwan0 interface to the modem can operate in 802.3 mode (frames carrying an Ethernet header) or in raw IP mode. Very likely the EC25 will only support raw IP mode (this is the case for all newer Qualcomm based modems) Setting this up in older kernels often requires patches to the qmi-wwan driver. On a new kernel you simply enter

    echo 1 > /sys/class/net/wwan0/qmi/raw_ip

  • Next, try if you can talk to the modem using QMI. Install libqmi and try a simple status query:

    qmicli -d /dev/cdc-wdm0 --nas-get-signal-info

    [/dev/cdc-wdm0] Successfully got signal info

    LTE:

      RSSI: '-79 dBm'
      RSRQ: '-14 dB'
      RSRP: '-111 dBm'
      SNR: '4.6 dB'
    
  • If this works, use ‘qmi-network’ to start a connection. Please google this command for more information on how to use it…

2 Likes

Hello,wtolkien, I have tested qmi-wwan,I succeed to get ip for wwan0, and use data speed tool to test speed,as you say,the performance of qmi is better than ppp.

image

image

2 Likes

And I also think it’s depend on network situation,here I got 70Mb/s speed.

image

2 Likes

Excellent! I’m glad you got it to work. 70Mb/s is actually really good for real world testing!

Thanks for your advice wtolkien;:grinning:

I will post GPS testing result later.

Please integrate latest kernel(including qmi driver) in latest release, also please provide the instruction about how to use qmi-www in release notes. Good job, thanks.

OK,Gary,I will put qmi instruction in this thread.

I’ve put qmi-wwan usage instructions and GPS usage instructions in FAQ,if you guys have any questions,please let me know . Thanks.

Hi. I attached the 4G LTE USB module on R2 board by USB OTG cable. When I type,

lsusb

Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 002: ID 2c7c:0125
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

ls /dev/ttyUSB*

ls: cannot access ‘/dev/ttyUSB*’: No such file or directory

I am using @frank-w 4.14.28-bpi-r2-main kernel.

TIA.

Hello,Did you enable CONFIG_USB_SERIAL_OPTION?

Could you please try to enable “USB driver for GSM and CDMA modems”?

Hi. Should I enable this configuration in kernel configuration file & recompile?. If so, may I know if we have any precompiled for 4G LTE USB module. Otherwise, I will recompile it.

TIA.

I tested with Kernel4.4, I will have a test with kernel 4.14,but now could you please recompile by yourself?

Hello,I have succeed to add ppp and qmi-wwan driver to kernel 4.14,I will make a patch to this repo which is based on frank’s.

  • ppp:

    image

  • qmi-wwan

    image

@Jackzeng glad to hear from you. Appreciate if you share your 4.18.32 kernel binary. I am also building my kernel source.

TIA.

Hello, here is the patch file for the kernel 4.14; if you want the image, I will post it here later.

you need also modify the kernel configurations, you can compare with yours.

config (120.3 KB) patch (6.6 KB)

best regards.

@Jackzeng Thanks. I have done it. Got the ports. However, facing other issues and unable to make it work with ppp. The log is as follow. I am using Vodafone 4G SIM and the APN is www, user name & pwd are empty.

> ./ppp1.sh &                                                                                            
> [1] 8212
> quectel-pppd options in effect:
> devname   /dev/ttyUSB3    # (default)
> apn       www    # (default)
> user         # (default)
> password     # (default)
> pppd options in effect:
> debug           # (from command line)
> nodetach                # (from command line)
> dump            # (from command line)
> noauth          # (from command line)
> user            # (from command line)
> password ??????         # (from command line)
> /dev/ttyUSB3            # (from command line)
> 115200          # (from command line)
> lock            # (from command line)
> connect ''chat -s -v ABORT BUSY ABORT \"NO CARRIER\" ABORT \"NO DIALTONE\" ABORT ERROR ABORT \"NO ANSWER\" TIMEOUT 30 \"\" AT OK ATE0 O
> K ATI\\;+CSUB\\;+CSQ\\;+CPIN?\\;+COPS?\\;+CGREG?\\;\\&D2 OK AT+CGDCONT=1,\\\"IP\\\",\\\"www\\\",,0,0 OK ATD*99# CONNECT'
>                 # (from command line)
> disconnect chat -s -v ABORT ERROR ABORT \"NO DIALTONE\" SAY \"\\nSending break to the modem\\n\" \"\" +++ \"\" +++ \"\" +++ SAY \"\\nGo
> od bay\\n\"             # (from command line)
> nocrtscts               # (from command line)
> modem           # (from command line)
> asyncmap 0              # (from /etc/ppp/options)
> lcp-echo-failure 4              # (from /etc/ppp/options)
> lcp-echo-interval 30            # (from /etc/ppp/options)
> hide-password           # (from /etc/ppp/options)
> novj            # (from command line)
> novjccomp               # (from command line)
> ipcp-accept-local               # (from command line)
> ipcp-accept-remote              # (from command line)
> noipdefault             # (from command line)
> ipcp-max-configure 30           # (from command line)
> defaultroute            # (from command line)
> usepeerdns              # (from command line)
> noccp           # (from command line)
> noipx           # (from /etc/ppp/options)
> abort on (BUSY)
> abort on (NO CARRIER)
> abort on (NO DIALTONE)
> abort on (ERROR)
> abort on (NO ANSWER)
> timeout set to 30 seconds
> send (AT^M)
> expect (OK)
> ^M
> OK
>  -- got it
> 
> send (ATE0^M)
> expect (OK)
> ^M
> ^M
> OK
>  -- got it
> 
> send (ATI;+CSUB;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2^M)
> expect (OK)
> ^M
> ^M
> Quectel^M
> EC25^M
> Revision: EC25EFAR02A08M4G^M
> ^M
> SubEdition: V04^M
> ^M
> +CSQ: 99,99^M
> ^M
> +CPIN: READY^M
> ^M
> +COPS: 0^M
> ^M
> +CGREG: 0,0^M
> ^M
> OK
>  -- got it
> 
> send (AT+CGDCONT=1,"IP","www",,0,0^M)
> expect (OK)
> ^M
> ^M
> OK
>  -- got it
> 
> send (ATD*99#^M)
> expect (CONNECT)
> ^M
> ^M
> CONNECT
>  -- got it
> 
> Script ''chat -s -v ABORT BUSY ABORT "NO CARRIER" ABORT "NO DIALTONE" ABORT ERROR ABORT "NO ANSWER" TIMEOUT 30 "" AT OK ATE0 OK ATI\;+C
> SUB\;+CSQ\;+CPIN?\;+COPS?\;+CGREG?\;\&D2 OK AT+CGDCONT=1,\"IP\",\"www\",,0,0 OK ATD*99# CONNECT'' finished (pid 8215), status = 0x0
> Serial connection established.
> using channel 3
> Using interface ppp0
> Connect: ppp0 <--> /dev/ttyUSB3
> sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xba9fe554> <pcomp> <accomp>]
> rcvd [LCP ConfReq id=0x5 <asyncmap 0x0> <auth chap MD5> <magic 0xd1228a58> <pcomp> <accomp>]
> sent [LCP ConfNak id=0x5 <auth pap>]
> rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xba9fe554> <pcomp> <accomp>]
> rcvd [LCP ConfReq id=0x6 <asyncmap 0x0> <auth pap> <magic 0xd1228a58> <pcomp> <accomp>]
> sent [LCP ConfAck id=0x6 <asyncmap 0x0> <auth pap> <magic 0xd1228a58> <pcomp> <accomp>]
> sent [LCP EchoReq id=0x0 magic=0xba9fe554]
> sent [PAP AuthReq id=0x1 user="" password=<hidden>]
> rcvd [LCP DiscReq id=0x7 magic=0xd1228a58]
> rcvd [LCP EchoRep id=0x0 magic=0xd1228a58 ba 9f e5 54]
> rcvd [PAP AuthAck id=0x1 ""]
> PAP authentication succeeded
> sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
> Modem hangup
> Connection terminated.
> 
> 
> 
> 
> 
> 
> CTRL-A Z for help | 115200 8N1 | NOR | Minicom 2.7 | VT102 | Online 0:42 | ttyUSB0

Hello,try to modify here in ppp1.sh to www

image