EM05-G模组不能获取到ipv4地址

香橙派5B上插入EM05-g(M.2 to USB转接)后,能够枚举串口和usb0网络接口,usb0使能后貌似能够获取ipv6地址,但获取不到ipv4地址。

[ 203.365698] usb 1-1: new high-speed USB device number 3 using ehci-platform
[ 203.526235] usb 1-1: New USB device found, idVendor=2c7c, idProduct=030e, bcdDevice= 3.18
[ 203.526323] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 203.526351] usb 1-1: Product: Quectel EM05-G
[ 203.526376] usb 1-1: Manufacturer: Quectel
[ 203.529114] option 1-1:1.0: GSM modem (1-port) converter detected
[ 203.529667] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
[ 203.530360] option 1-1:1.1: GSM modem (1-port) converter detected
[ 203.530870] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
[ 203.531591] option 1-1:1.2: GSM modem (1-port) converter detected
[ 203.532083] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
[ 203.532811] option 1-1:1.3: GSM modem (1-port) converter detected
[ 203.533299] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
[ 203.537928] [dhd] CFG80211-ERROR) wl_cfg80211_netdev_notifier_call : wdev null. Do nothing
[ 203.541149] [dhd] CFG80211-ERROR) wl_cfg80211_netdev_notifier_call : wdev null. Do nothing
[ 203.541842] cdc_ether 1-1:1.4 usb0: register ‘cdc_ether’ at usb-fc800000.usb-1, CDC Ethernet Device, c2:13:01:ab:93:1f
[ 203.547417] [I/USB_PNP_NOTIFY] UsbPnpNotifyCallback: action=0x1\x0d
[ 203.547498] [I/USB_PNP_NOTIFY] UsbPnpNotifyAddInitInfo:209 i=0, interfaceInfo=0xff-0xff-0xff-0x0\x0d
[ 203.547531] [I/USB_PNP_NOTIFY] UsbPnpNotifyAddInitInfo:209 i=1, interfaceInfo=0xff-0x0-0x0-0x1\x0d
[ 203.547562] [I/USB_PNP_NOTIFY] UsbPnpNotifyAddInitInfo:209 i=2, interfaceInfo=0xff-0x0-0x0-0x2\x0d
[ 203.547592] [I/USB_PNP_NOTIFY] UsbPnpNotifyAddInitInfo:209 i=3, interfaceInfo=0xff-0x0-0x0-0x3\x0d
[ 203.547669] [I/USB_PNP_NOTIFY] UsbPnpNotifyAddInitInfo:209 i=4, interfaceInfo=0x2-0x6-0x0-0x4\x0d
[ 203.547700] [I/USB_PNP_NOTIFY] UsbPnpNotifyAddInitInfo:209 i=5, interfaceInfo=0xa-0x0-0x0-0x5\x0d
[ 203.547978] [I/USB_PNP_NOTIFY] UsbPnpNotifyReportThread: UsbPnpNotifyReportThread start!\x0d
[ 203.548038] [I/USB_PNP_NOTIFY] UsbPnpNotifyHdfSendEvent:375 device information, 3 usbDevAddr=18446743528309749760, devNum=3, busNum=1, infoTable=6-0x2c7c-0x30e!\x0d

ifconfig usb0 up

ifconfig

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope: Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 TX bytes:0

eth0 Link encap:Ethernet HWaddr 36:39:26:33:f4:d7 Driver rk_gmac-dwmac
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 TX bytes:0
Interrupt:87

usb0 Link encap:Ethernet HWaddr c2:13:01:ab:93:1f Driver cdc_ether
inet6 addr: fe80::c013:1ff:feab:931f/64 Scope: Link
inet6 addr: 2409:8900:1ae6:527:c013:1ff:feab:931f/64 Scope: Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:520 TX bytes:512

英文论坛上应该也看到了你的问题。
ipv4 需要DHCP 去拿地址。v6 是因为操作系统已经帮你做了那个工作。

用busybox能获取IPv4地址了,但还无法连接网络。

busybox udhcpc -i usb0

udhcpc: started, v1.31.1
udhcpc: sending discover
udhcpc: sending select for 192.168.225.24
udhcpc: lease of 192.168.225.24 obtained, lease time 43200
/usr/share/udhcpc/default.script: Resetting default routes
route: ioctl 890c: No such process
route: 0 > -1
/usr/share/udhcpc/default.script: Adding DNS 192.168.225.1
/usr/share/udhcpc/default.script[63]: resolvconf: inaccessible or not found

ifconfig usb0

usb0 Link encap:Ethernet HWaddr 56:65:cb:46:fd:d8 Driver cdc_ether
inet addr:192.168.225.24 Bcast:192.168.225.255 Mask:255.255.255.0
inet6 addr: 2409:8900:21d4:b887:5465:cbff:fe46:fdd8/64 Scope: Global
inet6 addr: fe80::5465:cbff:fe46:fdd8/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26 errors:0 dropped:0 overruns:0 frame:0
TX packets:94 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3293 TX bytes:35204

ping -I usb0 qq.com

ping: qq.com: Name does not resolve

那你看看是不是DNS没有写进去吧

DNS 192.168.225.1 写到/etc/resolv.conf文件里了。ping这个地址也能ping通。

你可以这么做

创建一个default.script

#!/bin/sh
# Busybox udhcpc dispatcher script. Copyright (C) 2009 by Axel Beckert.
#
# Based on the busybox example scripts and the old udhcp source
# package default.* scripts.

RESOLV_CONF="/etc/resolv.conf"

