Nanopi2连接USB LTE适配器

Windows下的硬件id

Nanopi2连接USB LTE适配器_第1张图片
lte4gusb.PNG
  • http://forum.ubuntu.org.cn/viewtopic.php?f=116&t=472546
  • https://askubuntu.com/questions/384562/how-do-i-get-an-iball-3-5g-modem-working-on-ubuntu
  • http://www.virtualizor.com/wiki/PPP
  • https://openvz.org/PPP_in_container
user@debian:/tmp/test$ cat /etc/usb_modeswitch.conf 
# Configuration for the usb_modeswitch package, a mode switching tool for
# USB devices providing multiple states or modes
#
# Evaluated by the wrapper script /usr/sbin/usb_modeswitch_dispatcher
#
# To enable an option, set it to "1", "yes" or "true" (case doesn't matter)
# Everything else counts as "disable"


# Disable automatic mode switching globally (e.g. to access the original
# install storage)

#DisableSwitching=0


# Enable logging (results in a extensive report file in /var/log, named
# "usb_modeswitch_" and probably others

#EnableLogging=0


# Optional increase of "delay_use" for the usb-storage driver; there are hints
# that a recent kernel default change to 1 sec. may lead to problems, particu-
# larly with USB 3.0 ports. Set this to at least 3 (seconds) in that case.
# Does nothing if the current system value is same or higher

#SetStorageDelay=4

DefaultVendor= 0x05c6
DefaultProduct= 0xf000
TargetVendor= 0x05c6
TargetProduct= 0x6000
MessageContent="5553424312345678000000000000061b000000020000000000000000000000"

测试一下

user@debian:/tmp/test$ sudo usb_modeswitch -W -c /etc/usb_modeswitch.conf 

Read config file: /etc/usb_modeswitch.conf

 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.2.0 (C) Josua Dietze 2014
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x05c6
DefaultProduct= 0xf000
TargetVendor=   0x05c6
TargetProduct=  0x6000
MessageContent="5553424312345678000000000000061b000000020000000000000000000000"
NeedResponse=0

Look for target devices ...
  found USB ID 04f3:0103
  found USB ID 04fc:0c25
  found USB ID 05c6:f000
   vendor ID matched
  found USB ID 1043:8012
  found USB ID 24ae:2001
  found USB ID 1a40:0201
  found USB ID 8087:0024
  found USB ID 1d6b:0002
  found USB ID 1d6b:0003
  found USB ID 1d6b:0002
  found USB ID 04fc:2801
  found USB ID 8087:0024
  found USB ID 1d6b:0002
 No devices in target mode or class found
Look for default devices ...
  found USB ID 04f3:0103
  found USB ID 04fc:0c25
  found USB ID 05c6:f000
   vendor ID matched
   product ID matched
  found USB ID 1043:8012
  found USB ID 24ae:2001
  found USB ID 1a40:0201
  found USB ID 8087:0024
  found USB ID 1d6b:0002
  found USB ID 1d6b:0003
  found USB ID 1d6b:0002
  found USB ID 04fc:2801
  found USB ID 8087:0024
  found USB ID 1d6b:0002
 Found devices in default mode (1)
Access device 009 on bus 004
Current configuration number is 1
Use interface number 0
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: Qualcomm, Incorporated
     Product: Qualcomm CDMA Technologies MSM
  Serial No.: 1234567890ABCDEF
-------------------------
Looking for active driver ...
 No active driver found. Detached before or never attached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
 OK, message successfully sent
Reset response endpoint 0x81
Reset message endpoint 0x01
-> Run lsusb to note any changes. Bye!

试了很多次了终于试出来啊

sudo usb_modeswitch -W -n -I -v 05c6 -p f000 -V 05c6 -P 6000 -M 555342430850e782c000000080000671010000000000000000000000000000
user@debian:/tmp/test$ ls /dev/ttyUSB*
/dev/ttyUSB1  /dev/ttyUSB2  /dev/ttyUSB3  /dev/ttyUSB4

user@debian:/tmp/test$ lsusb
Bus 004 Device 008: ID 04f3:0103 Elan Microelectronics Corp. ActiveJet K-2024 Multimedia Keyboard
Bus 004 Device 007: ID 04fc:0c25 Sunplus Technology Co., Ltd SATALink SPIF225A
Bus 004 Device 005: ID 1043:8012 iCreate Technologies Corp. Flash Disk 256 MB
Bus 004 Device 004: ID 24ae:2001  
Bus 004 Device 015: ID 05c6:6000 Qualcomm, Inc. Siemens SG75
Bus 004 Device 003: ID 1a40:0201 Terminus Technology Inc. FE 2.1 7-port Hub
Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 04fc:2801 Sunplus Technology Co., Ltd 
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

wvdial出错了,发现原来是内核问题啊

