700MHz
的5G基站,需要換用新的5G模組.移遠通訊的RM500U模組
正好可以滿足我們的使用要求;雙卡單待
支援SIM卡熱插拔
支援中國廣電700MHz基站
版本升級方便
tar -xvf Quectel_Linux_USB_Serial_Option_Driver_20211012.tgz
20211012
,其中存放著各個版本的驅動原始碼,如下3.17.0
,我就選擇v3.17.1
版本的驅動# 檢視核心版本
$ uname -a
Linux (none) 3.17.0-xilinx #1 SMP PREEMPT Fri Nov 3 11:57:52 CST 2017 armv7l GNU/Linux
# 選擇版本最接近的驅動
$ cd 20211012/v3.17.1/
RM500U-CN
模組,還需要自己在原始碼中手動新增對RM500U-CN模組的支援,難道是因為這個模組比較新,驅動還未更新?(2022/7/16)drivers/usb/serial/option.c
,新增對RM500U-CN模組的支援lsusb
命令可以看到模組對應的PID
和VID
分別為0x2C7C
和0x0900
,將其新增到option.c
的option_ids[]陣列
中,如下圖:$ make install
# 指明核心原始碼路徑,這裡因為有些敏感資訊,我隱藏了一部分路徑,修改成自己的原始碼路徑即可
KERNELDIR := /***/***/***/***/***/kernel/build/linux-***-v2014.4 # 核心原始碼路徑
PWD := $(shell pwd)
obj-m+=./drivers/usb/serial/option.o
obj-m+=./drivers/usb/serial/usb_wwan.o
obj-m+=./drivers/usb/serial/qcserial.o
modules: clean
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
install: modules
# 這裡表示編譯完成後,執行make install時將驅動拷貝到步驟2.4自定義的路徑下
cp $(PWD)/drivers/usb/serial/*.ko ./install
clean:
$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
# make install ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi-
$ ls install/
option.ko qcserial.ko usb_wwan.ko
# insmod usb_wwan.ko
# insmod option.ko
# insmod qcserial.ko
/dev
目錄下產生5個ttyUSB,dmesg
如下:# dmesg | grep ttyUSB*
[ 1121.543526] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB9
[ 1121.593404] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB10
[ 1121.614269] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB11
[ 1121.655317] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB12
[ 1121.684846] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB13
ifconfig
看不到5G模組對應的interface,這是什麼原因呢?USB NCM
驅動,但是我司的嵌入式裝置上使用的是cdc_ether
驅動,需要修改5G模組的模式minicom 或 microcom
輸入如下AT指令,並重啟模組(minicom或microcom如何使用這裡就不贅述了,網上資料一大堆):# minicom -D /dev/ttyUSB11
AT+QCFG="usbnet",1 # 重啟模組生效
[ 1121.500432] cdc_ether 1-1.1:1.0 usb0: register 'cdc_ether' at usb-zynq-ehci.0-1.1, CDC Ethernet Device, 3e:37:f1:99:c9:6e
# 如使用RNDIS驅動,需要執行如下AT指令
AT+QCFG="usbnet" ,3
# 如使用NCM驅動,需要執行如下AT指令
AT+QCFG="usbnet" ,5
#查詢卡是否成功識別
AT+CPIN?
+CPIN: READY
OK
#查詢APN
AT+CGDCONT?
+CGDCONT: 1,"IPV4V6","3gnet","0.0.0.0",0,0,0,0,,,,,,0,,,0,,0,0,0,0
+CGDCONT: 11,"IPV4V6","ims","0.0.0.0",0,0,0,0,,,,,,0,,,0,,0,0,0,0
OK
#查詢運營商
AT+QSPN
+QSPN: "CHN-UNICOM","UNICOM","CHN-UNICOM",0,"46001"
OK
#設定APN
AT+CGDCONT=1,"IP","3gnet"
OK
#查詢網路資訊:存取計數,運營商,頻段
AT+QNWINFO
+QNWINFO: "FDD LTE",46001,"LTE BAND 3",1506
+QNWINFO: "NR5G-NSA",46001,"",0
OK
#查詢網路設定優先順序
AT+QNWPREFCFG="mode_pref"
+QNWPREFCFG: "mode_pref",AUTO
OK
#設定NSA入網
AT+QNWPREFCFG="mode_pref",NR5G-NSA
OK
#設定SA入網
AT+QNWPREFCFG="mode_pref",NR5G-SA
OK
#設定模組自動選擇入網方式及優先順序
AT+QNWPREFCFG="mode_pref",AUTO
OK
#撥號
AT+QNETDEVCTL=1,1,0
OK
#查詢IP
AT+CGPADDR
+CGPADDR: 1,"10.66.98.208"
+CGPADDR: 11,""
OK
#查詢訊號強度NSA
AT+QENG="servingcell"
+QENG: "servingcell", "NOCONN"
+QENG: "LTE","FDD",460,01,B61D52,312,350,1,3,3,184B,-88,-9,-62,8,12,0,37
+QENG: "NR5G-NSA",460,01,589,-88,17,-3,627264,78,0,6219,1
OK
#查詢訊號強度SA
AT+QENG="servingcell"
+QENG: "servingcell","NOCONN","NR5G-SA","TDD",460,11,596961006,341,590E02,627264,78,100,-88,-10,5,20,28,1
OK
#查詢運營商
AT+QSPN
+QSPN: "CHN-UNICOM","UNICOM","CHN-UNICOM",0,"46001"
OK
#查詢運營商的另一種方法
AT+COPS=3,1
OK
AT+COPS?
+COPS: 0,1,"CUCC",13
OK
#查詢當前使用的卡槽
AT+QUIMSLOT?
+QUIMSLOT: 1
OK
#切換為卡槽2
AT+QUIMSLOT=2
OK
#切換為卡槽1
AT+QUIMSLOT=1
OK
#檢視模組溫度
AT+QTEMP
+QTEMP: "soc-thermal","33"
+QTEMP: "pa-thermal","31"
+QTEMP: "pa5g-thermal","31"
+QTEMP: "board-thermal","32"
OK
#設定使用者名稱,密碼,鑑權方式
AT+QICSGP=1,3,"3gnet","cogent","cogent",2
OK
#查詢使用者名稱,密碼,鑑權方式
AT+QICSGP?
+QICSGP: 1,1,"cmnet","user","passwd",3
OK
#開啟熱插拔,使用該指令時模組中不能插卡
AT+QSIMDET=1,1
#檢視熱插拔狀態
AT+QSIMDET?
NOTE: