Re: Installing OpenWrt 21.02 on the TP-Link AD7200

2021-04-20 Thread Alex Henrie
On Tue, Apr 20, 2021 at 4:04 AM Stijn Segers  wrote:
>
> Alex Henrie  schreef op 20 april 2021 07:28:32 CEST:
> >
> >So, what is the correct procedure for installing OpenWrt on the AD7200?
>
> Try downgrading to an older firmware. If that does not work then you'll need 
> to hook up serial to see the messages the flashing process spits out.
>
> Chances are OEM firmware checks for a software version now e.g., which is 
> unset at this point (see tplink-safeloader.c code).

Thanks for the suggestion. The firmware upload fails with the same
error if I try to upload an older version of the stock firmware. The
latest version of the stock firmware (which is the version that is on
the router I have) is 2.0.1.

I next tried setting .soft_ver to "soft_ver:2.0.1\n" and
"soft_ver:2.0.1 Build 20170103 rel.71053\n" in the AD7200 section in
tplink-safeloader.c, but neither worked.

Attaching a serial cable is a good idea, but it will be a week or two
before I can get that done. Do you have any other suggestions?

-Alex

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] toolchain: use xz compression

2021-04-20 Thread Sven Roederer
Also use xz compression, as we do for sdk and imagebuilder.

Signed-off-by: Sven Roederer 
---
 target/toolchain/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/toolchain/Makefile b/target/toolchain/Makefile
index c3ba70db04..cf34a89e04 100644
--- a/target/toolchain/Makefile
+++ b/target/toolchain/Makefile
@@ -62,13 +62,13 @@ $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2: clean
find $(TOOLCHAIN_BUILD_DIR) -name CVS | $(XARGS) rm -rf
mkdir -p $(BIN_DIR)
(cd $(BUILD_DIR); \
-   tar cfj $@ $(TOOLCHAIN_NAME); \
+   tar -I '$(STAGING_DIR_HOST)/bin/xz -7e -T$(if $(filter 
1,$(NPROC)),2,0)' -cf $@ $(TOOLCHAIN_NAME); \
)
 
 download:
 prepare:
-compile: $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2
+compile: $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.xz
 install: compile
 
 clean:
-   rm -rf $(TOOLCHAIN_BUILD_DIR) $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2
+   rm -rf $(TOOLCHAIN_BUILD_DIR) $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.xz
-- 
2.17.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 1/2] iwinfo: nl80211: perform split wiphy dump

2021-04-20 Thread David Bauer
Perform a split wiphy dump when acquiring the hw modelist of a mac80211
device. Otherwise HE capabilities are missing from the message.

This is necessary since upstream commit f8d504caa ("nl80211: reduce
non-split wiphy dump size")  (Kernel 5.9).

Signed-off-by: David Bauer 
---
 iwinfo_nl80211.c | 188 +++
 1 file changed, 110 insertions(+), 78 deletions(-)

diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c
index 6e79ec8..aeff778 100644
--- a/iwinfo_nl80211.c
+++ b/iwinfo_nl80211.c
@@ -2941,8 +2941,73 @@ struct nl80211_modes
bool ok;
uint32_t hw;
uint32_t ht;
+
+   uint32_t nl_freq;
+   uint16_t nl_ht;
+   uint32_t nl_vht;
+   uint16_t he_phy_cap[6];
 };
 
