feat: add pcie dial support for rw350r-gl and other mtk_t7xx devices

This commit is contained in:
sfwtw 2025-04-27 15:37:04 +08:00
parent ce8cae0f69
commit f21eb3b3e9
7 changed files with 247 additions and 181 deletions

View File

@ -26,6 +26,8 @@ LUCI_DEPENDS:=+luci-compat \
+usbutils \
+PACKAGE_luci-app-qmodem_INCLUDE_ADD_PCI_SUPPORT:kmod-pcie_mhi \
+PACKAGE_luci-app-qmodem_INCLUDE_ADD_PCI_SUPPORT:pciutils \
+PACKAGE_luci-app-qmodem_INCLUDE_ADD_MTK_T7XX_SUPPORT:umbim \
+PACKAGE_luci-app-qmodem_INCLUDE_ADD_MTK_T7XX_SUPPORT:kmod-mtk-t7xx \
+PACKAGE_luci-app-qmodem_INCLUDE_ADD_QFIREHOSE_SUPPORT:qfirehose \
+PACKAGE_luci-app-qmodem_USE_TOM_CUSTOMIZED_QUECTEL_CM:quectel-CM-5G-M \
+PACKAGE_luci-app-qmodem_USING_QWRT_QUECTEL_CM_5G:quectel-CM-5G \
@ -33,7 +35,6 @@ LUCI_DEPENDS:=+luci-compat \
+tom_modem \
+jq +bc\
+coreutils +coreutils-stat
define Package/luci-app-qmodem/conffiles
/etc/config/qmodem
@ -69,6 +70,10 @@ endchoice
bool "Add PCIe Modem SUPPORT"
default n
config PACKAGE_luci-app-qmodem_INCLUDE_ADD_MTK_T7XX_SUPPORT
bool "Add MTK-T7XX Modem PCI SUPPORT"
default n
config PACKAGE_luci-app-qmodem_INCLUDE_ADD_QFIREHOSE_SUPPORT
bool "Add Qfirehose SUPPORT"
default n

View File

