1、由原理图可知4G模块用到GPIO39 GPIO40 GPIO41:
该模块用的是usb 连接,我们已经配置好USB,我们只要开启对应GPIO即可。
#############hub_usb4_4g_power_h#############
echo 39 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio39/direction
echo 1 > /sys/class/gpio/gpio39/value
#############hub_usb4_4g_power_on############
echo 40 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio40/direction
echo 1 > /sys/class/gpio/gpio40/value
#############hub_usb4_4g_reset_N##################
echo 41 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio41/direction
echo 0 > /sys/class/gpio/gpio41/value
sleep 0.1 echo 1 > /sys/class/gpio/gpio41/value
2、移植4G驱动
修改驱动源码
# vi kernel/drivers/usb/serial/option.c
3、添加内核配置
CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_OPTION=y
2、lsub可以看到识别该模块
上电后可看到如下打印。
3、配置 ppp
CONFIG_PPP=y
CONFIG_PPP_MULTILINK=y
CONFIG_PPP_FILTER=y
CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_PPP_DEFLATE=y
CONFIG_PPP_BSDCOMP=y
6、编辑拨号脚本
# vi /etc/ppp/peers/modem_L610
nodetach
lock
/dev/ttyUSB0
115200
nocrtscts
debug
logfile /tmp/logfile
modem
hide-password
usepeerdns
noauth
noipdefault
novj
novjccomp
noccp
defaultroute
ipcp-accept-local
ipcp-accept-remote
connect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-modem-connect'
disconnect '/usr/sbin/chat -s -v -f /etc/ppp/peers/chat-modem-disconnect'
# vi /etc/ppp/peers/chat-modem-connect
ABORT 'NOCARRIER'
ABORT 'ERROR'
ABORT 'NODIALTONE'
ABORT 'BUSY'
ABORT 'NOANSWER'
'' AT
OK AT+GTRAT?
OK AT+CMEE=2
OK AT+CSQ
OK AT+CPIN?
OK AT+COPS?
OK AT+CGDCONT=1,\"IP\",\"cmnet\"
OK ATDT*99#
CONNECT''
# vi /etc/ppp/peers/chat-modem-disconnect
ABORT OK
ABORT BUSY
ABORT DELAYED
ABORT "NO ANSWER"
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT VOICE
ABORT ERROR
ABORT RINGING
TIMEOUT 12
""\K
""\K
""\K
""+++ATH
""+++ATH
""+++ATH
#""ATZ
SAY"\nGoodbay\n"
7、ppp拨号
pppd call modem_L610 &
尝试ping 114.114.114.114,验证网络是否通畅。
成功连通
13 篇文章
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!