+static int nl80211_eval_modelist(struct nl80211_modes *m)
+{
+   /* Treat any nonzero capability as 11n */
+   if (m->nl_ht > 0)
+   {
+   m->hw |= IWINFO_80211_N;
+   m->ht |= IWINFO_HTMODE_HT20;
+
+   if (m->nl_ht & (1 << 1))
+   m->ht |= IWINFO_HTMODE_HT40;
+   }
+
+   if (m->he_phy_cap[0] != 0) {
+   m->hw |= IWINFO_80211_AX;
+   m->ht |= IWINFO_HTMODE_HE20;
+
+   if (m->he_phy_cap[0] & BIT(9))
+   m->ht |= IWINFO_HTMODE_HE40;
+   if (m->he_phy_cap[0] & BIT(10))
+   m->ht |= IWINFO_HTMODE_HE40 | IWINFO_HTMODE_HE80;
+   if (m->he_phy_cap[0] & BIT(11))
+   m->ht |= IWINFO_HTMODE_HE160;
+   if (m->he_phy_cap[0] & BIT(12))
+   m->ht |= IWINFO_HTMODE_HE160 | IWINFO_HTMODE_HE80_80;
+   }
+
+   if (m->nl_freq < 2485)
+   {
+   m->hw |= IWINFO_80211_B;
+   m->hw |= IWINFO_80211_G;
+   }
+   else if (m->nl_vht)
+   {
+   /* Treat any nonzero capability as 11ac */
+   if (m->nl_vht > 0)
+   {
+   m->hw |= IWINFO_80211_AC;
+   m->ht |= IWINFO_HTMODE_VHT20 | IWINFO_HTMODE_VHT40 | 
IWINFO_HTMODE_VHT80;
+
+   switch ((m->nl_vht >> 2) & 3)
+   {
+   case 2:
+   m->ht |= IWINFO_HTMODE_VHT80_80;
+   /* fall through */
+
+   case 1:
+   m->ht |= IWINFO_HTMODE_VHT160;
+   }
+   }
+   }
+   else if (m->nl_freq >= 56160)
+   {
+   m->hw |= IWINFO_80211_AD;
+   }
+   else if (!(m->hw & IWINFO_80211_AC))
+   {
+   m->hw |= IWINFO_80211_A;
+   }
+}
+
 static int nl80211_get_modelist_cb(struct nl_msg *msg, void *arg)
 {
struct nl80211_modes *m = arg;
@@ -2962,94 +3027,43 @@ static int nl80211_get_modelist_cb(struct nl_msg *msg, 
void *arg)
  nla_data(band), nla_len(band), NULL);
 
if (bands[NL80211_BAND_ATTR_HT_CAPA])
-   caps = 
nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]);
+   m->nl_ht = 
nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]);
 
-   /* Treat any nonzero capability as 11n */
-   if (caps > 0)
-   {
-   m->hw |= IWINFO_80211_N;
-   m->ht |= IWINFO_HTMODE_HT20;
-
-   if (caps & (1 << 1))
-   m->ht |= IWINFO_HTMODE_HT40;
-   }
+   if (bands[NL80211_BAND_ATTR_VHT_CAPA])
+   m->nl_vht = 
nla_get_u32(bands[NL80211_BAND_ATTR_VHT_CAPA]);
 
if (bands[NL80211_BAND_ATTR_IFTYPE_DATA]) {
struct nlattr *tb[NL80211_BAND_IFTYPE_ATTR_MAX 
+ 1];
-   uint16_t phy_cap[6] = { 0 };
struct nlattr *nl_iftype;
int rem_band;
int len;
 
-   m->hw |= IWINFO_80211_AX;
-   m->ht |= IWINFO_HTMODE_HE20;
-
nla_for_each_nested(nl_iftype, 
bands[NL80211_BAND_ATTR_IFTYPE_DATA], rem_band) {
nla_parse(tb, 
NL80211_BAND_IFTYPE_ATTR_MAX,
  nla_data(nl_iftype), 
nla_len(nl_iftype), NULL);
if 
(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]) {
len = 
nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]);
 
