Merge "[Feature][ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes"
diff --git a/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c b/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
index 1a14627..14f7110 100755
--- a/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
+++ b/ap/app/zte_comm/wlan/src/wifi_ap_ctrl.c
@@ -1491,7 +1491,8 @@
         } 
     } 
 }
-#if defined(__ESP_8089_CHIP__)
+//zw.wang WiFi for MAC is obtained from firmware and set on 20240508 start
+#if defined(CONFIG_WIFI_EFUSE_MAC)
 int wifi_fw_mac_config_ssid(struct         wlan_ap_server *ap_svr)
 {
 	char ssid_write_flag[8] = {0};
@@ -1515,11 +1516,12 @@
 		sc_cfg_set("at_wifi_mac", fake_at_wifi_mac);
 
 		get_mac_config_ssid_key_nv();
-		wlan_ap_get_para(ap_svr);
-		wlan_ap_save_config(ap_svr);
+		//wlan_ap_get_para(ap_svr);
+		//wlan_ap_save_config(ap_svr);
 	}
 	return 0;
 }
+//zw.wang WiFi for MAC is obtained from firmware and set on 20240508 end
 #endif
 
 #ifdef USE_CAP_SUPPORT
diff --git a/ap/app/zte_comm/wlan/src/wlan_config_ssid.c b/ap/app/zte_comm/wlan/src/wlan_config_ssid.c
index 0187a24..663203f 100755
--- a/ap/app/zte_comm/wlan/src/wlan_config_ssid.c
+++ b/ap/app/zte_comm/wlan/src/wlan_config_ssid.c
@@ -341,12 +341,18 @@
 	//snprintf(mac_cmd, sizeof(mac_cmd), "MAC_A1=%s\n", mac);
 	wf_log ("set_mac_conf:[%s]", mac_cmd);
 	wlan_write_file("/etc_rw/aic_macconfig.txt", mac_cmd);
-#elif defined(__ESP_8089_CHIP__)
+//zw.wang WiFi for MAC is obtained from firmware and set on 20240508 start
+#endif
+	return 0;
+}
+static int set_mac_at (char *mac, char *mac2)
+{
+#if defined(CONFIG_WIFI_EFUSE_MAC)
 	char mac_cmd[128]={0};
 	int ret = 0;
 
-	snprintf(mac_cmd, sizeof(mac_cmd), "AT+MAC=%s\r", s_mac);//no :
-	wf_log ("write mac:[%s]", s_mac);
+	snprintf(mac_cmd, sizeof(mac_cmd), "AT+MAC=%s\r", mac);//no :
+	wf_log ("write mac:[%s]", mac);
 
 	ret = get_modem_info(mac_cmd, NULL, NULL);
 	if (ret != 0) {
@@ -356,7 +362,7 @@
 #endif	
 	return 0;
 }
-
+//zw.wang WiFi for MAC is obtained from firmware and set on 20240508 end
 static VOID setWifiKeyForImei (CHAR* outkey, CHAR* imeistr, UINT32 num)
 {
 	CHAR old_key[WLAN_NV_WPAPSK1_LENGTH] = {0};
@@ -546,6 +552,9 @@
 	make_user_mac (read_mac);
 
 	set_mac_conf(mac, m_mac);
+//zw.wang WiFi for MAC is obtained from firmware and set on 20240508 start
+	set_mac_at(read_mac, m_read_mac);
+//zw.wang WiFi for MAC is obtained from firmware and set on 20240508 end
 }
 
 
diff --git a/ap/app/zte_comm/wlan/src/wlan_main.c b/ap/app/zte_comm/wlan/src/wlan_main.c
index daac630..bd738d5 100755
--- a/ap/app/zte_comm/wlan/src/wlan_main.c
+++ b/ap/app/zte_comm/wlan/src/wlan_main.c
@@ -2028,6 +2028,12 @@
 	MSG_BUF wlanMsg={0};

 	int threadid = 0;

 	char wifiEnabled[8] = {0};

+//zw.wang After rndis used the network, the T106 sleep was repeatedly awakened on 20240429 start

+	char wifiAvailable[8] = {0};

+	sc_cfg_get ("wifiAvailable", wifiAvailable, sizeof (wifiAvailable));

+	if (!strcmp (wifiAvailable, "0"))

+		return -1;

+//zw.wang After rndis used the network, the T106 sleep was repeatedly awakened on 20240429 start

 	prctl(PR_SET_NAME, "wlan", 0, 0, 0);

 //the first step,  log  and envirenment init

 	loglevel_init();

@@ -2043,7 +2049,7 @@
 #endif	

 #endif

 

-#if !(defined(__ESP_8089_CHIP__))

+#if !(defined(CONFIG_WIFI_EFUSE_MAC)) //zw.wang WiFi for MAC is obtained from firmware and set on 20240508
 	send_get_mac_req();

 #endif

 	

@@ -2061,7 +2067,7 @@
 

 

 	init_config();

-#if !(defined(__ESP_8089_CHIP__))

+#if !(defined(CONFIG_WIFI_EFUSE_MAC)) //zw.wang WiFi for MAC is obtained from firmware and set on 20240508
 	get_mac_config_ssid_key_nv();

 #endif

 

@@ -2108,7 +2114,7 @@
 		return -1;

 	}

 