case $1 in
    bound|renew)
	[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
	[ -n "$subnet" ] && NETMASK="netmask $subnet"

	/sbin/ifconfig $interface $ip $BROADCAST $NETMASK

	echo ip : $ip
	echo  ----
	echo  BROADCAST: $BROADCAST
	echo  netmask: $NETMASK

	if [ -n "$router" ]; then
	    echo "$0: Resetting default routes"
	    while /sbin/route del default gw 0.0.0.0 dev $interface; do :; done

	    metric=0
	    for i in $router; do
		/sbin/route add default gw $i dev $interface metric $metric
		metric=$(($metric + 1))
	    done
	fi

	# Update resolver configuration file
	R=""
	[ -n "$domain" ] && R="domain $domain
"
	for i in $dns; do
	    echo "$0: Adding DNS $i"
	    R="${R}nameserver $i
"
	done

	if [ -x /sbin/resolvconf ]; then
	    echo -n "$R" | resolvconf -a "${interface}.udhcpc"
	else
	    echo -n "$R" > "$RESOLV_CONF"
	fi
	;;

    deconfig)
	if [ -x /sbin/resolvconf ]; then
	    resolvconf -d "${interface}.udhcpc"
	fi
	/sbin/ifconfig $interface 0.0.0.0
	;;

    leasefail)
	echo "$0: Lease failed: $message"
	;;

    nak)
	echo "$0: Received a NAK: $message"
	;;

    *)
	echo "$0: Unknown udhcpc command: $1";
	exit 1;
	;;
esac

将这个文件放到/etc/udhcpc/ 目录里。

busybox udhcpc -i usb0 /etc/udcpc/default.script

busybox udhcpc -i usb0 -q

udhcpc: started, v1.31.1
Setting IP address 0.0.0.0 on usb0
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending select for 192.168.225.27
udhcpc: lease of 192.168.225.27 obtained, lease time 43200
Setting IP address 192.168.225.27 on usb0
Deleting routers
route: ioctl 890c: No such process
Adding router 192.168.225.1
Recreating /etc/resolv.conf
Adding DNS server 192.168.225.1

ping qq.com ----------这里还是ping不通

ping: qq.com: Name does not resolve

route

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.225.1 0.0.0.0 UG 0 0 0 usb0
192.168.225.0 * 255.255.255.0 U 0 0 0 usb0

cat /e

eng_chipset/ eng_system/ etc/

cat /etc/resolv.conf

nameserver 192.168.225.1

这里ping 不通,就要用AT指令查询下注网的情况了。

ping 8.8.8.8

ifconfig usb0 up

busybox udhcpc -i usb0

udhcpc: started, v1.31.1
Setting IP address 0.0.0.0 on usb0
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending select for 192.168.225.24
udhcpc: lease of 192.168.225.24 obtained, lease time 43200
Setting IP address 192.168.225.24 on usb0
Deleting routers
route: ioctl 890c: No such process
Adding router 192.168.225.1
Recreating /etc/resolv.conf
Adding DNS server 192.168.225.1

ping -I usb0 8.8.8.8

Ping 8.8.8.8 (8.8.8.8) from usb0 (192.168.225.24): 56(84) bytes.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=0 time=228 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=0 time=86 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=0 time=91 ms

— 8.8.8.8 ping statistics —
3 packets transmitted, 3 received, 0% packet loss
round-trip min/avg/max = 0/0/135 ms

echo “nameserver 8.8.8.8” >> /etc/resolv.conf

ping -I usb0 8.8.8.8

Ping 8.8.8.8 (8.8.8.8) from usb0 (192.168.225.24): 56(84) bytes.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=0 time=258 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=0 time=66 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=0 time=80 ms

— 8.8.8.8 ping statistics —
3 packets transmitted, 3 received, 0% packet loss
round-trip min/avg/max = 0/0/134 ms

echo “nameserver 8.8.8.8” > /etc/resolv.conf

cat /e

eng_chipset/ eng_system/ etc/

cat /etc/resolv.conf

nameserver 8.8.8.8

ping 8.8.8.8

Ping 8.8.8.8 (8.8.8.8): 56(84) bytes.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=0 time=250 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=0 time=69 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=0 time=88 ms

— 8.8.8.8 ping statistics —
3 packets transmitted, 3 received, 0% packet loss
round-trip min/avg/max = 0/0/135 ms

ping -I usb0 8.8.8.8

Ping 8.8.8.8 (8.8.8.8) from usb0 (192.168.225.24): 56(84) bytes.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=0 time=106 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=0 time=65 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=0 time=65 ms

— 8.8.8.8 ping statistics —
3 packets transmitted, 3 received, 0% packet loss
round-trip min/avg/max = 0/0/78 ms

ping www.baidu.com

ping: www.baidu.com: Name does not resolve

cat /e

eng_chipset/ eng_system/ etc/

cat /etc/resolv.conf

nameserver 8.8.8.8

注网情况查询:

ati
Quectel
EM05-G
Revision: EM05GFAR07A07M1G

OK
AT+ICCID
+ICCID: 898600660117F0021345

OK
AT+CSQ
+CSQ: 11,99

OK
AT+COPS?
+COPS: 0,0,“CHINA MOBILE”,7

OK
AT+CGREG?
+CGREG: 0,1

OK

这个应该是Debian 启用了一些特殊的机制。/etc/resolv.conf 里写了个DNS 没有用。
譬如什么mDNS以及安全DNS机制。
你可以用nslookup 和dig 工具检查下系统上的DNS。