-   if (len > sizeof(phy_cap) - 1)
-   len = sizeof(phy_cap) - 
1;
-   memcpy(&((__u8 *)phy_cap)[1],
+  

[PATCH 2/2] iwinfo: cli: fix hwmode formatting

2021-04-20 Thread David Bauer
The placeholder for the 802.11ax hwmode was missing.

Signed-off-by: David Bauer 
---
 iwinfo_cli.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/iwinfo_cli.c b/iwinfo_cli.c
index ee5a0e2..82b409c 100644
--- a/iwinfo_cli.c
+++ b/iwinfo_cli.c
@@ -274,12 +274,12 @@ static char * format_encryption(struct 
iwinfo_crypto_entry *c)
 
 static char * format_hwmodes(int modes)
 {
-   static char buf[15];
+   static char buf[17];
 
if (modes <= 0)
snprintf(buf, sizeof(buf), "unknown");
else
-   snprintf(buf, sizeof(buf), "802.11%s%s%s%s%s%s",
+   snprintf(buf, sizeof(buf), "802.11%s%s%s%s%s%s%s",
(modes & IWINFO_80211_A) ? "a" : "",
(modes & IWINFO_80211_B) ? "b" : "",
(modes & IWINFO_80211_G) ? "g" : "",
-- 
2.31.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH v2] uqmi: fix network registration loop

2021-04-20 Thread thomas . richard
From: Thomas Richard 

With some debug in qmi.sh using following patch, some errors are visible
in the registration step
@@ -29,6 +29,7 @@ proto_qmi_init_config() {
 }

 proto_qmi_setup() {
+   set -x
local interface="$1"
local dataformat connstat plmn_mode mcc mnc
local device apn auth username password pincode delay modes pdptype
@@ -224,6 +225,8 @@ proto_qmi_setup() {
fi
done

+   registration=$(uqmi -s -d "$device" --get-serving-system)
+
[ -n "$modes" ] && uqmi -s -d "$device" --set-network-modes "$modes" > 
/dev/null 2>&1

echo "Starting network $interface"

During the boot of the system, modem could not start automatically its
network registration.
netifd: wan (9235): + echo 'Waiting for network registration'
netifd: wan (9235): Waiting for network registration
netifd: wan (9235): + local 'registration_timeout=0'
netifd: wan (9235): + uqmi -s -d /dev/cdc-wdm1 --get-serving-system
netifd: wan (9235): + grep '"searching"'
netifd: wan (9235): + uqmi -s -d /dev/cdc-wdm1 --get-serving-system
netifd: wan (9235): + 
registration='{"registration":"not_registered","plmn_mcc":208,"plmn_mnc":20,"plmn_description":"","roaming":true}'
netifd: wan (9235): + '[' -n  ]
netifd: wan (9235): + echo 'Starting network wan'

As the while loop checks only "searching" pattern, uqmi.sh script quits
searching loop and continues whereas the modem is not registered

Other issue, after X seconds modem stops searching.
netifd: wan (9213): + uqmi -s -d /dev/cdc-wdm0 --get-serving-system
netifd: wan (9213): + grep '"searching"'
netifd: wan (9213): + '[' -e /dev/cdc-wdm0 ]
netifd: wan (9213): + '[' 3 -lt 0 -o 0 '=' 0 ]
netifd: wan (9213): + let registration_timeout++
netifd: wan (9213): + sleep 1
netifd: wan (9213): + uqmi -s -d /dev/cdc-wdm0 --get-serving-system
netifd: wan (9213): + grep '"searching"'
netifd: wan (9213): + uqmi -s -d /dev/cdc-wdm0 --get-serving-system
netifd: wan (9213): + registration='{"registration":"not_registered"}'
netifd: wan (9213): + '[' -n  ]
netifd: wan (9213): + echo 'Starting network wan'
netifd: wan (9213): Starting network wan

If registration_timeout is not expired, registration can be restarted

Signed-off-by: Thomas Richard 
---
 package/network/utils/uqmi/Makefile|  2 +-
 .../utils/uqmi/files/lib/netifd/proto/qmi.sh   | 35 --
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/package/network/utils/uqmi/Makefile 
b/package/network/utils/uqmi/Makefile
index 68958a3729..da54ba0f46 100644
--- a/package/network/utils/uqmi/Makefile
+++ b/package/network/utils/uqmi/Makefile
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uqmi
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/uqmi.git
diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh 
b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index a6c785eb56..c0134f44dd 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -209,19 +209,36 @@ proto_qmi_setup() {
 
uqmi -s -d "$device" --sync > /dev/null 2>&1
 
+   uqmi -s -d "$device" --network-register > /dev/null 2>&1
+
echo "Waiting for network registration"
+   sleep 1
local registration_timeout=0
-   while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > 
/dev/null; do
-   [ -e "$device" ] || return 1
-   if [ "$registration_timeout" -lt "$timeout" -o "$timeout" = "0" 
]; then
-   let registration_timeout++
-   sleep 1;
+   local registration_state=""
+   while true; do
+   registration_state=$(uqmi -s -d "$device" --get-serving-system 
2>/dev/null | jsonfilter -e "@.registration" 2>/dev/null)
+
+   [ "$registration_state" = "registered" ] && break
+
+   if [ "$registration_state" = "searching" ] || [ 
"$registration_state" = "not_registered" ]; then
+   if [ "$registration_timeout" -lt "$timeout" ] || [ 
"$timeout" = "0" ]; then
+   [ "$registration_state" = "searching" ] || {
+   echo "Device stopped network 
registration. Restart network registration"
+   uqmi -s -d "$device" --network-register 
> /dev/null 2>&1
+   }
+   let registration_timeout++
+   sleep 1
+   continue
+   fi
+   echo "Network registration failed, registration timeout 
reached"
else
-   echo "Network registration failed"
-   proto_notify_error "$interface" 
NETWORK_REGISTRATION_FAILED
-   proto_block_restart "$interface"
-   

[PATCH] kernel: netdev: add qlcnic

2021-04-20 Thread vi...@hakkerinen.eu

Add driver for QLogic QLE8240 and QLE8242 Converged Ethernet devices.

Signed-off-by: Vieno Hakkerinen 
---
 package/kernel/linux/modules/netdevices.mk | 17 +
 1 file changed, 17 insertions(+)

diff --git a/package/kernel/linux/modules/netdevices.mk 
b/package/kernel/linux/modules/netdevices.mk
index bc6ed2c7aa..defb3c1de7 100644
--- a/package/kernel/linux/modules/netdevices.mk
+++ b/package/kernel/linux/modules/netdevices.mk
@@ -885,6 +885,23 @@ endef
 $(eval $(call KernelPackage,macvlan))
 
 
+define KernelPackage/qlcnic

+  SUBMENU:=$(NETWORK_DEVICES_MENU)
+  DEPENDS:=@PCI_SUPPORT
+  TITLE:=QLogic QLE8240 and QLE8242 device support
+  KCONFIG:=CONFIG_QLCNIC
+  FILES:=$(LINUX_DIR)/drivers/net/ethernet/qlogic/qlcnic/qlcnic.ko
+  AUTOLOAD:=$(call AutoProbe,qlcnic)
+endef
+
+define KernelPackage/macvlan/description
+  This driver supports QLogic QLE8240 and QLE8242 Converged Ethernet
+  devices.
+endef
+
+$(eval $(call KernelPackage,qlcnic))
+
+
 define KernelPackage/tulip
   TITLE:=Tulip family network device support
   DEPENDS:=@PCI_SUPPORT +kmod-mii
--
2.31.1

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: Installing OpenWrt 21.02 on the TP-Link AD7200

2021-04-20 Thread Stijn Segers
Hi,

Alex Henrie  schreef op 20 april 2021 07:28:32 CEST:
>Hello everyone,
>
>OpenWrt 21.02 adds support for the TP-Link AD7200,[1][2] but in
>practice I have not been able to install it. When I try uploading any
>of the three images (uImage, factory, sysupgrade) through the web
>interface, it just says "Firmware file error."
>
>I also tried setting my computer's IP address to 192.168.0.66, making
>the image available over TFTP with the name
>AD7200_1.0_tp_recovery.bin, and booting up the router with the reset
>button held down. I had Wireshark open and watched the file being
>transferred, but when the transfer was complete, the router just
>rebooted into its stock firmware again.
>
>So, what is the correct procedure for installing OpenWrt on the AD7200?


Try downgrading to an older firmware. If that does not work then you'll need to 
hook up serial to see the messages the flashing process spits out.

Chances are OEM firmware checks for a software version now e.g., which is unset 
at this point (see tplink-safeloader.c code).

Stijn

>
>-Alex
>
>[1] 
>https://git.openwrt.org/?p=openwrt%2Fopenwrt.git=search=HEAD=commit=ad7200
>[2] 
>https://downloads.openwrt.org/releases/21.02-SNAPSHOT/targets/ipq806x/generic/
>
>___
>openwrt-devel mailing list
>openwrt-devel@lists.openwrt.org
>https://lists.openwrt.org/mailman/listinfo/openwrt-devel

-- 
Verstuurd vanaf mijn Android apparaat met K-9 Mail. Excuseer mijn beknoptheid.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: ath79: mikrotik mac issue

2021-04-20 Thread Roger Pueyo Centelles
Hi,

I gave it a try with OpenWrt SNAPSHOT, r16574-f7e00d81bc and Linux
OpenWrt 5.10.31 #0 Sun Apr 18 14:14:52 2021 mips GNU/Linux. The MAC
addresses are correct too.

Do we have the same file and drivers?

root@OpenWrt:/# md5sum /etc/*/02_network*
02ddf92ac3486bc00a25e0fa436bbba6  /etc/board.d/02_network

root@OpenWrt:/# dmesg | grep -i mikrotik | grep -i driver
[    1.369453] MikroTik RouterBOARD hardware configuration sysfs driver
v0.06
[    1.378313] MikroTik RouterBOARD software configuration sysfs driver
v0.03

Roger

El 20/4/21 a les 10:45, Koen Vandeputte ha escrit:
> Hi Roger,
>
> An important detail:
> I'm testing using kernel 5.10 :-)
>
> Regards,
>
> Koen
>

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: ath79: mikrotik mac issue

2021-04-20 Thread Koen Vandeputte

Hi Roger,

An important detail:
I'm testing using kernel 5.10 :-)

Regards,

Koen

On 18.04.21 19:00, Roger Pueyo Centelles wrote:

Hi,

Sorry, no clue. I am getting MAC addresses correctly assigned on a
MikroTik RB922UAGS-5HPacD running OpenWrt SNAPSHOT, r16574-f7e00d81bc.

As expected, random MAC addresses appear for both eth0 and eth1 on a
fresh boot after flashing with "sysupgrade -v -n. At around ~40 seconds
uptime, the network is activated with the correct MAC addresses enabled
(same as in /etc/config/network):

eth1: /sys/firmware/mikrotik/hard_config/mac_base
eth0: /sys/firmware/mikrotik/hard_config/mac_base+1
wlan0: /sys/firmware/mikrotik/hard_config/mac_base+2

The behaviour is correct on rebooting or reflashing.

Roger

El 16/4/21 a les 17:04, Koen Vandeputte ha escrit:

Hi all,

I found another interesting issue testing on a rb922
The board gets a random mac on each boot.

This is normal and should be automatically corrected by 02_network
afterwards when hard_config is available, but it seems it's not
getting applied correctly.
Debugging the 02_network script shows that the actual value is
properly fetched from hard_config, but it's not getting applied for
some reason ..
/etc/board.json shows the correct ones, but the interfaces still carry
the random MAC.

Judging by the flow in the script, I guess this issue will be present
on all ath79 Mikrotik targets.

Anyone got a clue?

Regards,

Koen



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] uqmi: fix network registration loop

2021-04-20 Thread Florian Eckert




On 2021-04-19 19:46, thomas.rich...@kontron.com wrote:

From: Thomas Richard 

Instrumenting qmi.sh script with following patch, some errors are 
visible.

--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -29,6 +29,7 @@ proto_qmi_init_config() {
 }

 proto_qmi_setup() {
+   set -x
local interface="$1"
local dataformat connstat plmn_mode mcc mnc
local device apn auth username password pincode delay modes 
pdptype

@@ -224,6 +225,8 @@ proto_qmi_setup() {
fi
done

+   registration=$(uqmi -s -d "$device" --get-serving-system)
+
[ -n "$modes" ] && uqmi -s -d "$device" --set-network-modes
"$modes" > /dev/null 2>&1

echo "Starting network $interface"

During the boot of the system, modem could not start automatically its
network registration.
netifd: wan (9235): + echo 'Waiting for network registration'
netifd: wan (9235): Waiting for network registration
netifd: wan (9235): + local 'registration_timeout=0'
netifd: wan (9235): + uqmi -s -d /dev/cdc-wdm1 --get-serving-system
netifd: wan (9235): + grep '"searching"'
netifd: wan (9235): + uqmi -s -d /dev/cdc-wdm1 --get-serving-system
netifd: wan (9235): +
registration='{"registration":"not_registered","plmn_mcc":208,"plmn_mnc":20,"plmn_description":"","roaming":true}'
netifd: wan (9235): + '[' -n  ]
netifd: wan (9235): + echo 'Starting network wan'

As the while loop checks only "searching" pattern, uqmi.sh script
quits searching loop and continues whereas the modem is not registered

Other issue, after X seconds modem stop searching.
netifd: wan (9213): + uqmi -s -d /dev/cdc-wdm0 --get-serving-system
netifd: wan (9213): + grep '"searching"'
netifd: wan (9213): + '[' -e /dev/cdc-wdm0 ]
netifd: wan (9213): + '[' 3 -lt 0 -o 0 '=' 0 ]
netifd: wan (9213): + let registration_timeout++
netifd: wan (9213): + sleep 1
netifd: wan (9213): + uqmi -s -d /dev/cdc-wdm0 --get-serving-system
netifd: wan (9213): + grep '"searching"'
netifd: wan (9213): + uqmi -s -d /dev/cdc-wdm0 --get-serving-system
netifd: wan (9213): + registration='{"registration":"not_registered"}'
netifd: wan (9213): + '[' -n  ]
netifd: wan (9213): + echo 'Starting network wan'
netifd: wan (9213): Starting network wan