@ -735,7 +735,7 @@
}
}
update(){
this.get_config();
}
@ -750,7 +750,7 @@
this.task = null;
this.init_nc_table();
}
scan_neighborcell(){
this.get_config();
}
@ -769,15 +769,15 @@
// }
nr_options(){
if (this.rat_input.selectedIndex == 0) {
this.band_tr.style.display = "none";
this.scs_tr.style.display = "none";
}
else{
this.band_tr.style.display = "";
this.scs_tr.style.display = "";
}
if (this.rat_input.selectedIndex == 0) {
this.band_tr.style.display = "none";
this.scs_tr.style.display = "none";
}
else{
this.band_tr.style.display = "";
this.scs_tr.style.display = "";
}
}
init_nc_table(){
var neighborcell_table,setting_table,status_table ;
@ -840,7 +840,6 @@
scs_tr.appendChild(td);
scs_tr.appendChild(td1);
status_th = this.createTH("<%:Status%>");
status_trh = this.createTRHeader();
status_trh.appendChild(status_th);
@ -870,11 +869,10 @@
this.set_config(JSON.stringify(config));
});
//add scan button
var scan_btn = this.createBTN("<%:Scan%>",() => {
this.scan_neighborcell();
});
//add scan button
var scan_btn = this.createBTN("<%:Scan%>",() => {
this.scan_neighborcell();
});
this.setting_table.appendChild(header);
this.setting_table.appendChild(rat_tr);
@ -896,7 +894,7 @@
nr = this.config.NR;
lte = this.config.LTE;
for (let cell_info of nr) {
this.create_nc_tr(1,cell_info);
this.create_nc_tr(1,cell_info);
}
for (let cell_info of lte) {
this.create_nc_tr(0,cell_info);

View File

@ -102,6 +102,52 @@ add_avalible_band_entry()
json_close_object
}
get_driver()
{
for i in $(find $modem_path -name driver);do
lsfile=$(ls -l $i)
type=${lsfile:0:1}
if [ "$type" == "l" ];then
link=$(basename $(ls -l $i | awk '{print $11}'))
case $link in
"mtk_t7xx")
mode="mtk_pcie"
break
;;
"qmi_wwan"*)
mode="qmi"
break
;;
"cdc_mbim")
mode="mbim"
break
;;
"cdc_ncm")
mode="ncm"
break
;;
"cdc_ether")
mode="ecm"
break
;;
"rndis_host")
mode="rndis"
break
;;
"mhi_netdev")
mode="mhi"
break
;;
*)
if [ -z "$mode" ]; then
mode="unknown"
fi
;;
esac
fi
done
echo $mode
}
get_dns()
{
@ -260,32 +306,45 @@ get_rat()
#return raw data
get_connect_status()
{
#get active pdp context
at_cmd="AT+CGACT?"
expect="+CGACT:"
result=`at $at_port $at_cmd | grep $expect|tr '\r' '\n'`
connect_status="No"
for pdp_index in `echo "$result" | tr -d "\r" | awk -F'[,:]' '$3 == 1 {print $2}'`; do
at_cmd="AT+CGPADDR=%s"
at_cmd=$(printf "$at_cmd" "$pdp_index")
expect="+CGPADDR:"
result=$(at $at_port $at_cmd | grep $expect)
if [ -n "$result" ];then
ipv6=$(echo $result | grep -oE "\b([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}\b")
ipv4=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
disallow_ipv4="0.0.0.0"
#remove the disallow ip
if [ "$ipv4" == "$disallow_ipv4" ];then
ipv4=""
fi
fi
if [ -n "$ipv4" ] || [ -n "$ipv6" ];then
driver=$(get_driver)
if [ "$driver" = "mtk_pcie" ]; then
mbim_port=$(echo "$at_port" | sed 's/at/mbim/g')
local config=$(umbim -d $mbim_port config)
local ipv4=$(echo "$config" | grep "ipv4address:" | awk '{print $2}' | cut -d'/' -f1)
local ipv6=$(echo "$config" | grep "ipv6address:" | awk '{print $2}' | cut -d'/' -f1)
disallow_ipv4="0.0.0.0"
if [ -n "$ipv4" ] && [ "$ipv4" != "$disallow_ipv4" ] || [ -n "$ipv6" ] && [ "$ipv6" != "::" ]; then
connect_status="Yes"
break
else
connect_status="No"
fi
done
else
at_cmd="AT+CGACT?"
expect="+CGACT:"
result=`at $at_port $at_cmd | grep $expect|tr '\r' '\n'`
for pdp_index in `echo "$result" | tr -d "\r" | awk -F'[,:]' '$3 == 1 {print $2}'`; do
at_cmd="AT+CGPADDR=%s"
at_cmd=$(printf "$at_cmd" "$pdp_index")
expect="+CGPADDR:"
result=$(at $at_port $at_cmd | grep $expect)
if [ -n "$result" ];then
ipv6=$(echo $result | grep -oE "\b([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}\b")
ipv4=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
disallow_ipv4="0.0.0.0"
#remove the disallow ip
if [ "$ipv4" == "$disallow_ipv4" ];then
ipv4=""
fi
fi
if [ -n "$ipv4" ] || [ -n "$ipv6" ];then
connect_status="Yes"
break
else
connect_status="No"
fi
done
fi
add_plain_info_entry "connect_status" "$connect_status" "Connect Status"
}

View File

@ -71,53 +71,6 @@ EOF
esac
}
get_driver()
{
for i in $(find $modem_path -name driver);do
lsfile=$(ls -l $i)
type=${lsfile:0:1}
if [ "$type" == "l" ];then
link=$(basename $(ls -l $i | awk '{print $11}'))
case $link in
"mtk_t7xx")
mode="mtk_pcie"
break
;;
"qmi_wwan"*)
mode="qmi"
break
;;
"cdc_mbim")
mode="mbim"
break
;;
"cdc_ncm")
mode="ncm"
break
;;
"cdc_ether")
mode="ecm"
break
;;
"rndis_host")
mode="rndis"
break
;;
"mhi_netdev")
mode="mhi"
break
;;
*)
if [ -z "$mode" ]; then
mode="unknown"
fi
;;
esac
fi
done
echo $mode
}
unlock_sim()
{
pin=$1
@ -299,7 +252,16 @@ check_ip()
esac
;;
esac
ipaddr=$(at "$at_port" "$check_ip_command" | grep +CGPADDR:)
if [ "$driver" = "mtk_pcie" ]; then
mbim_port=$(echo "$at_port" | sed 's/at/mbim/g')
local config=$(umbim -d $mbim_port config)
ipaddr=$(echo "$config" | grep "ipv4address:" | awk '{print $2}' | cut -d'/' -f1)
ipaddr="$ipaddr $(echo "$config" | grep "ipv6address:" | awk '{print $2}' | cut -d'/' -f1)"
else
ipaddr=$(at "$at_port" "$check_ip_command" | grep +CGPADDR:)
fi
if [ -n "$ipaddr" ];then
if [ $mtk -eq 1 ] && echo "$ipv4_config" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
if [ "$pdp_type" = "ipv4v6" ];then
@ -313,7 +275,6 @@ check_ip()
ipv4=$(echo $ipaddr | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
if [ "$manufacturer" = "simcom" ];then
ipv4=$(echo $ipaddr | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | grep -v "0\.0\.0\.0" | head -n 1)
ipaddr=$(echo $ipaddr | sed 's/\./:/g' | sed 's/+CGPADDR: //g' | sed 's/'$ipv4',//g')
ipv6=$(echo $ipaddr | grep -oE "\b([0-9a-fA-F]{0,4}.){2,7}[0-9a-fA-F]{0,4}\b")
fi
disallow_ipv4="0.0.0.0"
@ -629,21 +590,21 @@ wwan_hang()
ecm_hang()
{
if [ "$manufacturer" = "quectel" ]; then
at_command="AT+QNETDEVCTL=1,2,1"
elif [ "$manufacturer" = "fibocom" ]; then
#联发科平台广和通FM350-GL
if [ "$platform" = "mediatek" ]; then
at_command="AT+CGACT=0,3"
else
at_command="AT+GTRNDIS=0,1"
fi
elif [ "$manufacturer" = "meig" ]; then
at_command="AT$QCRMCALL=0,1,1,2,1"
else
at_command='ATI'
fi
at_command="AT+QNETDEVCTL=1,2,1"
elif [ "$manufacturer" = "fibocom" ]; then
#联发科平台广和通FM350-GL
if [ "$platform" = "mediatek" ]; then
at_command="AT+CGACT=0,3"
else
at_command="AT+GTRNDIS=0,1"
fi
elif [ "$manufacturer" = "meig" ]; then
at_command="AT$QCRMCALL=0,1,1,2,1"
else
at_command='ATI'
fi
tmp=$(at "${at_port}" "${at_command}")
tmp=$(at "${at_port}" "${at_command}")
}
@ -688,29 +649,29 @@ qmi_dial()
{
cmd_line="quectel-CM"
[ -e "/usr/bin/quectel-CM-M" ] && cmd_line="quectel-CM-M"
case $pdp_type in
"ip") cmd_line="$cmd_line -4" ;;
"ipv6") cmd_line="$cmd_line -6" ;;
"ipv4v6") cmd_line="$cmd_line -4 -6" ;;
*) cmd_line="$cmd_line -4 -6" ;;
esac
case $pdp_type in
"ip") cmd_line="$cmd_line -4" ;;
"ipv6") cmd_line="$cmd_line -6" ;;
"ipv4v6") cmd_line="$cmd_line -4 -6" ;;
*) cmd_line="$cmd_line -4 -6" ;;
esac
if [ "$network_bridge" = "1" ]; then
cmd_line="$cmd_line -b"
fi
if [ -n "$apn" ]; then
cmd_line="$cmd_line -s $apn"
fi
if [ -n "$username" ]; then
cmd_line="$cmd_line $username"
fi
if [ -n "$password" ]; then
cmd_line="$cmd_line $password"
fi
if [ "$auth" != "none" ]; then
cmd_line="$cmd_line $auth"
fi
if [ -n "$modem_netcard" ]; then
if [ "$network_bridge" = "1" ]; then
cmd_line="$cmd_line -b"
fi
if [ -n "$apn" ]; then
cmd_line="$cmd_line -s $apn"
fi
if [ -n "$username" ]; then
cmd_line="$cmd_line $username"
fi
if [ -n "$password" ]; then
cmd_line="$cmd_line $password"
fi
if [ "$auth" != "none" ]; then
cmd_line="$cmd_line $auth"
fi
if [ -n "$modem_netcard" ]; then
qmi_if=$modem_netcard
#if is wwan* ,use the first part of the name
if [[ "$modem_netcard" = "wwan"* ]];then
@ -720,8 +681,8 @@ qmi_dial()
if [[ "$modem_netcard" = "rmnet"* ]];then
qmi_if=$(echo "$modem_netcard" | cut -d. -f1)
fi
cmd_line="${cmd_line} -i ${qmi_if}"
fi
cmd_line="${cmd_line} -i ${qmi_if}"
fi
if [ "$en_bridge" = "1" ];then
cmd_line="${cmd_line} -b"
fi
@ -749,7 +710,7 @@ at_dial()
pdp_type="IP"
fi
local at_command='AT+COPS=0,0'
tmp=$(at "${at_port}" "${at_command}")
tmp=$(at "${at_port}" "${at_command}")
pdp_type=$(echo $pdp_type | tr 'a-z' 'A-Z')
case $manufacturer in
"quectel")
@ -821,50 +782,81 @@ at_dial()
esac
m_debug "dialing vendor:$manufacturer;platform:$platform; $cgdcont_command ; $at_command"
at "${at_port}" "${cgdcont_command}"
if [ $mtk -eq 1 ];then
sleep 3
fi
[ $mtk -eq 1 ] && sleep 1
at "$at_port" "$at_command"
if [ $mtk -eq 1 ];then
sleep 3
[ $mtk -eq 1 ] && sleep 1
if [ "$driver" = "mtk_pcie" ];then
mbim_port=$(echo "$at_port" | sed 's/at/mbim/g')
umbim -d $mbim_port disconnect > /dev/null 2>&1
sleep 1
umbim -d $mbim_port connect > /dev/null 2>&1
sleep 1
fi
}
ip_change_fm350()
{
m_debug "ip_change_fm350"
at_command="AT+CGPADDR=3"
local ipv4_config=$(at ${at_port} ${at_command} | cut -d, -f2 | grep -oE '[0-9]+.[0-9]+.[0-9]+.[0-9]+')
local public_dns1_ipv4="223.5.5.5"
local public_dns2_ipv4="119.29.29.29"
local public_dns1_ipv6="2400:3200::1"
local public_dns2_ipv6="2402:4e00::"
at_command="AT+GTDNS=3" | grep "+GTDNS: "| grep -E '[0-9]+.[0-9]+.[0-9]+.[0-9]+' | sed -n '1p'
local ipv4_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $1}')
[ -z "$ipv4_dns1" ] && {
ipv4_dns1="${public_dns1_ipv4}"
}
local ipv4_config=""
local ipv4_dns1=""
local ipv4_dns2=""
local ipv6_dns1=""
local ipv6_dns2=""
local gateway=""
local netmask="255.255.255.0"
local ipv4_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $1}')
[ -z "$ipv4_dns2" ] && {
ipv4_dns2="${public_dns2_ipv4}"
}
if [ "$driver" = "mtk_pcie" ]; then
mbim_port=$(echo "$at_port" | sed 's/at/mbim/g')
local ipv6_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $2}')
[ -z "$ipv6_dns1" ] && {
ipv6_dns1="${public_dns1_ipv6}"
}
local config=$(umbim -d $mbim_port config)
ipv4_config=$(echo "$config" | grep "ipv4address:" | awk '{print $2}' | cut -d'/' -f1)
gateway=$(echo "$config" | grep "ipv4gateway:" | awk '{print $2}')
local ipv6_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $2}')
[ -z "$ipv6_dns2" ] && {
ipv6_dns2="${public_dns2_ipv6}"
}
uci_ipv4=$(uci -q get network.$interface_name.ipaddr)
ipv4_dns1=$(echo "$config" | grep "ipv4dnsserver:" | head -n 1 | awk '{print $2}')
ipv4_dns2=$(echo "$config" | grep "ipv4dnsserver:" | tail -n 1 | awk '{print $2}')
if [ "$ipv4_dns1" = "$ipv4_dns2" ]; then
ipv4_dns2="119.29.29.29"
fi
ipv6_dns1=$(echo "$config" | grep "ipv6dnsserver:" | head -n 1 | awk '{print $2}')
ipv6_dns2=$(echo "$config" | grep "ipv6dnsserver:" | tail -n 1 | awk '{print $2}')
m_debug "umbim config: ipv4=$ipv4_config, gateway=$gateway, netmask=$netmask, dns1=$ipv4_dns1, dns2=$ipv4_dns2"
else
at_command="AT+CGPADDR=3"
ipv4_config=$(at ${at_port} ${at_command} | cut -d, -f2 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
gateway="${ipv4_config%.*}.1"
local public_dns1_ipv4="223.5.5.5"
local public_dns2_ipv4="119.29.29.29"
local public_dns1_ipv6="2400:3200::1"
local public_dns2_ipv6="2402:4e00::"
at_command="AT+GTDNS=3" | grep "+GTDNS: "| grep -E '[0-9]+.[0-9]+.[0-9]+.[0-9]+' | sed -n '1p'
local ipv4_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $1}')
[ -z "$ipv4_dns1" ] && {
ipv4_dns1="${public_dns1_ipv4}"
}
local ipv4_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $1}')
[ -z "$ipv4_dns2" ] && {
ipv4_dns2="${public_dns2_ipv4}"
}
local ipv6_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $2}')
[ -z "$ipv6_dns1" ] && {
ipv6_dns1="${public_dns1_ipv6}"
}
local ipv6_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $2}')
[ -z "$ipv6_dns2" ] && {
ipv6_dns2="${public_dns2_ipv6}"
}
uci_ipv4=$(uci -q get network.$interface_name.ipaddr)
fi
uci set network.${interface_name}.proto='static'
uci set network.${interface_name}.ipaddr="${ipv4_config}"
uci set network.${interface_name}.netmask='255.255.255.0'
uci set network.${interface_name}.gateway="${ipv4_config%.*}.1"
uci set network.${interface_name}.netmask="${netmask}"
uci set network.${interface_name}.gateway="${gateway}"
uci set network.${interface_name}.peerdns='0'
uci -q del network.${interface_name}.dns
uci add_list network.${interface_name}.dns="${ipv4_dns1}"
@ -989,7 +981,7 @@ at_dial_monitor()
check_ip
if [ $connection_status -eq 0 ];then
at_dial
sleep 5
sleep 3
elif [ $connection_status -eq -1 ];then
unexpected_response_count=$((unexpected_response_count+1))
if [ $unexpected_response_count -gt 3 ];then

