Recommendations:
In case your modem’s module firmware does not run the latest Quectel firmware, I highly recommend to flash it to the latest stable version RM520NGLAAR03A03M4G using the steps shown below. Please note that this is not the router’s OpenWRT firmware, rather the module one. A full reference can be found at: Upgrade Quectel Module Software - GL.iNet Router Docs 4
- To upgrade the Quectel modem firmware, SSH into the modem as root, and issue the following commands. Please verify that the calculated md5 hashes of the downloaded Qfirehose and the firmware zip file match the ones shown below within the lines!
opkg update && opkg install unzip
cd /usr/bin/
wget https://fw.gl-inet.com/tools/quectel_tool/QFirehose-mtk7981a-sha256-c0b944
chmod 775 QFirehose-mtk7981a-sha256-c0b944
md5sum QFirehose-mtk7981a-sha256-c0b944
42c934c8be6c860afc8b08c1cdb3fffd QFirehose-mtk7981a-sha256-c0b944
wget https://fw.gl-inet.com/download/RM520GL-modem_firmware/RM520NGLAAR03A03M4G_01.201.01.201.zip -P /
md5sum /RM520NGLAAR03A03M4G_01.201.01.201.zip
6deb45893ce2088729708c9790e4d742 /RM520NGLAAR03A03M4G_01.201.01.201.zip
unzip /RM520NGLAAR03A03M4G_01.201.01.201.zip -d /RM520NGLAAR03A03M4G_01.201.01.201
QFirehose-mtk7981a-sha256-c0b944 -f /RM520NGLAAR03A03M4G_01.201.01.201
echo 1 > /sys/devices/platform/11280000.pcie/pci0001:00/0001:00:00.0/0001:01:00.0/remove
echo 1 > /sys/devices/platform/11280000.pcie/pci0001:00/0001:00:00.0/rescan
gl_modem AT AT+QGMR
rm /RM520NGLAAR03A03M4G_01.201.01.201* -rf
reboot
- Now, familiarize yourself also with the Uboot flashing method, which you will need to use when flashing the downloaded vanilla OpenWRT firmware and the GL’s stock one: Debrick via Uboot - GL.iNet Router Docs 4
Downloading and Flashing a Vanilla OpenWRT firmware on a GL-X3000 router:
- Go to the URL: OpenWrt Firmware Selector
- Click on Customize installed packages and/or first boot script and insert the following packages in addition to the listed ones:
kmod-usb-serial-qualcomm luci-proto-mbim luci-proto-modemmanager luci-proto-qmi luci-ssl minicom kmod-usb-net-cdc-mbim picocom umbim usb-modeswitch pciids pciutils usbids usbmuxd kmod-usb-acm kmod-usb-ehci kmod-usb-net-huawei-cdc-ncm kmod-usb-net-ipheth kmod-usb-net-rndis kmod-usb-ohci kmod-usb-serial-ch341 kmod-usb-serial-ch348 kmod-usb-storage-uas kmod-usb-uhci kmod-usb2
- Click on REQUEST BUILD and wait till the build is successful.
- Once the build is finished, download it to your your computer by clicking on SYSUPGRADE.
- You may also want to verify the downloaded image sha256sum hash prior to flashing it!
- The computer at this stage should be connected to the router using an Ethernet cable!
- Flash the router using the Uboot method:
- Power off the router by unplugging the power cord
- Press and hold the reset button while powering on the router
- Wait for the Internet led to blink 5 times
- Release the reset button
- The Uboot rescue page is now accessible via http://192.168.1.1
- Make sure your computer’s IP/MASK is configured correctly as per the Uboot instructions!
- Select the OpenWrt sysupgrade image and start the upgrade process
- Wait for the router to finish flashing and rebooting ...
- Login to LuCI at https://192.168.1.1/cgi-bin/luci/ and set a password for root.
- SSH into the modem as root, and execute the following commands:
echo -e "AT+QCFG=\"usbnet\",0\r\n" > /dev/ttyUSB2
echo -e "AT+QCFG=\"data_interface\",0,0\r\n" > /dev/ttyUSB2
reboot
- Next browse to https://192.168.1.1/cgi-bin/luci/admin/network/network and create an Internet connection using the following steps:
- Click on Add new interface
- Choose any name for the connection and set the protocol to QMI Cellular and then click Create interface
- set Modem device to /dev/cdc-wdm0
- Enter your APN in the correspondence field
- Click on the Firewall Settings tab and then set Create / Assign firewall-zone to WAN
- Click Save and then Save & Apply
- Refresh the page and now you should now see an established connection. Congrats!
Yet, with the vanilla OpenWRT, the maximum connection speed I could reach is 300-350 Mbps . By contrast, I was getting over 800 Mbps on the GL.iNet firmware – that is more than double the speed! The reason is that GL.iNet uses a proprietary Quectel protocol/drivers that utilize the modem’s PCIe over MHI.
“QMI: A protocol for controlling the modem that is exactly the same as for the USB variant but is instead routed over PCIe/MHI.”
Although a vanilla OpenWRT has some pcie-mhi drivers, I could not get them to work at all after tinkering for a few days! Thus, if you want to triple your connection speed, you need to compile these proprietary drivers by yourself and then install it in your vanilla installation. The next section is for advanced users!
Compiling Quectel PCIe-MHI Drivers (advanced users):
After you have successfully installed a vanilla OpnWRT, perform the following steps in sequence to avoid compiling errors and other nasty issues:
- You need to use any Debian variants (Mint/Ubutrnu ...etc) to compile the required drivers/packages. Note, you may use a virtual machine, but it’s going to be very slow. Let’s first install the prerequisites:
sudo apt update
sudo apt install build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev python3-setuptools rsync swig unzip zlib1g-dev file wget
- Preparing the build system:
git clone https://git.openwrt.org/openwrt/openwrt.git
cd openwrt
git pull
git checkout master
./scripts/feeds update -a
./scripts/feeds install -a
./scripts/feeds install libpam liblzma
./scripts/feeds install -a
sed -i -e 's/libpcre/libpcre2/g' package/feeds/telephony/freeswitch/Makefile
./scripts/feeds install -a
wget https://downloads.openwrt.org/snapshots/targets/mediatek/filogic/config.buildinfo -O .config
make defconfig
make menuconfig
- Go to Target Profile and select GL.iNet GL-X3000
◦ hit Esc twice and when prompted to save the new configurations choose Yes and hit Enter. - Now lets build the toolchain – BE PATIENT – it takes about 30 minutes to finish:
make -j $(($(nproc)+1)) toolchain/install
make -j $(($(nproc)+1)) target/linux/compile
- After downloading the required packages Quectel_QConnectManager_Linux_V1.6.7.zip and Quectel_Linux_PCIE_MHI_Driver_V1.3.7.zip into the /openwrt directory, unzip them to the correct path:
unzip Quectel_Linux_PCIE_MHI_Driver_V1.3.7.zip -d package/kernel/
unzip Quectel_QConnectManager_Linux_V1.6.7.zip -d package/utils/
- Make sure the new packages are properly selected in the menu:
make menuconfig
◦ Enter the Utilities menu and select the quectel-CM-5G by hitting space
◦ Then enter the Kernel modules > Wireless Drivers menu and select kmod-pcie_mhi by hitting space
◦ Both selected packages should have the symbol<M>
◦ hit Esc twice and when prompted to save the new configurations choose Yes and hit Enter. - Compiling the packages:
make package/utils/quectel-CM-5G/{clean,compile} V=sc
make package/kernel/pcie_mhi/{clean,compile} V=sc
- If you have successfully compiled both of them without errors, they should be located at:
ls $HOME/openwrt/bin/packages/aarch64_cortex-a53/base/quectel-CM-5G*.ipk
ls $HOME/openwrt/bin/targets/mediatek/filogic/packages/kmod-pcie_mhi_*.ipk
- Let’s copy both packages to the X3000 device:
scp $HOME/openwrt/bin/packages/aarch64_cortex-a53/base/quectel-CM-5G*.ipk root@192.168.1.1:/root
scp $HOME/openwrt/bin/targets/mediatek/filogic/packages/kmod-pcie_mhi_*.ipk root@192.168.1.1:/root
- SSH into the X3000 router as root and and install both:
opkg install quectel-CM-5G_1.6.7-r1_aarch64_cortex-a53.ipk
opkg install kmod-pcie_mhi_6.6.43.1.3.7-r1_aarch64_cortex-a53.ipk
- reboot the device.
- Once the device is rebooted, SSH into the box and create a Cellular connection using the Quectel connection manager tool and you correct string of your ISP:
quectel-CM -4 -n 1 -s <apn> &
- If you see that udhcpc has obtained an IP from the ISP, then you have successfully established connection!
- To test the Internet accessibility, add the new interface to the WAN zone and insert a DNS server into the correct file:
sed -i -e "/[[:blank:]]*option[[:blank:]]*name[[:blank:]]*'wan'.*/a\\\tlist device 'rmnet_mhi0.1'" /etc/config/firewall
service firewall restart
echo 'nameserver 1.1.1.1' > /tmp/resolv.conf.d/resolv.conf.auto
echo 'nameserver 1.1.1.1' > /tmp/resolv.conf
- Perform a speed test few times and write down the maximum speed you get. We will significantly improve the speed by the next tweaks as there are a lot of dropped packets behind the scene!
- We still need to tweak few things more to prevent packets from being dropped (a bug in the pcie_mhi driver when using HW offloading) as well as improve the speed of the Internet connection on a vanilla OpneWRT:
echo 'pcie_mhi poll_weight=128 debug_mode=0 mhi_mbim_enabled=0 bridge_mode=0 qmap_mode=1' > /etc/modules.d/90-pcie_mhi
echo -e 'net.core.rmem_max = 16777216\nnet.core.wmem_max = 16777216\nnet.ipv4.tcp_rmem = 4096 262144 21367520\nnet.ipv4.tcp_wmem = 4096 24576 21367520\nnet.core.netdev_max_backlog = 4096\nnet.core.somaxconn = 8192' >> /etc/sysctl.conf
sed -i -e 's/\/tmp\/resolv.conf.d\/resolv.conf.auto/\/etc\/dnsmasq.servers/' /etc/config/dhcp
echo 'nameserver 1.1.1.1' > /etc/dnsmasq.servers
- Login into LuCI web interface and enable the use of all cpu cores as well as Hardware flow offloading:
- reboot the router.
- SSH into the router and start the connection again:
quectel-CM -4 -n 1 -s <apn> &
- Perform speed test again and you should get triple the speed without any packets being dropped! To verify whether there are dropped packets, run ifconfig while doing repetitive speed tests.
- To disable IPv6 stack, add the following lines into the /etc/rc.local file and reboot:
sysctl -w net.ipv4.conf.all.send_redirects=0
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
Note! If you do not use the WAN port (eth0) of the GL-X3000, which is a 2.5 Gbps, then you can get even a better speed by utilizing it. To do so, remove the port from the WAN and add it to the bridge.
Re-flashing the stock GL.iNet firmware:
These steps are needed when you want to revert back to stock GL.iNet firmware.
- Download GL’s stock firmware version 4.3.0 (this exact version!):
https://fw.gl-inet.com/firmware/x3000/release/openwrt-x3000-4.0-release20300-0425-1682418941.bin - Flash the downloaded firmware using the Uboot method
- SSH into the modem as root, and execute the following commands:
gl_modem AT 'AT+QCFG="pcie/mode",0'
gl_modem AT 'AT+QCFG="data_interface",1,0'
gl_modem AT 'AT+QCFG="usbnet",0'
- Afterwards, you can upgrade again to latest GL.iNet firmware. Thanks to ywp of GL.iNet for the recovery hint!
Quectel_QConnectManager_Linux_V1.6.7.zip (227.3 KB)
Quectel_Linux_PCIE_MHI_Driver_V1.3.7.zip (142.2 KB)