If registration_timeout is not expired, registration can be restarted

Signed-off-by: Thomas Richard 
---
 package/network/utils/uqmi/Makefile|  2 +-
 .../utils/uqmi/files/lib/netifd/proto/qmi.sh   | 35 
--

 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/package/network/utils/uqmi/Makefile
b/package/network/utils/uqmi/Makefile
index 68958a3729..da54ba0f46 100644
--- a/package/network/utils/uqmi/Makefile
+++ b/package/network/utils/uqmi/Makefile
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk

 PKG_NAME:=uqmi
-PKG_RELEASE:=2
+PKG_RELEASE:=3

 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/uqmi.git
diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index a6c785eb56..c29187cfbf 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -209,19 +209,36 @@ proto_qmi_setup() {

uqmi -s -d "$device" --sync > /dev/null 2>&1

+   uqmi -s -d "$device" --network-register > /dev/null 2>&1
+
echo "Waiting for network registration"
+   sleep 1
local registration_timeout=0
-   while uqmi -s -d "$device" --get-serving-system | grep '"searching"'
> /dev/null; do
-   [ -e "$device" ] || return 1
-		if [ "$registration_timeout" -lt "$timeout" -o "$timeout" = "0" ]; 
then


Could we please use not -o or -a?

In OpenWrt we prefer && or || pattern


-   let registration_timeout++
-   sleep 1;
+   local registration_state=""
+   while true; do
+   registration_state=$(uqmi -s -d "$device" --get-serving-system
2>/dev/null | jsonfilter -e "@.registration" 2>/dev/null)
+
+   [ "$registration_state" = "registered" ] && break
+
+   if [ "$registration_state" = "searching" -o 
"$registration_state" =
"not_registered" ]; then
+   [ "$registration_timeout" -lt "$timeout" -o "$timeout" = "0" ] 
&& {
+   [ "$registration_state" = "searching" ] || {
+   echo "Device stopped network 
registration. Restart
network registration"
+   uqmi -s -d "$device" --network-register > 
/dev/null 2>&1
+   }
+   let registration_timeout++
+   sleep 1
+   continue
+   }
+   echo "Network registration failed, registration timeout 
reached"
else
-