View File

@ -176,12 +176,12 @@ scan_pcie_slot_interfaces()
#mt_t7xx device
wwan_path="$slot_path/wwan"
if [ -d "$wwan_path" ]; then
net_devices=$(ls "$wwan_path" | grep -E "wwan[0-9]")
devices_path="$wwan_path/$net_devices"
if [ -d "$devices_path" ];then
mbim_devices=$(ls "$devices_path" | grep -E "wwan[0-9]mbim[0-9]")
dun_devices=$(ls "$devices_path" | grep -E "wwan[0-9]at[0-9]")
fi
net_devices=$(ls "$wwan_path" | grep -E "wwan[0-9]")
devices_path="$wwan_path/$net_devices"
if [ -d "$devices_path" ];then
mbim_devices=$(ls "$devices_path" | grep -E "wwan[0-9]mbim[0-9]")
dun_devices=$(ls "$devices_path" | grep -E "wwan[0-9]at[0-9]")
fi
fi
echo "net_devices: $net_devices dun_devices: $dun_devices"
at_ports="$dun_devices"
@ -283,25 +283,23 @@ match_config()
[[ "$name" = *"nl668"* ]] && name="nl668"
[[ "$name" = *"nl678"* ]] && name="nl678"
[[ "$name" = *"em120k"* ]] && name="em120k"
[[ "$name" = *"em120k"* ]] && name="em120k"
#FM350-GL-00 5G Module
[[ "$name" = *"fm350-gl"* ]] && name="fm350-gl"
#FM350-GL-00 5G Module
[[ "$name" = *"fm350-gl"* ]] && name="fm350-gl"
#RM500U-CNV
[[ "$name" = *"rm500u-cn"* ]] && name="rm500u-cn"
#RM500U-CNV
[[ "$name" = *"rm500u-cn"* ]] && name="rm500u-cn"
[[ "$name" = *"rm500u-ea"* ]] && name="rm500u-ea"
#t99w175
[[ "$name" = *"mv31-w"* ]] && name="t99w175"
[[ "$name" = *"rm500u-ea"* ]] && name="rm500u-ea"
#t99w175
[[ "$name" = *"mv31-w"* ]] || [[ "$name" = *"T99W175"* ]] && name="t99w175"
[[ "$name" = *"T99W175"* ]] && name="t99w175"
[[ "$name" = *"T99W373"* ]] && name="t99w373"
[[ "$name" = *"T99W373"* ]] && name="t99w373"
[[ "$name" = *"SIM8380G"* ]] && name="SIM8380G-M2"
[[ "$name" = *"SIM8380G"* ]] && name="SIM8380G-M2"
#rg200u-cn
#rg200u-cn
[[ "$name" = *"rg200u-cn"* ]] && name="rg200u-cn"
modem_config=$(echo $modem_support | jq '.modem_support."'$slot_type'"."'$name'"')

View File

@ -1005,6 +1005,15 @@
"mbim"
]
},
"rw350r-gl": {
"manufacturer": "fibocom",
"platform": "mediatek",
"data_interface": "pcie",
"define_connect": "1",
"modes": [
"mbim"
]
},
"fm150-ae": {
"manufacturer": "fibocom",
"platform": "qualcomm",

View File

@ -58,6 +58,11 @@ get_mode()
"41") mode="rndis" ;;
*) mode="$mode_num" ;;
esac
driver=$(get_driver)
case "$driver" in
"mtk_pcie")
mode="mbim" ;;
esac
;;
*)
mode="$mode_num"