How to use 4G Module on NanoPC-T4

From FriendlyELEC WiKi
Revision as of 08:54, 15 May 2019 by Tzs (Talk | contribs) (updated by API)

Jump to: navigation, search

查看中文

1 Using 4G Module EC20 on Android

1.1 Hardware Setup

Connect an EC20 module to a USB to miniPCIe board and connect the board to an ARM board's USB Host. Here is a hardware setup:

Power on the board and you will be able to surf the internet with the 4G module like using an Android phone.

1.2 Activate EC20's GPS Functions

By default GPS functions are disabled in Android. If GPS functions are enabled in Android but no GPS module is detected Android will continuously output log messages. After an EC20 module is connected you can enable GPS functions.
To enable the GPS functions open the "vendor/quectel/ec20/BoardConfigPartial.mk" file and change the following line:

BOARD_HAS_GPS := false

to

BOARD_HAS_GPS := true

and recompile Android。

2 Using 4G Module EC20 on FriendlyDesktop

2.1 Step1:Edit connections

In the upper right corner of the FriendlyDesktop desktop, click on the network icon and select "Edit connections" from the pop-up menu.:
Friendlydesktop-4g-step1.jpg

2.2 Step2:Add mobile network setting

Click the "+" plus button in the lower left corner:
Friendlydesktop-4g-step2.jpg
Select "Mobile Broadband" from the menu that appears:
Friendlydesktop-4g-step2b.jpg

2.3 Step3:Set up 4G connection

Select "Next" directly in "Set up a Mobile Broadband Connection" dialog:
Friendlydesktop-4g-step2c.jpg
In the area selection that appears, choose your region, I choose "China" here, there will be China's service providers, will list China Mobile and China Unicom, I use China Mobile's card, so choose "China" Mobile":
Friendlydesktop-4g-step2d.jpg
In the "Choose your billing plan" dialog, select Internet, then click Next:
Friendlydesktop-4g-step2d2.jpg
In the confirmation dialog box, click "Apply", in the following dialog box, click "Save" to save the settings:
Friendlydesktop-4g-step2e.jpg

2.4 Step4:Dial-up connection 4G network

In the upper right corner of the FriendlyDesktop desktop, click the network icon, and select “Chine Mobile Internet 1” in the pop-up menu to dial the 4G network. If the password input box is displayed, input 0000:
Friendlydesktop-4g-step4.jpg
The following picture browsing a web page on a 4G network:
Friendlydesktop-4g-step4b.jpg

3 Using 4G Module EC20 on FriendlyCore

3.1 Step1:Compile the quectel-CM command line tool on the development board

Compile and install quectel-CM into the /usr/bin/ directory by entering the following command:

git clone https://github.com/friendlyarm/quectel-cm.git
cd quectel-cm/
make
cp quectel-CM /usr/bin/

3.2 Step2:Add udhcpc script

The quectel-CM tool will call the udhcpc script. we need to create a udhcpc script for it. Please create a new file with the editor you are familiar with. The file name is: /usr/share/udhcpc/default.script, the content is as follows:

#!/bin/sh
 
# udhcpc script edited by Tim Riker <Tim@Rikers.org>
 
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
 
RESOLV_CONF="/etc/resolv.conf"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"
 
case "$1" in
  deconfig)
    /sbin/ifconfig $interface 0.0.0.0
    ;;
 
  renew|bound)
    /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
 
    if [ -n "$router" ] ; then
      echo "deleting routers"
      while route del default gw 0.0.0.0 dev $interface ; do
        :
      done
 
      for i in $router ; do
        route add default gw $i dev $interface
      done
    fi
 
    echo -n > $RESOLV_CONF
    [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
    for i in $dns ; do
      echo adding dns $i
      echo nameserver $i >> $RESOLV_CONF
    done
    ;;
esac
 
exit 0

Assign executable permissions with the following command:

chmod 755 /usr/share/udhcpc/default.script

3.3 Step3:Start 4G dialing

Start the dialing by entering the following command:

quectel-CM &

If the dialing is successful, the screen will output information such as the IP address, as shown below:

root@NanoPC-T4:~# quectel-CM &
[1] 5364
root@NanoPC-T4:~# [05-15_08:23:13:719] WCDMA&LTE_QConnectManager_Linux&Android_V1.1.34
[05-15_08:23:13:720] quectel-CM profile[1] = (null)/(null)/(null)/0, pincode = (null)
[05-15_08:23:13:721] Find /sys/bus/usb/devices/3-1 idVendor=2c7c idProduct=0125
[05-15_08:23:13:722] Find /sys/bus/usb/devices/3-1:1.4/net/wwan0
[05-15_08:23:13:722] Find usbnet_adapter = wwan0
[05-15_08:23:13:723] Find /sys/bus/usb/devices/3-1:1.4/usbmisc/cdc-wdm0
[05-15_08:23:13:723] Find qmichannel = /dev/cdc-wdm0
[05-15_08:23:13:739] cdc_wdm_fd = 7
[05-15_08:23:13:819] Get clientWDS = 18
[05-15_08:23:13:851] Get clientDMS = 2
[05-15_08:23:13:884] Get clientNAS = 2
[05-15_08:23:13:915] Get clientUIM = 1
[05-15_08:23:13:947] Get clientWDA = 1
[05-15_08:23:13:979] requestBaseBandVersion EC20CEFHLGR06A01M1G_OCPU_BETA1210
[05-15_08:23:14:043] requestSetEthMode QMUXResult = 0x1, QMUXError = 0x46
[05-15_08:23:14:075] requestGetSIMStatus SIMStatus: SIM_READY
[05-15_08:23:14:107] requestGetProfile[1] cmnet///0
[05-15_08:23:14:139] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE
[05-15_08:23:14:171] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED
[05-15_08:23:14:235] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE
[05-15_08:23:14:938] requestSetupDataCall WdsConnectionIPv4Handle: 0xe16e4540
[05-15_08:23:15:002] requestQueryDataCall IPv4ConnectionStatus: CONNECTED
[05-15_08:23:15:036] ifconfig wwan0 up
[05-15_08:23:15:052] busybox udhcpc -f -n -q -t 5 -i wwan0
[05-15_08:23:15:062] udhcpc (v1.23.2) started
[05-15_08:23:15:077] Sending discover...
[05-15_08:23:15:093] Sending select for 10.22.195.252...
[05-15_08:23:15:105] Lease of 10.22.195.252 obtained, lease time 7200
[05-15_08:23:15:118] deleting routers
SIOCDELRT: No such process
[05-15_08:23:15:132] adding dns 221.179.38.7
[05-15_08:23:15:132] adding dns 120.196.165.7

3.4 Test 4G connection

Ping a domain name to see if DNS resolution is already working:

root@NanoPC-T4:~# ping www.baidu.com
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=1 ttl=56 time=74.3 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=2 ttl=56 time=25.1 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=3 ttl=56 time=30.8 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=4 ttl=56 time=29.1 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=5 ttl=56 time=29.2 ms

3.5 Test the speed of 4G

wget -O - https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python

The test results obtained are as follows:

Retrieving speedtest.net configuration...
Testing from China Mobile Guangdong (117.136.40.167)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by ChinaTelecom-GZ (Guangzhou) [2.51 km]: 62.726 ms
Testing download speed................................................................................
Download: 32.93 Mbit/s
Testing upload speed................................................................................................
Upload: 5.58 Mbit/s