wvdial
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: ATE0V1
ATE0V1
OK
--> Sending: ATS0=0
OK
--> Sending: AT+CGDCONT=1,"IP","3GNET"
OK
--> Sending: AT+CFUN=1
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
CONNECT 100000000
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Thu Jun 22 22:28:40 2017
--> Pid of pppd: 3681
--> pppd: ����[18]�[02]
--> Disconnecting at Thu Jun 22 22:28:41 2017
--> The PPP daemon has died: Fatal pppd error (exit code = 1)
--> man pppd explains pppd error codes in more detail.
--> Try again and look into /var/log/messages and the wvdial and pppd man pages for more information.
--> Auto Reconnect will be attempted in 5 seconds
--> Initializing modem.
--> Sending: ATZ
--> Sending: ATQ0
--> Re-Sending: ATZ
--> Modem not responding.
--> Initializing modem.
--> Sending: ATZ
--> Sending: ATQ0
--> Re-Sending: ATZ
--> Modem not responding.
--> Disconnecting at Thu Jun 22 22:29:16 2017

要编译内核了
安装编译器在 linux 64

git clone https://github.com/friendlyarm/prebuilts.git
sudo mkdir -p /opt/FriendlyARM/toolchain
sudo tar xf prebuilts/gcc-x64/arm-cortexa9-linux-gnueabihf-4.9.3.tar.xz -C /opt/FriendlyARM/toolchain/

增加到环境~/.bashrc

export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH
export GCC_COLORS=auto

下载内核文件

git clone https://github.com/friendlyarm/linux-3.4.y.git
cd linux-3.4.y
git checkout nanopi2-lollipop-mr1

编译

make nanopi2_linux_defconfig
touch .scmversion
# make menuconfig
 *** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 *** 
 *** Install ncurses (ncurses-devel) and try again.
 *** 
/home/jimmy/linux-3.4.y/scripts/kconfig/Makefile:190: recipe for target 'scripts/kconfig/dochecklxdialog' failed
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
Makefile:493: recipe for target 'menuconfig' failed
make: *** [menuconfig] Error 2

出错了bing一下出来了

sudo apt-get install libncurses5-dev 

又出错,看一下少了什么

  UIMAGE  arch/arm/boot/uImage
"mkimage" command not found - U-Boot images will not be built
/home/jimmy/linux-3.4.y/arch/arm/boot/Makefile:101: recipe for target 'arch/arm/boot/uImage' failed
make[1]: *** [arch/arm/boot/uImage] Error 1
/home/jimmy/linux-3.4.y/arch/arm/Makefile:291: recipe for target 'uImage' failed
make: *** [uImage] Error 2

修改nanopi2内核选项,
make menuconfig
Device drivers -> Networking device support -> PPP(point to point protocol) support
我选了以下模块(以M方式即module方式)
PPP support for async serial ports
PPP support for sync tty ports
PPP Deflate compression
PPP BSD-Compress compression
SLIP(serial line) support

到了几个ko形式的内核库文件,拷贝它们到ARM目标板上,并在/etc/init.d/rcS中动态加载:

insmod /etc/ppp/slhc.ko                                        
insmod /etc/ppp/ppp_generic.ko                                 
insmod /etc/ppp/ppp_async.ko                                   
insmod /etc/ppp/ppp_synctty.ko                                 
insmod /etc/ppp/ppp_deflate.ko                                 
insmod /etc/ppp/bsd_comp.ko                                    
insmod /etc/ppp/slip.ko

注意加载顺序,我记得好象必须把slhc.ko先加载

lsmod多了三个mod

root@NanoPi2:~/nanopi2_ko# lsmod
Module                  Size  Used by
slip                    9456  0 
ppp_synctty             5433  0 
ppp_async               6797  0 
nx_vpu                351383  0 
vr                    142655  0 
bnep                   11245  2 
hci_uart               14744  1 
btbcm                   5120  1 hci_uart
bluetooth             385422  22 bnep,btbcm,hci_uart
bcmdhd                605063  0 
cfg80211              459462  1 bcmdhd
compat                 23995  5 bnep,cfg80211,bcmdhd,hci_uart,bluetooth

这样就可以wvdial

wvdial
--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: ATE0V1
ATE0V1
OK
--> Sending: ATS0=0
OK
--> Sending: AT+CGDCONT=1,"IP","3GNET"
OK
--> Sending: AT+CFUN=1
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
CONNECT 100000000
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Fri Jun 23 17:03:09 2017
--> Pid of pppd: 1714
--> Using interface ppp0
--> pppd: ��`�[02]
--> pppd: ��`�[02]
--> pppd: ��`�[02]
--> pppd: ��`�[02]
--> pppd: ��`�[02]
--> pppd: ��`�[02]
--> local  IP address 10.232.146.224
--> pppd: ��`�[02]
--> remote IP address 10.64.64.64
--> pppd: ��`�[02]
--> primary   DNS address 210.21.196.6
--> pppd: ��`�[02]
--> secondary DNS address 221.5.88.88
--> pppd: ��`�[02]
^CCaught signal 2:  Attempting to exit gracefully...
--> Terminating on signal 15
--> pppd: ��`�[02]
--> Connect time 0.4 minutes.
--> pppd: ��`�[02]
--> pppd: ��`�[02]
--> pppd: ��`�[02]
--> Disconnecting at Fri Jun 23 17:03:28 2017

你可能感兴趣的:(Nanopi2连接USB LTE适配器)