-#if defined(__ESP_8089_CHIP__)

+#if defined(CONFIG_WIFI_EFUSE_MAC) //zw.wang WiFi for MAC is obtained from firmware and set on 20240508
 	wifi_fw_mac_config_ssid(ap_server);

 #endif

 

diff --git a/ap/app/zte_mdl/Makefile b/ap/app/zte_mdl/Makefile
index 7cd997d..c7a1eac 100755
--- a/ap/app/zte_mdl/Makefile
+++ b/ap/app/zte_mdl/Makefile
@@ -72,6 +72,9 @@
 

 CFLAGS 	 += -D__QRCODE_WIFI__

 CFLAGS 	 += -D__USE_AES__

+# zw.wang WiFi for MAC is obtained from firmware and set on 20240508 start
+CFLAGS 	 += -DCONFIG_WIFI_EFUSE_MAC
+# zw.wang WiFi for MAC is obtained from firmware and set on 20240508 end
 

 ifeq ($(WLAN_STA_FUNC),yes)

 CFLAGS += -D__STA_FUNC__

diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Kconfig b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Kconfig
index e20ffc3..3963d90 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Kconfig
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/Kconfig
@@ -5,4 +5,12 @@
 	depends on MMC
 	---help---
 		Enable AIC8800D80L  kernel driver.
-#endmenu
\ No newline at end of file
+# zw.wang WiFi for MAC is obtained from firmware and set on 20240508 start
+config WIFI_EFUSE_MAC
+	tristate "AIC8800D80L Wireless driver use efuse mac"
+	depends on MMC
+	---help---
+		Enable AIC8800D80L  use efuse mac.
+
+# zw.wang WiFi for MAC is obtained from firmware and set on 20240508 end
+#endmenu
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c
index 5acd34e..72bea62 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/wireless/aic8800d80l/rwnx_main.c
@@ -8629,12 +8629,11 @@
         goto err_lmac_reqs;
     if (mac_addr_efuse[0] | mac_addr_efuse[1] | mac_addr_efuse[2] | mac_addr_efuse[3])
     {
-		if(rwnx_hw->sdiodev->chipid == PRODUCT_ID_AIC8800D80){
-			printk("not use mac_addr_efuse\n");
-		}
-		else {
+//zw.wang WiFi for MAC is obtained from firmware and set on 20240508 start
+#if defined(CONFIG_WIFI_EFUSE_MAC)
         	memcpy(init_conf[0].mac_addr, mac_addr_efuse, ETH_ALEN);
-		}
+#endif
+//zw.wang WiFi for MAC is obtained from firmware and set on 20240508 end
     }
 
     printk("get macaddr:%x,%x\r\n", mac_addr_efuse[0], mac_addr_efuse[5]);
diff --git a/ap/os/linux/linux-3.4.x/drivers/net/zvnet/zvnet_dev.c b/ap/os/linux/linux-3.4.x/drivers/net/zvnet/zvnet_dev.c
index 79cbb75..e48b6b8 100755
--- a/ap/os/linux/linux-3.4.x/drivers/net/zvnet/zvnet_dev.c
+++ b/ap/os/linux/linux-3.4.x/drivers/net/zvnet/zvnet_dev.c
@@ -456,17 +456,19 @@
 				}

 			}

 		}else{

-#if 0

-			if(is_multicast_ether_addr(skb_mac_header(skb))){

+//zw.wang After rndis used the network, the T106 sleep was repeatedly awakened on 20240429 start

+#if 1

+			if(is_multicast_ether_addr(skb_mac_header(skb)) && skb->indev == NULL){

 				if(pcu_CoreIsActive(2) == 0){

 					net->stats.tx_errors++;

 					net->stats.tx_dropped++;

-					zv_err("cap psm zvnet drop arp?");

+					//zv_err("cap psm zvnet drop arp?");

 					kfree_skb(skb);

 					return NET_XMIT_SUCCESS;

 				}

 			}

 #endif

+//zw.wang After rndis used the network, the T106 sleep was repeatedly awakened on 20240429 end

 		}

 	}

 	if(unlikely(skb->capHead || skb->next || skb->fclone || skb->cloned 

diff --git a/ap/project/zx297520v3/prj_vehicle_dc_ref/config/normal/config.linux b/ap/project/zx297520v3/prj_vehicle_dc_ref/config/normal/config.linux
index 450f7c8..16efbbb 100755
--- a/ap/project/zx297520v3/prj_vehicle_dc_ref/config/normal/config.linux
+++ b/ap/project/zx297520v3/prj_vehicle_dc_ref/config/normal/config.linux
@@ -1076,7 +1076,9 @@
 # CONFIG_RDAWFMAC is not set
 CONFIG_AIC8800=y
 # CONFIG_AIC8800D80L is not set
-
+# zw.wang WiFi for MAC is obtained from firmware and set on 20240508 start
+CONFIG_WIFI_EFUSE_MAC=y
+# zw.wang WiFi for MAC is obtained from firmware and set on 20240508 end
 CONFIG_AIC8800_SDIO_TX_AGGR=y
 CONFIG_AIC8800_SDIO_RX_AGGR=y
 #
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user
index 3666046..af42ce7 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user
@@ -437,6 +437,12 @@
 wifi_sta_connection=0
 wifi_wps_index=1
 wifiEnabled=1
+#zw.wang After rndis used the network, the T106 sleep was repeatedly awakened on 20240429 start
+wifiAvailable=1
+#zw.wang After rndis used the network, the T106 sleep was repeatedly awakened on 20240429 end
+# zw.wang WiFi for MAC is obtained from firmware and set on 20240508 start
+wifi_mac_num=1
+# zw.wang WiFi for MAC is obtained from firmware and set on 20240508 end
 wifilan=wlan0-va0
 wifilan2=wlan0-va1
 WirelessMode=6
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
index d91390c..23bb8e4 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
@@ -30,11 +30,16 @@
 #define FOTA_REBOOT_FLAG "/mnt/userdata/.fota_reboot_flag"

 #define FOTA_FLAG_FILE "/mnt/userdata/.back_up_flag"

 #define FOTA_SYNC_FLAG    1

+#define FOTA_CURRENT_SYS  "/mnt/userdata/.fota_current_sys"

+

 

 extern int lynq_sync_system();

 extern int lynq_fota_get_addr_value(char *tmp_value);

 extern int lynq_fota_set_addr_value(char        *value,int size);

 extern int lynq_fota_nrestart(void);

+extern int lynq_get_current_system();

+

+

 #define REBOOT_DONE  1

 

 void set_upgrade_reboot_flag(void)

@@ -53,6 +58,134 @@
     system("sync");

     return ;

 }

+

+int check_need_sync()

+{

+    int current_sys = 0;

+    int record_sys = 0;

+    int ret = 0;

+    char tmp_sys[8] = {0};

+    FILE *fp = NULL;

+

+    //not fota 

+    if(access(FOTA_FLAG_FILE, F_OK) == -1)

+    {

+        printf("Fota flag file no exist\n");

+

+        //file no exist,get current sys write to file

+        if(access(FOTA_CURRENT_SYS,F_OK) == -1)

+        {

+            printf("Record current sys file no exist\n");

+            

+            fp = fopen(FOTA_CURRENT_SYS,"w");

+            if(fp == NULL)

+             {

+                printf("creat  record current file failed\n");

+                return -1;

+            }

+            current_sys = lynq_get_current_system();

+            if(current_sys < 0)

+            {

+                printf("Get current system failed %d\n",current_sys);

+                fclose(fp);

+                return -1;

+            }

+            else

+            {

+                

+                printf("Get current system success  %d\n",current_sys);

+                fprintf(fp, "%d", current_sys);

+                system("sync");

+                fclose(fp);

+                return 0;

+            }

+        }

+        else

+        {

+            current_sys = lynq_get_current_system();

+            if(current_sys < 0)

+            {

+                printf("Get current system failed %d\n",current_sys);

+                return -1;

+            }

+

+            printf("Get current system success  %d\n",current_sys);

+            

+            fp = fopen(FOTA_CURRENT_SYS,"r");

+            if(fp == NULL)

+            {

+                printf("read file failed \n");

+                return -1;

+            }

+        

+            if(fgets(tmp_sys, sizeof(tmp_sys), fp) != NULL)

+            {

+                record_sys = atoi(tmp_sys);

+            }

+            else

+            {

+                printf("tmp_sys is NULL");

+                fclose(fp);

+                return -1;

+            }

+            

+            if( record_sys == current_sys)

+            {

+                printf("System not need sync \n");

+                fclose(fp);

+                return 0;

+            }

+            else 

+            {

+                fp = fopen(FOTA_CURRENT_SYS,"w");

+                if(fp == NULL)

+                {

+                    printf("creat file failed  \n");

+                    return -1;

+                }

+                

+                printf("System need sync \n");

+                fprintf(fp,"%d",current_sys);

+                system("sync");

+                fclose(fp);

+                ret = lynq_sync_system();

+                if(ret < 0 )

+                {

+                    printf("A/B sync system failed \n");

+                    return -1;

+                }

+                printf("A/B sync system success \n");

+                return 0;

+            }

+        }

+            

+        

+    }

+    else

+    {

+        fp = fopen(FOTA_CURRENT_SYS,"w");

+        if(fp == NULL)

+        {

+            printf("Creat file failed \n");

+            return -1;

+        }

+        printf("fota flag file exist,record current sys \n");

+        current_sys = lynq_get_current_system();

+        if(current_sys < 0)

+        {

+            printf("Get current system failed %d\n",current_sys);

+            return -1;

+        }

+        

+        fprintf(fp,"%d",current_sys);

+        system("sync");

+        fclose(fp);

+        return 0;

+    }

+           

+

+}

+

 int main()

 {

     int ret = 0 ;

@@ -60,6 +193,8 @@
     char tmp_addr[128] = {0};

     FILE *fp = NULL;

 

+    check_need_sync();

+

     fp = fopen(FOTA_FLAG_FILE,"r");

     if(fp == NULL)

     {

@@ -67,7 +202,7 @@
         return -1;

 

     }

-   

+

     fread(&sync_flag,sizeof(int),1,fp);

     fclose(fp);