Merge "[Feature][ZXW-265]merge P56U03 version"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
index 2c97505..dd13fc7 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
@@ -48,11 +48,11 @@
         install -d ${D}${includedir}/

         cp -raf ${SRC-DIR}/include/ ${D}${includedir}/

         install -d ${D}/data/gnss_update

-        install -m 644 ${WORKONSRC}UC6228CI-R3.2.10.100Build8019_mfg.pkg ${D}/data/gnss_update

-        install -m 644 ${WORKONSRC}bootloader_r3.0.0_build6773_uartboot_921600.pkg ${D}/data/gnss_update

+        install -m 644 ${WORKONSRC}HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQALS.ANT.EPH.CFG.PPS13.240115R1.bin ${D}/data/gnss_update

+        install -m 644 ${WORKONSRC}HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQBS.B1C.ANT.EPH.CFG.PPS13.240308R1.bin ${D}/data/gnss_update

         install -m 644 ${WORKONSRC}agps.conf ${D}/data/gnss_update

-        ln -sf ./UC6228CI-R3.2.10.100Build8019_mfg.pkg ${D}/data/gnss_update/firmware.pkg

-        ln -sf ./bootloader_r3.0.0_build6773_uartboot_921600.pkg ${D}/data/gnss_update/bootloader.pkg

+        ln -sf ./HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQALS.ANT.EPH.CFG.PPS13.240115R1.bin ${D}/data/gnss_update/HD.bin

+        ln -sf ./HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQBS.B1C.ANT.EPH.CFG.PPS13.240308R1.bin ${D}/data/gnss_update/HD_BD.bin

     fi 

 }

 

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/fwup.c b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/fwup.c
new file mode 100755
index 0000000..6b126bb
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/fwup.c
@@ -0,0 +1,459 @@
+/*!

+ *****************************************************************************

+ **

+ ** \file        fwup.c

+ ** \brief       firmware update function

+ **

+ ** \attention   This sample code is provided "as is" without warranty of any

+ **              kind. We disclaim all warranties, either express or implied,

+ **              including the warranties of merchantability and fitness for a

+ **              particular purpose.

+ **

+ **

+ *****************************************************************************/

+#include <termios.h>

+#include "hd8040_upgrade.h"

+

+#define READ_LENGTH 128

+#define VERSION_MAX_LEN 16

+

+const uint8_t cmdMONVER[] = {0xf1, 0xd9, 0x0a, 0x04, 0x00, 0x00, 0x0e, 0x34};

+const uint8_t cmdSETFRQ[] = {0xf1, 0xd9, 0xf4, 0x00, 0x04, 0x00, 0x80, 0xba, 0x8c, 0x01, 0xbf, 0xff};

+uint8_t cmdSETFRQ_ONLY[] = {0xF1, 0xD9, 0xF4, 0x03, 0x08, 0x00, 0x00, 0x08, 0x07, 0x00, 0x00, 0x08, 0x07, 0x00, 0x1D, 0x69};

+const uint8_t cmdCFGFWUP[] = {0xf1, 0xd9, 0x06, 0x50, 0x01, 0x00, 0x10, 0x67, 0x71, 0x00};

+uint8_t cmdOpenWrtPro[] = 	{0xF1, 0xD9, 0xF4, 0x08, 0x04, 0x00, 0x00, 0x02, 0x00, 0x80, 0x82, 0x76};

+uint8_t cmdOpenQe_and_wrtPro[] = {0xF1, 0xD9, 0xF4, 0x13, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x0E, 0x55};

+const uint8_t cmdBOOTERASE[] = {0xf1, 0xd9, 0xf4, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x8f, 0x95};

+uint8_t cmdBOOTERASE_100[] = {0xf1, 0xd9, 0xf4, 0x05, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0f, 0x25};

+const uint8_t cmdCFGRST[] = {0xf1, 0xd9, 0x06, 0x40, 0x01, 0x00, 0x00, 0x47, 0x21};

+uint8_t cmdBOOTERASE_900[] = {0xf1, 0xd9, 0xf4, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x8f, 0x95};

+uint8_t cmd_RadFlash[] = {0xF1, 0xD9, 0xF4, 0x07, 0x01, 0x00, 0x02, 0xFE, 0xE5};

+

+const uint8_t cmdBOOTBAUD[] = {0xf1, 0xd9, 0xf4, 0x03, 0x08, 0x00, 0x00, 0xc2, 0x01, 0x00, 0x00, 0xc2, 0x01, 0x00, 0x85, 0x7d};

+uint8_t cmdNMEAOFF[] = {

+    0xf1, 0xd9, 0x06, 0x01, 0x03, 0x00, 0xf0, 0x00, 0x00, 0xfa, 0x0f,

+    0xf1, 0xd9, 0x06, 0x01, 0x03, 0x00, 0xf0, 0x02, 0x00, 0xfc, 0x13,

+    0xf1, 0xd9, 0x06, 0x01, 0x03, 0x00, 0xf0, 0x03, 0x00, 0xfd, 0x15,

+    0xf1, 0xd9, 0x06, 0x01, 0x03, 0x00, 0xf0, 0x04, 0x00, 0xfe, 0x17,

+    0xf1, 0xd9, 0x06, 0x01, 0x03, 0x00, 0xf0, 0x05, 0x00, 0xff, 0x19,

+    0xf1, 0xd9, 0x06, 0x01, 0x03, 0x00, 0xf0, 0x06, 0x00, 0x00, 0x1b,

+    0xf1, 0xd9, 0x06, 0x01, 0x03, 0x00, 0xf0, 0x07, 0x00, 0x01, 0x1d

+};

+

+

+static int

+byte_array_to_hex_string(char *pResult, uint8_t const * pData, int dataLen)

+{

+    int strLen = 0;

+    int res = 0;

+    char * pMsg = pResult;

+    int i = 0;

+

+    if(!pData || !pResult || dataLen <= 0)

+    {

+        HDBD_LOG("[%s %d]Para err, return -1\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+

+    for(i = 0; i < dataLen; ++i)

+    {

+        /*  The first Hex value does not need a leading '-' */

+        if(i != 0)

+        {

+            res = snprintf(pMsg + strLen, 2, "-");

+            /* increase the total strLength */

+            if(res >= 0)

+            {

+                strLen += res;

+            }

+            else

+            {

+                HDBD_LOG("[%s %d]add leading Error, return -1\n", __FUNCTION__, __LINE__);

+                return -1;

+            }

+        }

+

+        /*  Print the hex character to the string */

+        res = snprintf(pMsg + strLen, 3, "%02X", pData[i]);

+        if(res >= 0)

+        {

+            strLen += res;

+        }

+        else

+        {

+            HDBD_LOG("[%s %d]Print the hex character to the string Error, return -1\n", __FUNCTION__, __LINE__);

+            return -1;

+        }

+    }

+

+    return strLen;

+}

+

+/**

+  * @brief  send cmd to chip wait result

+  * @param  uart_fd : uart fd

+  * @param  cmd : send data command

+  * @param  recv_buf : send result

+  * @param  send_length: send cmd length

+  * @param  recv_length : result length

+  * @param  timeout : wait result time

+  * @retval SUCCESS/FAIL

+  */

+static int 

+send_cmd_and_recv_result(int uart_fd, uint8_t *cmd, uint8_t *recv_buf, int send_length, int *recv_length, int timeout)

+{

+    int ret = -1;

+

+    ret = uart_send(uart_fd, cmd, send_length);

+    if(ret == -1)

+    {

+        HDBD_LOG("[%s %d] uart send failed\n", __FUNCTION__, __LINE__);

+        return  ret;

+    }

+

+    ret = uart_recv(uart_fd, recv_buf, recv_length, timeout);

+    if(ret == -1)

+    {

+        HDBD_LOG("[%s %d] uart recv failed\n", __FUNCTION__, __LINE__);

+        return  ret;

+    }

+

+    return 0;

+}

+

+/**

+  * @brief  Boot mode send one block data of firmware

+  * @param  addr: address of the data in HD8030 chip memory

+  * @param  cnt : the number of the block

+  * @param  data: the pointer of the block data

+  * @param  len : the length of data

+  * @retval None

+  */

+int sendfwboot(int uart_fd, uint32_t addr, uint16_t cnt, uint8_t *data, uint32_t len, uint8_t *recv_buf)

+{

+    uint8_t cmd[] = {0xf1, 0xd9, 0xf4, 0x05, 0x06, 0x08, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00};

+    uint8_t ck[2] = { 0 };

+    int i = 0;

+    uint32_t ck1 = 0, ck2 = 0;

+    int actual_length = 10;//READ_LENGTH-1;

+    int time_out = 3; /* 1 second */

+

+    *((uint16_t *)(cmd + 4)) = len + 6;

+    *((uint32_t *)(cmd + 6)) = addr;

+    *((uint16_t *)(cmd + 10)) = cnt;

+    for(i = 0; i < 12; ++i)

+    {

+        if(i >= 2)

+        {

+            ck1 += cmd[i];

+            ck2 += ck1;

+        }

+    }

+    for(i = 0; i < len; ++i)

+    {

+        ck1 += data[i];

+        ck2 += ck1;

+    }

+    ck[0] = ck1;

+    ck[1] = ck2;

+

+    uart_send(uart_fd, (uint8_t *)cmd, 12);

+    uart_send(uart_fd, (uint8_t *)data, len);

+    send_cmd_and_recv_result(uart_fd, (uint8_t *)ck, recv_buf, 2, &actual_length, time_out);

+    HDBD_LOG("[%s %d]boot up: cnt is <%d>, recv [%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x]\n", __FUNCTION__, __LINE__, cnt, recv_buf[0], recv_buf[1], recv_buf[2], recv_buf[3],recv_buf[4], recv_buf[5], recv_buf[6], recv_buf[7], recv_buf[8], recv_buf[9]);

+    if( (recv_buf[0] == 0xF1) && (recv_buf[1] == 0xD9) && (recv_buf[2] == 0x05) && (recv_buf[3] == 0x01) )

+    {

+        return 0;

+    }

+

+    return -1;

+}

+

+

+

+

+/**

+  * @brief  get version from chip,if user do not save version, so get_mon_ver(NULL, 0)

+  * @param  ver_buf:save version buffer

+  * @param  ver_len:length of version buffer

+  * @retval SUCCESS/FAIL

+  */

+int get_mon_ver(int uart_fd,uint8_t *ver_buf, int ver_len)

+{

+    int ret = -1;

+    int actual_length = 40;

+    uint8_t cur_sw_ver[VERSION_MAX_LEN + 1] = {0};

+    uint8_t cur_hw_ver[VERSION_MAX_LEN + 1] = {0};

+    uint8_t recv_buf[READ_LENGTH] = {0};

+    uint16_t f1StarAddr = 0;

+    uint8_t read_count = 0;

+    int time_out = 3; /* 1 second */

+    char str_hex[512] = {0};

+

+    if(NULL == ver_buf || ver_len < 41)

+    {

+        HDBD_LOG("[%s %d]Para mybe error, FAIL\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+

+    memset(recv_buf, 0x0, sizeof(recv_buf));

+    memset(cur_sw_ver, 0x0, VERSION_MAX_LEN);

+    memset(cur_hw_ver, 0x0, VERSION_MAX_LEN);

+

+    HDBD_LOG("[%s %d] enter\n", __FUNCTION__, __LINE__);

+    ret = uart_send(uart_fd, cmdMONVER, sizeof(cmdMONVER));

+    if(ret == -1)

+    {

+        HDBD_LOG("[%s %d] uart send failed\n", __FUNCTION__, __LINE__);

+        return  ret;

+    }

+

+    read_count = 1;

+    while(1)

+    {

+        if((read_count % 10) == 0)

+        {

+            ret = uart_send(uart_fd, cmdMONVER, sizeof(cmdMONVER));

+            if(ret == -1)

+            {

+                HDBD_LOG("[%s %d] uart send failed\n", __FUNCTION__, __LINE__);

+                return	ret;

+            }

+        }

+

+        ret = uart_recv(uart_fd, recv_buf, &actual_length, time_out);

+        if(ret == -1)

+        {

+            HDBD_LOG("[%s %d] uart recv failed\n", __FUNCTION__, __LINE__);

+            return  ret;

+        }

+

+        f1StarAddr = 0;

+        HDBD_LOG("[%s %d] actual_length:%d, read_count:%d\n", __FUNCTION__, __LINE__, actual_length, read_count);

+        memset(str_hex, 0x0, sizeof(str_hex));

+        byte_array_to_hex_string(str_hex, recv_buf+f1StarAddr, actual_length);

+        HDBD_LOG("[%s %d]str_hex : %s\n", __FUNCTION__, __LINE__, str_hex);

+        while(f1StarAddr < (actual_length-16))

+        {

+            if( (recv_buf[f1StarAddr] == 0xF1) && (recv_buf[f1StarAddr+1] == 0xD9) )

+            {

+                goto READ_VER;

+            }

+

+            f1StarAddr ++;

+        }

+

+        read_count ++;

+        if(read_count >= 25)

+        {

+            return  -1;

+        }

+

+    }

+

+READ_VER:

+    if(f1StarAddr >= (actual_length-16))

+    {

+        HDBD_LOG("[%s %d] get ver fail\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+    memcpy(cur_sw_ver, recv_buf + f1StarAddr + 6, VERSION_MAX_LEN);

+    memcpy(cur_hw_ver, recv_buf + f1StarAddr + 6 + VERSION_MAX_LEN, VERSION_MAX_LEN);

+    HDBD_LOG("[%s %d]=====> sw_ver:%s\n", __FUNCTION__, __LINE__, cur_sw_ver);

+    HDBD_LOG("[%s %d]=====> hw_ver:%s\n", __FUNCTION__, __LINE__, cur_hw_ver);

+

+    if ( (strncmp((char *)(recv_buf + f1StarAddr + 6), "FB03BOOT", 8) != 0)

+         && (strncmp((char *)(recv_buf + f1StarAddr + 6), "FB02BOOT", 8) != 0) )

+    {

+        HDBD_LOG("[%s %d] user modebuf:%s\n", __FUNCTION__, __LINE__,recv_buf + f1StarAddr + 6);

+

+        if(strncmp((char *)(recv_buf + f1StarAddr + 6 + VERSION_MAX_LEN), "HD", 2) == 0)

+        {

+            HDBD_LOG("[%s %d] get user ver sucess\n", __FUNCTION__, __LINE__);

+        }

+        else

+        {

+            HDBD_LOG("[%s %d] get user ver fail\n", __FUNCTION__, __LINE__);

+            return -1;

+        }

+    }

+    else

+    {

+        HDBD_LOG("[%s %d]boot_mode:buf:%s\n", __FUNCTION__, __LINE__,recv_buf + f1StarAddr + 6);

+    }

+

+    /* COPY version to user, the length of recv_buf is more than 40 bytes */

+    if (ver_buf != NULL && (ver_len > 16))

+    {

+        memcpy(ver_buf, cur_sw_ver, 16);

+    }

+

+    return 0;

+}

+

+void uart_clear_buf(int32_t fd)

+{

+    tcflush(fd, TCIFLUSH);

+    return;

+}

+

+/**

+  * @brief  Boot mode firmware update

+  * @param  data: the pointer of the firmware data

+  * @param  len : the length of firmware data

+  * @retval None

+  */

+int fw_update_boot(int uart_fd, uint8_t *data, uint32_t len)

+{

+    int i = 1;

+    uint8_t dataAck[10];

+    uint8_t *data1st1k = data;

+    uint8_t recvBuf[READ_LENGTH] = {0};

+    uint8_t errorCount = 0;

+    int32_t ret = 0;

+    int j = 0;

+    if (NULL == data )

+    {

+        HDBD_LOG("[%s %d]firmware data error\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+

+    uart_clear_buf(uart_fd);

+    errorCount = 0;

+    while(1)

+    {

+        ret = get_mon_ver(uart_fd, (uint8_t *)recvBuf, READ_LENGTH - 1);

+        errorCount ++;

+        if (ret != 0)

+        {

+            HDBD_LOG("[%s %d]boot: Get version FAIL in baudrate 460800, return\n", __FUNCTION__, __LINE__);

+            if(errorCount >= 3)

+            {

+                HDBD_LOG("[%s %d] enter boot failed!\n", __FUNCTION__, __LINE__);

+                return -1;

+            }

+        }

+        else

+        {

+            break;

+        }

+    }

+    HDBD_LOG("[%s %d] buf:%s\n", __FUNCTION__, __LINE__,recvBuf);

+    i = 0;

+    while(i < 15)

+    {

+        if( (recvBuf[i] == 'F') && (recvBuf[i+1] == 'B') && (recvBuf[i+2] == '0') && (recvBuf[i+3] == '3'))

+        {

+            goto BOOT;

+        }

+        HDBD_LOG("[%s %d] enter boot failed!\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+

+BOOT:

+    ret = uart_send(uart_fd, (uint8_t *)cmdSETFRQ, sizeof(cmdSETFRQ));

+    usleep(50000);

+

+    uart_clear_buf(uart_fd);

+    memset(recvBuf, 0x00, sizeof(recvBuf));

+    i = 10;

+    ret = send_cmd_and_recv_result(uart_fd,cmdOpenWrtPro, recvBuf, sizeof(cmdOpenWrtPro), &i, 3);

+    HDBD_LOG("[%s %d]ret:%d,recvBuf(%d)(%02x,%x,%x,%x,%x,%x,%x,%x,%x,%x)\n", __FUNCTION__, __LINE__, ret, i,

+             recvBuf[0],recvBuf[1],recvBuf[2],recvBuf[3],recvBuf[4],recvBuf[5],

+            recvBuf[6],recvBuf[7],recvBuf[8],recvBuf[9]);

+    if( (recvBuf[8] != 0x04) || (recvBuf[9] != 0x1b))

+    {

+        HDBD_LOG("[%s %d] upgrade write:open flash write protect failed!\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+

+

+    i = 10;

+    ret = send_cmd_and_recv_result(uart_fd, cmdOpenQe_and_wrtPro, recvBuf, sizeof(cmdOpenQe_and_wrtPro), &i, 3);

+    HDBD_LOG("[%s %d]ret:%d,cmdOpenQe_and_wrtPro(%d)(%02x,%x,%x,%x,%x,%x,%x,%x,%x,%x)\n", __FUNCTION__, __LINE__, ret, i,

+             recvBuf[0],recvBuf[1],recvBuf[2],recvBuf[3],recvBuf[4],recvBuf[5],

+            recvBuf[6],recvBuf[7],recvBuf[8],recvBuf[9]);

+    if((recvBuf[2] == 0x05) && (recvBuf[3] == 0x00))

+    {

+

+        i = 10;

+        ret = send_cmd_and_recv_result(uart_fd, cmd_RadFlash, recvBuf, sizeof(cmd_RadFlash), &i, 3);

+        HDBD_LOG("[%s %d]ret:%d,cmd_RadFlash(%d)(%02x,%x,%x,%x,%x,%x,%x,%x,%x,%x)\n", __FUNCTION__, __LINE__, ret, i,

+                 recvBuf[0],recvBuf[1],recvBuf[2],recvBuf[3],recvBuf[4],recvBuf[5],

+                recvBuf[6],recvBuf[7],recvBuf[8],recvBuf[9]);

+        if((recvBuf[2] != 0xF4) || (recvBuf[3] != 0x07))

+        {

+            HDBD_LOG("[%s %d] cmd_RadFlash error!\n", __FUNCTION__, __LINE__);

+            return -1;

+        }

+

+        i = 10;

+        ret = send_cmd_and_recv_result(uart_fd, cmdOpenQe_and_wrtPro, recvBuf, sizeof(cmdOpenQe_and_wrtPro), &i, 3);

+        HDBD_LOG("[%s %d]ret:%d,cmdOpenQe_and_wrtPro(%d)(%02x,%x,%x,%x,%x,%x,%x,%x,%x,%x)\n", __FUNCTION__, __LINE__, ret, i,

+                 recvBuf[0],recvBuf[1],recvBuf[2],recvBuf[3],recvBuf[4],recvBuf[5],

+                recvBuf[6],recvBuf[7],recvBuf[8],recvBuf[9]);

+        j = 0;

+        while(j < i)

+        {

+            if((recvBuf[j] == 0xF1) && (recvBuf[j+1] == 0xD9))

+            {

+                if((recvBuf[j+2] != 0x05) || (recvBuf[j+3] != 0x01))

+                {

+                    HDBD_LOG("[%s %d] cmdOpenQe_and_wrtPro error!\n", __FUNCTION__, __LINE__);

+                    return -1;

+                }

+            }

+

+            j++;

+

+            if(j > 20)

+            {

+                break;

+            }

+        }

+    }

+

+    

+    ret = send_cmd_and_recv_result(uart_fd,cmdBOOTERASE_900, recvBuf, sizeof(cmdBOOTERASE_900), &i, 3);

+    HDBD_LOG("[%s %d]ret:%d,cmdOpenQe_and_wrtPro(%d)(%02x,%x,%x,%x,%x,%x,%x,%x,%x,%x)\n", __FUNCTION__, __LINE__, ret, i,

+             recvBuf[0],recvBuf[1],recvBuf[2],recvBuf[3],recvBuf[4],recvBuf[5],

+            recvBuf[6],recvBuf[7],recvBuf[8],recvBuf[9]);

+    if( (recvBuf[0] == 0xF1) && (recvBuf[1] == 0xD9) && (recvBuf[2] == 0x05) && (recvBuf[3] != 0x01) )

+    {

+        HDBD_LOG("[%s %d] cmdBOOTERASE error!\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+

+    clearBuffer();

+

+    data += 1024;

+    len -= 1024;

+    for(i = 1 ;len > 1024; ++i, data += 1024, len -= 1024)

+    {

+        ret = sendfwboot(uart_fd, 0x90000000 + i * 0x400, i, data, 1024, recvBuf);

+        if (ret != 0)

+        {

+            HDBD_LOG("[%s %d] upgrade error,return!\n", __FUNCTION__, __LINE__);

+            return -1;

+        }

+    }

+

+    ret = sendfwboot(uart_fd, 0x90000000 + i * 0x400, i, data, len, recvBuf);

+    if (ret != 0)

+    {

+        HDBD_LOG("[%s %d] upgrade error,return!\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+    i++;

+

+    ret = sendfwboot(uart_fd, 0x90000000, i, data1st1k, 1024, recvBuf);

+    if (ret != 0)

+    {

+        HDBD_LOG("[%s %d] upgrade error,return!\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+    HDBD_LOG("[%s %d] upgrade success!\n", __FUNCTION__, __LINE__);

+    return 0;

+}

+

+

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/hd8040_upgrade.h b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/hd8040_upgrade.h
new file mode 100755
index 0000000..bd4cc6b
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/hd8040_upgrade.h
@@ -0,0 +1,93 @@
+#ifndef  __HD8040_UPGRADE_H

+#define  __HD8040_UPGRADE_H

+

+#include <stdio.h>

+#include <stdlib.h>

+#include <string.h>

+#include "stdint.h"

+

+//cfg

+#define SWITCH_BAUD_460800 1

+#define UPG_CHECK_VER 1

+

+typedef int  sys_err_t;

+

+#define sys_TRUE       (1)

+#define sys_FALSE      (0)  

+

+#define sys_SUCCESS   (0)

+#define sys_FAILED    (-1)

+

+

+typedef unsigned char  uint8_t;

+typedef unsigned short int uint16_t;

+

+#define HDBD_LOG printf

+

+

+typedef enum {

+    HDBD_UPG_SUCESS = 0,

+    HDBD_UPG_ENTER_BOOTMODE_ERROR  = 1,

+    HDBD_UPG_FAIL  = 2,

+}HDBD_RET;

+

+#define COMM_BAUDRATE_PHONE 115200

+

+

+#define ADDR_FLASH_BIN_INFO_ADDR 0x0000000//

+

+/**

+ * @brief  upgrade entry

+ * @param  fd:uart fd

+ * @param  uart_baud_max:uart max baud

+ * @param  binSize:upgrade file bin size

+ * @param  upgrade_clientID:need upgrade clientID

+ * @param  new_ver:upgrade success version

+ * @retval hd8040_upgrade.h  ERROR_LIST

+ */

+

+//#define PYTHON_CALL_BACK_SUPPORT 0

+

+#ifdef PYTHON_CALL_BACK_SUPPORT

+typedef struct python_callback_str

+{

+    int (*gnss_gpio_init_callback)();

+    int (*gnss_enter_boot_callback)();

+    int (*gnss_reset_callback)();

+    int (*set_gnss_baud_callback)(int32_t, uint8_t);

+    int (*uart_send_callback)(int32_t, uint8_t *, int32_t);

+    int (*uart_recv_callback)(int32_t, uint8_t *, int32_t *, int32_t);

+    int (*bsp_flash_readbytes_callback)(uint32_t, uint8_t *, uint32_t);

+    int (*uart_clear_buf_callback)(int32_t);

+    int (*uart_control_callback)(int32_t, uint16_t);

+}PYTHON_CALLBACK;

+

+typedef int (callback)(uint8_t *, uint16_t);

+typedef int (*gnss_gpio_init_callback_)();

+typedef int (*gnss_enter_boot_callback_)();

+typedef int (*gnss_reset_callback_)();

+typedef int (*set_gnss_baud_callback_)(int32_t, uint8_t);

+typedef int (*uart_send_callback_)(int32_t, uint8_t *, int32_t);

+typedef int (*uart_recv_callback_)(int32_t, uint8_t *, int32_t *, int32_t);

+typedef int (*bsp_flash_readbytes_callback_)(uint32_t, uint8_t *, uint32_t);

+typedef int (*uart_clear_buf_callback_)(int32_t);

+typedef int (*uart_control_callback_)(int32_t, uint16_t);

+

+extern PYTHON_CALLBACK g_python_callback;

+extern HDBD_RET hdbd_upgrade_entry(int32_t fd, int32_t uart_baud_max, int32_t binSize, uint8_t *upgrade_clientID, uint8_t *new_ver, 

+                                   gnss_gpio_init_callback_ gnss_gpio_init_callback__,

+                                   gnss_enter_boot_callback_ gnss_enter_boot_callback__,

+                                   gnss_reset_callback_ gnss_reset_callback__,

+                                   set_gnss_baud_callback_ set_gnss_baud_callback__,

+                                   uart_send_callback_ uart_send_callback__,

+                                   uart_recv_callback_ uart_recv_callback__,

+                                   bsp_flash_readbytes_callback_ bsp_flash_readbytes_callback__,

+                                   uart_clear_buf_callback_ uart_clear_buf_callback__,

+                                   uart_control_callback_ uart_control_callback__

+                                   );

+#else

+extern HDBD_RET hdbd_upgrade_entry(int32_t fd, int32_t uart_baud_max, int32_t binSize, uint8_t *upgrade_clientID, uint8_t *new_ver);

+#endif

+extern HDBD_RET hdbd_enter_boot(int32_t fd, int32_t uart_baud_max, int binSize, uint8_t *upgrade_clientID, uint8_t *new_ver);

+#endif

+

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/lynq-gnss-update.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/lynq-gnss-update.cpp
deleted file mode 100755
index 29abd03..0000000
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/lynq-gnss-update.cpp
+++ /dev/null
@@ -1,1337 +0,0 @@
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <time.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/times.h>
-#include <sys/types.h>
-#include <termios.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/wait.h>
-#include <ctype.h>
-#include <sched.h>
-#include <limits.h>
-#include <linux/serial.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#define RTM_FILE_NAME "rtm.bin"
-
-#define PARA_ERR                -1
-#define FILE_CHECK_ERR          -2
-#define ENTER_UPDATE_MODE_ERR   -3
-#define UPDATE_ERR              -4
-#define UART_DEV_ERR            -5
-
-#define XMODEM_SOH 0x01
-#define XMODEM_STX 0x02
-#define XMODEM_EOT 0x04
-#define XMODEM_ACK 0x06
-#define XMODEM_NAK 0x15
-#define XMODEM_CAN 0x18
-#define XMODEM_CRC_CHR	'C'
-#define XMODEM_CRC_SIZE 2		/* Crc_High Byte + Crc_Low Byte */
-#define XMODEM_FRAME_ID_SIZE 2 		/* Frame_Id + 255-Frame_Id */
-#define XMODEM_DATA_SIZE_SOH 128  	/* for Xmodem protocol */
-#define XMODEM_DATA_SIZE_STX 1024 	/* for 1K xmodem protocol */
-#define USE_1K_XMODEM 1  		/* 1 for use 1k_xmodem 0 for xmodem */
-#define	TIMEOUT_USEC	0
-#define	TIMEOUT_SEC		10
-
-#if (USE_1K_XMODEM)
-#define XMODEM_DATA_SIZE 	XMODEM_DATA_SIZE_STX
-#define XMODEM_HEAD		XMODEM_STX
-#else
-#define XMODEM_DATA_SIZE 	XMODEM_DATA_SIZE_SOH
-#define XMODEM_HEAD 		XMODEM_SOH
-#endif
-
-
-/******************************************************************************
- * 时间处理相关的宏
- *****************************************************************************/
-// 时间超时标志
-int timeout_sign = 1;
-// 获取当前时间
-#define GET_TIME()  { gettimeofday(&time_m, NULL); \
-    time_m.tv_sec += TIMEOUT_SEC;\
-}
-// 设置从循环中退出的时间
-#define SET_TIME_OUT(x)  { gettimeofday(&time_m, NULL); \
-    time_m.tv_sec += x;\
-}
-// 检测时间是否超时,超时则退出当前函数
-#define CHK_TIME()  { gettimeofday(&time_n, NULL); \
-    if(time_n.tv_sec > time_m.tv_sec) { \
-    printf("\ntimeout!!!\n\n");\
-    close(fd); \
-    return ret; \
-} \
-}
-// 检测时间是否超时,超时则退出当前循环
-#define CHK_TIME_BREAK()  { gettimeofday(&time_n, NULL); \
-    if(time_n.tv_sec > time_m.tv_sec) { \
-    timeout_sign = 1; 	\
-    printf("\ntimeout!!!\n\n");\
-    break; \
-} \
-}
-// 检测延时是否到达,到达则退出当前循环
-#define DELAY_TIME_BREAK()  { gettimeofday(&time_n, NULL); \
-    if(time_n.tv_sec > time_m.tv_sec) { \
-    timeout_sign = 1; 	\
-    break; \
-} \
-}
-
-// 检测时间是否超时,超时则退出当前函数
-#define CHK_TIME1()  { gettimeofday(&time_n, NULL); \
-    if(time_n.tv_sec > time_m.tv_sec) { \
-    printf("\ntimeout!!!\n\n");\
-    if(datafile != NULL) \
-    fclose(datafile); \
-    return ret; \
-} \
-}
-
-
-/******************************************************************************
- * APData 相关定义、声明
- *****************************************************************************/
-// APData 数据头部定义
-typedef struct {
-    unsigned int  ih_magic;		// Image Header Magic Number
-    unsigned int  ih_dcrc;		// Image Data CRC checksum
-    unsigned int  ih_time;		// Image Creation Timestamp
-    unsigned int  ih_size;		// Image Data Size
-    unsigned int  ih_compress;		// Image Header compress or not:0, not compress
-    unsigned int  pkg_flash_addr;	// flash memory offset for package
-    unsigned int  pkg_run_addr;		// Run time address for this package
-    unsigned int  ih_hcrc;		// Image Header CRC checksum
-} uc_image_header_t;
-
-// APData 数据头部长度
-#define HEADERLEN 32
-// APData 接收状态类型
-typedef enum ReceStat{
-    WAIT_FD = 1,
-    WAIT_FC,
-    WAIT_FB,
-    WAIT_FA,
-    RECE_HEADER,
-    RECE_DATA,
-} RecvStat_t;
-// APData 接收状态变量
-static RecvStat_t recvStat = WAIT_FD;
-// APData 接收状态变量
-static int isStartReceive = 0;
-// APData 开始接收
-void af_start_receive();
-// APData 停止接收,在数据接收完成或出错时调用
-void af_stop_receive();
-// 获取isStartReceive 变量值
-int af_is_start_receive();
-// APData 数据接收入口
-int af_add_char(char *file, unsigned char c);
-// 校验 APData 数据头
-int af_check_header(unsigned char *pbuf, unsigned int len);
-// 校验 APData 数据区
-int af_check_data(unsigned int * pbuf, unsigned int len);
-// 获取 APData 数据长度
-int af_get_data_len();
-// APData 数据接收缓存
-
-int check_file(char *fname);
-
-/******************************************************************************
- * 与接收机串口通讯相关定义、声明
- *****************************************************************************/
-// select功能使用变量
-static int use_select = 1;
-// 初始化串口资源
-int initial_serialPort(char * serial_device);
-// 设置串口波特率
-static int set_baudrate(int fd, int baudrate);
-// 检测串口数据
-static int select_read(int fd, int timeout);
-// 读取串口数据
-static ssize_t deal_read(int fd, void *buf, size_t count);
-// 向接收机发送串口数据
-static void gps_dev_send(int fd, char *msg);
-// 通过xmodem协议向接收机发送串口数据
-int xmodem_send(int fd, char *fname);
-
-/******************************************************************************
- * apflash 功能函数
- *****************************************************************************/
-// 检测接收机发送的'YC'信号,如果收到,则标志着接收机进入boot模式,并可以通过xmodem发送数据
-int check_YC(char newchar);
-// 获取 APData 数据, 应该在接收机定位且星历数据接收完整时获取
-int getAPData(int fd, char *file);
-// 向接收机发送 APData 数据,有效的APData数据可以让CI模块迅速定位
-int sendAPData(int fd, char *ap);
-// 校验 APData 数据文件
-int checkAPData(char *apFile);
-// 为接收机加载BootLoader,该流程执行时,需要根据终端提示,给接收机下电和上电,确保接收机进入boot模式
-int downloadBL(int fd, char *bl);
-// 为接收机加载Firmware,该流程必须在加载BootLoader之后进行
-int downloadFW(int fd, char *fw);
-unsigned int recv_buf[1024 * 2];
-unsigned char *pbuf;
-int data_len;
-volatile int nmea_state = 0;
-volatile int nmea_reading = 0;
-// 校验文件
-void printGetapUsage(char *app)
-{
-    printf("\n%s getap -d receiverPort [-b baudrate] [-h] -a apfile \n", app);
-    printf("\tfunction: read APData from receiver\n");
-    printf("\tparas:\n");
-    printf("\t\treceiverPort: Port that connected to receiver\n");
-    printf("\t\tbaudrate: baudrate of receiverPort\n");
-}
-
-void printSendapUsage(char *app)
-{
-    printf("\n%s sendap -d receiverPort [-b baudrate] [-h] -a apfile\n", app);
-    printf("\tfunction: send APData to receiver\n");
-    printf("\tparas:\n");
-    printf("\t\treceiverPort: Port that connected to receiver\n");
-    printf("\t\tbaudrate: baudrate of receiverPort\n");
-}
-
-void printCheckapUsage(char *app)
-{
-    printf("\n%s checkap -a apfile [-h]\n", app);
-    printf("\tfunction: check APData\n");
-    printf("\tparas:\n");
-    printf("\t\tapfile: APData file\n");
-}
-
-void printDownloadblUsage(char *app)
-{
-    printf("\n%s downbl -d receiverPort [-b baudrate] -l bootloader [-h]\n", app);
-    printf("\tfunction: download bootloader to receiver\n");
-    printf("\tparas:\n");
-    printf("\t\treceiverPort: Port that connected to receiver\n");
-    printf("\t\tbaudrate: baudrate of receiverPort\n");
-    printf("\t\tbootloader: bootloader file\n");
-}
-
-void printDownloadfwUsage(char *app)
-{
-    printf("\n%s downfw -d receiverPort [-b baudrate] -f firmware [-h]\n", app);
-    printf("\tfunction: download firmware to receiver\n");
-    printf("\tparas:\n");
-    printf("\t\treceiverPort: Port that connected to receiver\n");
-    printf("\t\tbaudrate: baudrate of receiverPort\n");
-    printf("\t\tfirmware: firmware file\n");
-}
-
-void printUsage(char *app)
-{
-    printGetapUsage(app);
-    printSendapUsage(app);
-    printCheckapUsage(app);
-    printDownloadblUsage(app);
-    printDownloadfwUsage(app);
-}
-
-int exec_cmd(const char *cmd, char *result)
-{
-    FILE *pipe = popen(cmd, "r");
-    if(!pipe)
-        return -1;
-
-    char buffer[256] = {0};
-    while(!feof(pipe))
-    {
-        if(fgets(buffer, 256, pipe))
-        {
-            memset(buffer, 0, sizeof(buffer));
-        }
-    }
-    pclose(pipe);
-    return 0;
-}
-
-int mopen_open_gps(int state)
-{
-    char cmd[128] = "echo '86' > /sys/class/gpio/export && cd /sys/class/gpio/gpio86";
-    int ret;
-
-    if(0 == state)
-    {
-        nmea_state = 0;
-        for(int cont = 0; cont < 200; cont++)
-        {
-            if (nmea_reading == 0)
-            {
-                break;
-            }
-            usleep(10000);
-        }
-        ret = exec_cmd(cmd,NULL);
-        if(0 != ret)
-        {
-            printf("stop fail %x\n", ret);
-        }
-        char cmd2[128] = "echo '0' > /sys/class/gpio/gpio86/value && echo '86' > /sys/class/gpio/unexport";
-        ret = exec_cmd(cmd2,NULL);
-        if(0 != ret)
-        {
-            printf("stop fail %x\n", ret);
-        }
-    }
-
-    if(1 == state)
-    {
-        nmea_state = 1;
-
-        ret = exec_cmd(cmd,NULL);
-        if(0 != ret)
-        {
-            printf("start fail %x\n", ret);
-            return -1;
-        }
-        char cmd3[128] = "echo '1' > /sys/class/gpio/gpio86/value && echo '86' > /sys/class/gpio/unexport";
-        ret = exec_cmd(cmd3,NULL);
-        if(0 != ret)
-        {
-            printf("start fail %x\n", ret);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int main(int argc, char *argv[])
-{
-    int c;
-    int ret = 0;
-    int fd = -1;
-    int paraMask = 0;
-    int baud = 115200;
-    char devPort[200] = {0};
-    char fw[200] = {0};
-    char bl[200] = {0};
-    char ap[200] = {0};
-    int func = 0; // 1:getap, 2:sendap, 3:downbl, 4:downfw, 5:checkap
-
-    // Verify arguments
-    if (argc < 2) {
-        printf("Usage:\n");
-        printUsage(argv[0]);
-        exit(1);
-    }
-
-    if(strcmp(argv[1], "getap") == 0) {
-        func = 1;
-        paraMask = 1;
-    } else if (strcmp(argv[1], "sendap") == 0) {
-        func = 2;
-        paraMask = 1;
-    } else if (strcmp(argv[1], "downbl") == 0) {
-        func = 3;
-        paraMask = 9;
-    } else if (strcmp(argv[1], "downfw") == 0) {
-        func = 4;
-        paraMask = 5;
-    } else if (strcmp(argv[1], "checkap") == 0) {
-        func = 5;
-        paraMask = 16;
-    } else {
-        printf("Usage:\n");
-        printUsage(argv[0]);
-        exit(1);
-    }
-
-    for(;;) {
-        opterr = 0;
-        c = getopt(argc, argv, "d:b:f:l:a:h");
-        if(c < 0)
-            break;
-        switch(c) {
-        case 'd':
-            snprintf(devPort, 200, "%s", optarg);
-            printf("receiver port: %s\n", devPort);
-            paraMask &= ~1;
-            break;
-        case 'b':
-            baud = atoi(optarg);
-            printf("baud rate: %d\n", baud);
-            break;
-        case 'f':
-            snprintf(fw, 200, "%s", optarg);
-            printf("firmware: %s\n", fw);
-            paraMask &= ~4;
-            break;
-        case 'l':
-            snprintf(bl, 200, "%s", optarg);
-            printf("bootloader: %s\n", bl);
-            paraMask &= ~8;
-            break;
-        case 'a':
-            snprintf(ap, 200, "%s", optarg);
-            printf("apdata file: %s\n", ap);
-            paraMask &= ~16;
-            break;
-        case 'h':
-        default:
-            printf("Usage:\n");
-            if (func == 1)
-                printGetapUsage(argv[0]);
-            else if (func == 2)
-                printSendapUsage(argv[0]);
-            else if (func == 3)
-                printDownloadblUsage(argv[0]);
-            else if (func == 4)
-                printDownloadfwUsage(argv[0]);
-            else if (func == 5)
-                printCheckapUsage(argv[0]);
-            else
-                printUsage(argv[0]);
-            exit(1);
-        }
-    }
-    if (paraMask) {
-        if (func == 1)
-            printGetapUsage(argv[0]);
-        else if (func == 2)
-            printSendapUsage(argv[0]);
-        else if (func == 3)
-            printDownloadblUsage(argv[0]);
-        else if (func == 4)
-            printDownloadfwUsage(argv[0]);
-        else if (func == 5)
-            printCheckapUsage(argv[0]);
-        else
-            printUsage(argv[0]);
-        exit(1);
-    }
-
-    // Open serial port
-    if (func != 5) {
-        if ((fd = initial_serialPort(devPort)) == -1)
-        {
-            printf("Can't open COM\n");
-            return UART_DEV_ERR;
-        }
-        if (baud == 115200) {
-            set_baudrate(fd, B115200);
-        } else if (baud == 230400) {
-            set_baudrate(fd, B230400);
-        } else if (baud == 921600) {
-            set_baudrate(fd, B921600);
-        } else if (baud == 1843200) {
-            set_baudrate(fd, B1500000);
-        } else {
-            printf("baudrate %d not supported\n", baud);
-            close(fd);
-            exit(1);
-        }
-    }
-
-    // execute function
-    switch(func) {
-    case 1:
-        ret = getAPData(fd, ap);
-        break;
-    case 2:
-        ret = sendAPData(fd, ap);
-        break;
-    case 3:
-        ret = downloadBL(fd, bl);
-        break;
-    case 4:
-        ret = downloadFW(fd, fw);
-        break;
-    case 5:
-        ret = checkAPData(ap);
-        break;
-    default:break;
-    }
-    close(fd);
-    return ret;
-
-}
-
-int getAPData(int fd, char *file)
-{
-    int rByte = 0;
-    char rbuf[4096];
-    int ret = 0, i;
-    struct timeval time_m, time_n;
-
-    if (NULL == file) {
-        printf("Please input file!! \n");
-        return 1;
-    }
-    if (!fd)
-        return 1;
-    printf("Get apdata\n");
-    gps_dev_send(fd, "$ReqRecvFlash\r\n");
-    af_start_receive();
-    GET_TIME();
-    while(1) {
-        CHK_TIME();
-        if(select_read(fd,1) > 0)
-            usleep(50000);
-        else
-            continue;
-
-        rByte = deal_read(fd,&rbuf,sizeof(rbuf));
-        if(rByte >= 1){
-            if(af_is_start_receive()) {
-                for(i = 0; i < rByte; i++)
-                    af_add_char(file, rbuf[i]);
-            } else {
-                break;
-            }
-        }
-    }
-
-    checkAPData(file);
-    return 0;
-}
-
-int sendAPData(int fd, char *apFile)
-{
-    int rByte = 0;
-    char rbuf[4096];
-    int ret = 0;
-    struct timeval time_m, time_n;
-
-    if(access(apFile, F_OK) != -1)
-    {
-        // Download APData only if the file exits
-        printf("Download APData...\n");
-        if(xmodem_send(fd, apFile))
-        {
-            printf("xmodem error!\n");
-            close(fd);
-            return ENTER_UPDATE_MODE_ERR;
-        }
-        // Waiting for 'C'
-        GET_TIME();
-        while(1)
-        {
-            CHK_TIME();
-            if(select_read(fd,1) > 0)
-                usleep(500000);
-            else
-                continue;
-            rByte = deal_read(fd,&rbuf,sizeof(rbuf)-1);
-            rbuf[rByte] = 0;
-            if(rByte > 0)
-            {
-                if(rbuf[rByte - 1] == 'C')
-                    break;
-            }
-        }
-        printf("download APData success\n");
-    }
-    else
-    {
-        printf("file err!\n");
-        return 1;
-    }
-
-    return 0;
-}
-
-int checkAPData(char *apFile)
-{
-    printf("Checking %s\n", apFile);
-    if(check_file(apFile))
-    {
-        printf("file error!\n");
-        return FILE_CHECK_ERR;
-
-    }
-    else
-    {
-        printf("pass\r\n");
-    }
-    return 0;
-}
-
-int downloadFW(int fd, char *fw)
-{
-    int ret;
-    struct timeval time_m, time_n;
-    char rbuf[512];
-
-    if(NULL == fw) {
-        printf("Error: Can't find firmware.\n");
-        return -1;
-    }
-    printf("Download firmware...\n");
-    if(xmodem_send(fd, fw) < 0) {
-        printf("xmodem error! send firmware failed!\n");
-        close(fd);
-        return UPDATE_ERR;
-    }
-    set_baudrate(fd, B115200);
-    printf("Download firmware success\n");
-    return 0;
-}
-
-int downloadBL(int fd, char *bl)
-{
-    int rByte = 0;
-    char rbuf[4096];
-    char name[128];
-    int ret = 0;
-    struct timeval time_m, time_n;
-
-    if(NULL == bl) {
-        printf("Error: Can't find bootloader.\n");
-        return -1;
-    }
-    printf("------Please Powerdown the receiver!\n");
-    mopen_open_gps(0);
-    SET_TIME_OUT(3);
-    while(1) {
-        DELAY_TIME_BREAK(); //
-        if(select_read(fd,1) > 0)
-            usleep(50000);
-        else
-            continue;
-
-        rByte = deal_read(fd,&rbuf,sizeof(rbuf));
-    }
-    int start = 0,finish = 0;
-
-    memset(name, 0, sizeof(name));
-    sprintf(name,"M!T");
-    printf("waiting for YC, timeout is %d s\n", TIMEOUT_SEC);
-    printf("-------Please Powerup the receiver!\n");
-    mopen_open_gps(1);
-    // Waiting for 'YC'
-    GET_TIME();
-    while(1) {
-        int finish = 0, i;
-        CHK_TIME_BREAK(); //
-        rByte = write(fd, name, strlen(name));
-        rByte = select_read(fd,1);
-        if(rByte <= 0)
-            continue;
-        rByte = deal_read(fd, rbuf, sizeof(rbuf) - 1);
-        rbuf[rByte] = 0;
-        for (i = 0 ; i < rByte; i++)
-        {
-            if (check_YC(rbuf[i])) {
-                printf("Receive 'YC'\n");
-                finish = 1;
-                break;
-            }
-        }
-        if (finish)
-            break;
-    }
-    //wait 'YC' timeout deal
-    if (timeout_sign == 1)
-    {
-        //wait NAK
-        GET_TIME();
-        printf("2222\n");
-        while(1)
-        {
-            CHK_TIME();
-            if(select_read(fd,1) <= 0)
-                continue;
-
-            rByte = deal_read(fd, rbuf,sizeof(rbuf));
-            if (rbuf[rByte-1] == 'C')
-            {
-                printf("###read xmodem start character 'C'.\n");
-                break;
-            }
-        }
-    }
-    //use_select = 1;
-    printf("download bootloader...\n");
-
-    // Transfer bootloader via xmodem protocal
-    // if(xmodem_send(fd, "./bootloader.bin")) {
-    if(xmodem_send(fd, bl)) {
-        printf("xmodem error!\n");
-        close(fd);
-        return ENTER_UPDATE_MODE_ERR;
-    }
-    printf("download bootloader success\n");
-    return 0;
-}
-
-int check_YC(char newchar)
-{
-    int static state = 0;
-    int ret = 0;
-    switch (state) {
-    case 0:
-        if (newchar == 'Y')
-            state = 1;
-        break;
-    case 1:
-        if (newchar == 'C') {
-            state = 1;
-            ret = 1;
-        }
-        break;
-    default:
-        state = 0;
-    }
-    return ret;
-}
-
-const unsigned short CRC16_Table[256] = {
-    0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
-    0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
-    0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
-    0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
-    0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
-    0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
-    0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
-    0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
-    0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
-    0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
-    0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
-    0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
-    0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
-    0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
-    0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
-    0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
-    0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
-    0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
-    0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
-    0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
-    0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
-    0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
-    0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
-    0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
-    0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
-    0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
-    0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
-    0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
-    0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
-    0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
-    0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
-    0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
-};
-
-unsigned short crc16_ccitt(const unsigned char *buf, int len)
-{
-    register int counter;
-    register unsigned short crc = 0;
-    for (counter = 0; counter < len; counter++)
-        crc = (crc << 8) ^ CRC16_Table[((crc >> 8) ^ *(char *)buf++) & 0x00FF];
-    return crc;
-}
-
-
-unsigned int checksum32(unsigned int * pbuf, unsigned int len)
-{
-    unsigned int i, sumValue = 0;
-    len >>=2;
-
-    for(i=0;i<len;i++)
-    {
-        sumValue += *pbuf++;
-    }
-    return sumValue;
-}
-
-void af_start_receive()
-{
-    recvStat = WAIT_FD;
-    isStartReceive = 1;
-    return;
-}
-
-void af_stop_receive()
-{
-    int i;
-    printf("%s:%d\r\n", __FUNCTION__, __LINE__);
-    printf("%s:%d  recvStat = %d\r\n", __FUNCTION__, __LINE__, recvStat);
-    pbuf = (unsigned char *)recv_buf;
-    for(i = 0; i < 4636; i++){
-        if(i % 32 == 0)printf("\r\n");
-        printf("%02X ", pbuf[i]);
-    }
-    printf("\r\n");
-    isStartReceive = 0;
-    return;
-}
-
-int af_is_start_receive()
-{
-    return isStartReceive;
-}
-
-int af_check_header(unsigned char *pbuf, unsigned int len)
-{
-    unsigned int crc = crc16_ccitt(pbuf, len-4);
-
-    if(crc == *(unsigned int *)(pbuf + len - 4))
-        return 1;
-    else
-        return 0;
-}
-
-int af_check_data(unsigned int * pbuf, unsigned int len)
-{
-    unsigned int cs = checksum32(pbuf + 8, len);
-    if(cs == pbuf[1])
-        return 1;
-    else
-        return 0;
-}
-
-int af_get_data_len()
-{
-    int len = *(int *)(recv_buf+3);
-    return len;
-}
-
-int af_add_char(char *file, unsigned char c)
-{
-    int ret = 0;
-    switch(recvStat){
-    case WAIT_FD:
-        if(c == 0xfd){
-            pbuf = (unsigned char *)recv_buf;
-            pbuf[0] = c;
-            recvStat = WAIT_FC;
-            printf("------------received 0xfd\r\n");
-        }
-        break;
-    case WAIT_FC:
-        if(c == 0xfc){
-            pbuf[1] = c;
-            recvStat = WAIT_FB;
-            printf("------------received 0xfc\r\n");
-        }else{
-            af_stop_receive();
-        }
-        break;
-    case WAIT_FB:
-        if(c == 0xfb){
-            pbuf[2] = c;
-            recvStat = WAIT_FA;
-            printf("------------received 0xfb\r\n");
-        }else{
-            af_stop_receive();
-        }
-        break;
-    case WAIT_FA:
-        if(c == 0xfa){
-            pbuf[3] = c;
-            recvStat = RECE_HEADER;
-            pbuf += 4;
-            printf("------------received 0xfa\r\n");
-        }else{
-            af_stop_receive();
-        }
-        break;
-    case RECE_HEADER:
-        *pbuf = c;
-        pbuf++;
-        if((pbuf - (unsigned char *)recv_buf) == HEADERLEN){
-            if(af_check_header((unsigned char *)recv_buf, HEADERLEN)){
-                recvStat = RECE_DATA;
-                data_len = af_get_data_len();
-            }else{
-                af_stop_receive();
-            }
-        }
-        break;
-    case RECE_DATA:
-        *pbuf = c;
-        pbuf++;
-        if((pbuf - (unsigned char *)recv_buf) == data_len + HEADERLEN){
-            if(af_check_data(recv_buf, recv_buf[3])){
-                int fd = open(file, O_WRONLY|O_CREAT, S_IRWXU);
-                write(fd, recv_buf, pbuf - (unsigned char *)recv_buf);
-                printf("%s:%d rtm len = %ld\r\n", __FUNCTION__, __LINE__, pbuf-(unsigned char *)recv_buf);
-                close(fd);
-                printf("receive rtm\n");
-            }else{
-                printf("af_check_data false!");
-            }
-            af_stop_receive();
-        }
-        ret = 1;
-        break;
-    default:
-        printf("%s:recvStat = %d\r\n", __FUNCTION__, recvStat);
-        break;
-    }
-    return ret;
-}
-
-
-
-ssize_t deal_read(int fd, void *buf, size_t count)
-{
-    int ret = 0;
-
-    while (1)
-    {
-        ret = read(fd, buf, count);
-        if (ret == 0)
-        {
-            printf("read serial return 0, please check serial device.\n");
-            exit(UART_DEV_ERR);
-        }
-        if(ret < 0)
-        {
-            if ((errno == EAGAIN) || (errno == EINTR))
-            {
-                printf("read serial return -1, errno = %d, retry.\n", errno);
-                continue;
-            }
-            else
-            {
-                printf("read serial return -1, errno = %d, please check serial device.\n", errno);
-                exit(UART_DEV_ERR);
-            }
-        }
-        return ret;
-    }
-}
-
-unsigned short get_crc16 ( char *ptr, unsigned short count )
-{
-    unsigned short crc, i;
-
-    crc = 0;
-    while(count--)
-    {
-        crc = crc ^ (int) *ptr++ << 8;
-
-        for(i = 0; i < 8; i++)
-        {
-            if(crc & 0x8000)
-                crc = crc << 1 ^ 0x1021;
-            else
-                crc = crc << 1;
-        }
-    }
-
-    return (crc & 0xFFFF);
-}
-
-void dump_u(void *buf, int len)
-{
-    unsigned char *p = (unsigned char *)buf;
-    int i;
-
-    for(i = 0; i < len; i++) {
-        if(i % 16 == 0) printf("%04x:", i);
-        if(i % 16 == 8) printf(" -");
-        printf(" %02x", p[i]);
-        if(i % 16 == 15) printf("\n");
-    }
-    if(i % 16) printf("\n");
-}
-
-unsigned int get_file_size(const char * name)
-{
-    struct stat statbuff;
-    //unsigned int size, checksum;
-    if(stat(name, &statbuff) < 0)
-        return -1;
-    else
-        return statbuff.st_size;
-}
-
-
-int check_file(char * fname)
-{
-    FILE *fd;
-    uc_image_header_t header;
-    unsigned int buf[1024];
-    unsigned int fsize, checksum, i;
-    unsigned int len;
-    unsigned short crc;
-    size_t rByte;
-
-    if((fd=fopen(fname,"rb"))==NULL)
-    {
-        printf("\n can't open (%s) or not exist!(errno=%d:%s) \n", fname, errno, strerror(errno));
-        return -1;
-    }
-
-    fsize = get_file_size(fname);
-
-    printf("file size [%d]\n",fsize);
-
-    if(fsize == 0)
-        return -1;
-
-    while(fsize > sizeof(header)) {
-        rByte = fread((char *)&header, sizeof(char), sizeof(header), fd);
-
-        dump_u((char *)&header, sizeof(header));
-
-        crc = get_crc16 ( (char *) &header, sizeof(header)-4);
-        printf("crc16  [%08x]\n", crc);
-
-        if((header.ih_hcrc & 0xFFFF) != crc) {
-            fclose(fd);
-            return -1;
-        }
-
-        fsize -= sizeof(header);
-        fsize -= header.ih_size;
-        checksum = 0;
-        len = header.ih_size;
-        while(len > 0)
-        {
-            if(len >= 1024 )
-                rByte = 1024;
-            else
-                rByte = len;
-
-            memset(buf, 0, sizeof(buf));
-            rByte = fread((char *)buf, 1, rByte, fd);
-            for(i = 0; i < (rByte+3)/4; i++)
-                checksum += buf[i];
-
-            len -= rByte;
-        }
-        printf("checksum  [%08x]\n\n",checksum);
-
-        if( checksum != header.ih_dcrc) {
-            fclose(fd);
-            return -1;
-        }
-    }
-
-    fclose(fd);
-    return 0;
-}
-
-static int select_read(int fd, int timeout) //1ms
-{
-    fd_set set;
-    struct timeval t;
-    int ret;
-    int i = timeout;
-
-    if(use_select) {
-        do {
-            FD_ZERO(&set);
-            FD_SET(fd, &set);
-            t.tv_sec = 0;
-            t.tv_usec = 100;
-            ret = select(FD_SETSIZE, &set, NULL, NULL, &t );
-            if(ret == 0) continue;
-            if(ret < 0 && errno == EINTR)continue;
-            else return ret;
-        } while(i--);
-    } else {
-        struct timeval t0, t1;
-        long dt = 0;
-        int c;
-        printf("22222\n");
-        gettimeofday(&t0, NULL);
-        do {
-            c = 0;
-            ret = ioctl(fd, FIONREAD, &c);
-            if(c > 0) { ret = c; break; }
-
-            gettimeofday(&t1, NULL);
-            dt = t1.tv_usec - t0.tv_usec;
-            dt += (t1.tv_sec-t0.tv_sec)*1000*1000;
-        } while(dt/1000 < timeout);
-    }
-
-    return ret;
-}
-
-int set_baudrate(int fd, int baudrate)
-{
-    struct termios options, oldtio;
-
-    if(fcntl(fd, F_SETFL, 0) < 0) {
-        printf("fcntl failed!\n");
-        return -1;
-    }
-
-    if(tcgetattr(fd, &oldtio) != 0) {
-        printf("setup serial error!\n");
-        return -1;
-    }
-
-    /* Get the current options for the port... */
-    tcgetattr(fd, &options);
-
-    /* Set the baud rates to baudrate... */
-    cfsetispeed(&options,baudrate);
-    cfsetospeed(&options,baudrate);
-    tcsetattr(fd, TCSANOW, &options);
-
-    if (0 != tcgetattr(fd, &options))
-    {
-        printf("get options error!\n");
-        return -1;
-    }
-
-    /*
-         * 8bit Data,no partity,1 stop bit...
-         */
-    options.c_cflag &= ~PARENB;//无奇偶校验
-    options.c_cflag &= ~CSTOPB;//停止位,1位
-    options.c_cflag &= ~CSIZE; //数据位的位掩码
-    options.c_cflag |= CS8;    //数据位,8位
-
-    cfmakeraw(&options);
-
-    /*
-         * Set the new options for the port...
-         */
-    if (tcsetattr(fd, TCSANOW, &options) != 0)
-    {
-        printf("setup serial error!\n");
-        return -1 ;
-    }
-
-    return 0 ;
-}
-
-int initial_serialPort(char * serial_device)
-{
-    int fd;
-    fd = open( serial_device , O_RDWR );
-    if ( fd == -1 )
-    {
-        /* open error! */
-        printf("Can't open serial port(%s)!(errno=%d:%s) \n", serial_device, errno, strerror(errno));
-        return -1;
-    }
-
-    set_baudrate(fd, B9600);
-
-    return fd ;
-}
-
-static void gps_dev_send(int fd, char *msg)
-{
-    int i, n, ret;
-
-    i = strlen(msg);
-
-    n = 0;
-
-    printf("function gps_dev_send: %s", msg);
-    do {
-
-        ret = write(fd, msg + n, i - n);
-
-        if (ret < 0 && errno == EINTR) {
-            continue;
-        }
-
-        n += ret;
-
-    } while (n < i);
-
-    // drain cmd
-    tcdrain(fd);
-
-    return;
-}
-
-int xmodem_send(int fd, char *fname)
-{
-    char packet_data[XMODEM_DATA_SIZE];
-    char frame_data[XMODEM_DATA_SIZE + XMODEM_CRC_SIZE + XMODEM_FRAME_ID_SIZE + 1];
-    int ret = -1;
-
-    FILE *datafile;
-    int complete,retry_num,pack_counter,read_number,write_number,i;
-    unsigned short crc_value;
-    unsigned char ack_id = 'C';
-    struct timeval time_m, time_n;
-
-    datafile = NULL;
-    pack_counter = 0;	// 包计数器清零
-    complete = 0;
-    retry_num = 0;
-
-    printf("[%s]\n",fname);
-    //只读方式打开一个准备发送的文件,如果不存在就报错,退出程序。
-    if((datafile=fopen(fname,"rb"))==NULL)
-    {
-        printf("\n can't open (%s) or not exist!(errno=%d:%s) \n", fname, errno, strerror(errno));
-        return -1;
-    }
-    else
-    {
-        printf("Ready to send the file:%s\n",fname);
-    }
-
-    printf("Waiting for signal C/NAK!\n");
-    GET_TIME();
-    while(1)
-    {
-        CHK_TIME1();
-        if(select_read(fd,1) > 0)
-            usleep(10000);
-        else
-            continue;
-
-        //read(fd,&ack_id,1);
-        deal_read(fd,&ack_id,1);
-        if(ack_id == 'C')
-            break;
-    }
-
-    printf("The signal NAK: %02x ok!!!\n",ack_id);//打印接收到的NAK信息
-
-    while(!complete)
-    {
-        switch(ack_id)
-        {
-        case XMODEM_CRC_CHR:	// 接收到字符'C'开始启动传输,并使用CRC校验
-            printf("begining to Send file %s...\n",fname);
-
-        case XMODEM_ACK:        //0x06
-            retry_num = 0;
-            pack_counter++;
-
-            read_number = fread(packet_data, sizeof(char), XMODEM_DATA_SIZE, datafile);
-            //从打开的datafile指向的文件中读取
-            //XMODEM_DATA_SIZE 个(char)数据,
-            //放到packet_data这个数组中
-            if(read_number > 0)//read_number为返回的读取实际字节数
-            {
-                //printf("test:read_number:%d\n", read_number);
-                if(read_number < XMODEM_DATA_SIZE_STX)
-                {
-                    printf("Start filling the last frame!\n");
-                    for(; read_number < XMODEM_DATA_SIZE; read_number++)
-                        packet_data[read_number] = 0x1A;  // 不足128字节用0x1A填充
-                    //printf("replenish data.\n");
-                }
-
-                frame_data[0] = XMODEM_HEAD;  // 帧开始字符
-                frame_data[1] = (char)pack_counter;  // 信息包序号
-                frame_data[2] = (char)(255 - frame_data[1]);  // 信息包序号的补码
-
-                for(i=0; i < XMODEM_DATA_SIZE; i++)  // 128字节的数据段
-                    frame_data[i+3] = packet_data[i];//把收到的字符和信息头一起打包
-
-                crc_value = get_crc16(packet_data, XMODEM_DATA_SIZE); // 16位crc校验
-                frame_data[XMODEM_DATA_SIZE+3] = (unsigned char)(crc_value >> 8);// 高八位数据
-                frame_data[XMODEM_DATA_SIZE+4] = (unsigned char)(crc_value);     //低八位数据
-
-                /* 发送133字节数据 */
-                write_number = write( fd, frame_data, XMODEM_DATA_SIZE + 5);//向串口写一个包数据,即133字节数据
-                printf("."); //ADD: process
-                fflush(stdout);
-                //printf("waiting for next ACK... \n......\n");
-
-                GET_TIME();
-                while(1)
-                {
-                    CHK_TIME1();
-                    if(select_read(fd,1) > 0)
-                        usleep(10000);
-                    else
-                        continue;
-
-                    //read(fd,&ack_id,1);
-                    deal_read(fd,&ack_id,1);
-                    break;
-                }
-
-                if(ack_id == XMODEM_ACK) {
-                    //printf("ACK Ok!!Ready sending next pack!\n");
-                    ;
-                }
-                else
-                {
-                    printf("ACK Error!\n");
-                    printf("0x%02X\n",ack_id);
-                    //printf("pack_counter = %d\n", pack_counter);
-                }
-            }
-
-            else  // 文件发送完成
-            {
-                ack_id = XMODEM_EOT;
-                complete = 1;
-                printf("Complete ACK\n");
-
-                GET_TIME();
-                while(ack_id != XMODEM_ACK)
-                {
-                    CHK_TIME1();
-                    ack_id = XMODEM_EOT;
-                    write_number = write(fd,&ack_id,1);
-                    while((deal_read(fd, &ack_id, 1)) <= 0);
-                }
-                printf("Send file successful!!!\n");
-                fclose(datafile);
-                datafile = NULL;
-            }
-            break;
-
-        case XMODEM_NAK:
-            if( retry_num++ > 10)
-            {
-                printf("Retry too many times,Quit!\n");
-                complete = 1;
-            }
-            else //重试,发送
-            {
-                write_number = write(fd, frame_data, XMODEM_DATA_SIZE + 5);
-                printf("Retry for ACK,%d,%d...", pack_counter, write_number);
-
-                GET_TIME();
-                while(1)
-                {
-                    CHK_TIME1();
-                    if(select_read(fd,1) > 0)
-                        usleep(100);
-                    else
-                        continue;
-
-                    //read(fd,&ack_id,1);
-                    deal_read(fd,&ack_id,1);
-                    break;
-                }
-
-                if( ack_id == XMODEM_ACK )
-                    printf("OK\n");
-                else
-                    printf("Error!\n");
-            }
-            break;
-        default:
-            printf("Fatal Error! %d\n", ack_id);
-            complete = 1;
-            return -1;
-            break;
-        }
-    }
-
-    if( datafile != NULL )
-        fclose(datafile);
-
-    return 0;
-}
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/main.c b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/main.c
new file mode 100755
index 0000000..6b9fddd
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/main.c
@@ -0,0 +1,236 @@
+#include "hd8040_upgrade.h"

+#include "port.h"

+#include <getopt.h>

+#include <include/lynq-gpio.h>

+#define READ_MAX_LENGTH 128

+#define PORT_NAME ("/dev/ttyS2")

+uint8_t g_bin_buff[500*1024] = {0};

+uint32_t g_bin_buff_size = 0;

+extern int get_mon_ver(int uart_fd,uint8_t *ver_buf, int ver_len);

+

+#define READ_LEN_MAX 1024 //BOOT_UPGRADE_BUFF_MAX_1

+

+int read_bin_file(uint8_t *path, uint8_t *buff)

+{

+    int fp = -1;

+    int ret = 0;

+    int i = 0;

+    int size = 0;

+

+    if (NULL == path || NULL == buff)

+    {

+        printf("[%s %d] str error", __FUNCTION__, __LINE__);

+        return -1;

+    }

+

+    fp = open((char *)path, O_RDONLY);

+    if(fp < 0)

+    {

+        printf( "[%s %d]open file failed ! errno is %d\n", __FUNCTION__, __LINE__, errno);

+        return -1;

+    }

+

+    size = lseek(fp, 0x00, SEEK_END);

+    if(size <= 0)

+    {

+        printf( "[%s %d]file is empty\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+

+    printf( "[%s %d]file size is:%d\n", __FUNCTION__, __LINE__, size);

+    lseek(fp, 0x00, SEEK_SET);

+    while(1)

+    {

+        ret = read(fp, buff, READ_LEN_MAX);

+        i += ret;

+        if(ret == READ_LEN_MAX)

+        {

+            buff += READ_LEN_MAX;

+        }

+        else

+        {

+            break;

+        }

+    }

+

+    printf( "[%s %d]file size is:%d,i:%d\n", __FUNCTION__, __LINE__, size, i);

+    close(fp);

+    if(size != i)

+    {

+        return -1;

+    }

+    g_bin_buff_size = size;

+    return 0;

+}

+

+static void print_usage(const char *prog)

+{

+    printf("Usage: %s [-BUTVh]\n", prog);

+    puts("  -B --boot    boot mode select\n"

+         "  -U --user  user mode select \n"

+         "  -T --usertoboot  usertoboot mode select \n"

+         "  -V --version firmware version get \n"

+         "  -h --help    help message print \n");

+    exit(1);

+}

+

+struct option long_options[] = {

+{ "name", 0, NULL, 'n' },

+{ "bf_name", 0, NULL, 'b' },

+{ "love", 1, NULL, 'l' },

+{ 0, 0, 0, 0},

+};

+

+static const struct option lopts[] = {

+{ "boot",	required_argument, NULL, 'B' },//required_argument

+{ "user",	required_argument, NULL, 'U' },

+{ "usertoboot", required_argument, NULL, 'T' },

+{ "version",   0, NULL, 'V' },

+{ "help",	0, NULL, 'h' },

+{ 0, 0, 0, 0 },

+};

+char* const short_options1 = "B:U:T:Vh";

+

+int write_file(uint8_t *path, uint8_t *buff, int len)

+{

+    int fp = -1;

+    int ret = 0;

+    int i = 0;

+    int size = 0;

+

+    if (NULL == path || NULL == buff)

+    {

+        printf("[%s %d] str error", __FUNCTION__, __LINE__);

+        return -1;

+    }

+

+    fp = open((char *)path, O_RDWR );

+    if(fp < 0)

+    {

+        printf( "[%s %d]open file failed ! errno is %d\n", __FUNCTION__, __LINE__, errno);

+        return -1;

+    }

+

+    size = lseek(fp, 0x00, SEEK_END);

+

+    write(fp, buff, len);

+

+    printf( "[%s %d]file size is:%d,i:%d\n", __FUNCTION__, __LINE__, size, i);

+    close(fp);

+    return 0;

+}

+

+//example  //升级过程中,禁止其他程序操作该串口,禁止断电复位等操作

+int main(int argc, char *argv[])

+{

+    uint8_t newVersionBuf[READ_MAX_LENGTH] = {0};

+    uint8_t cleintID[READ_MAX_LENGTH] = "999999";

+    int fd = -1; // uart handle

+    int ret = -1;

+    uint8_t filePath[256] = {0};

+    uint16_t filePtahLen = 0;

+

+    if (argc == 1)

+    {

+        printf("This program needs arguments....\n\n");

+        print_usage(argv[0]);

+    }

+

+    int num;

+    while ((num = getopt_long(argc, argv, short_options1, lopts, NULL)) != -1)

+    {

+        printf("getopt_long C:%d\n", num);

+        switch (num)

+        {

+

+        case 'B':

+        {

+            printf("optarg:%s\n", optarg);

+            if ( optarg == NULL )

+            {

+                printf("%s: option 'B' requires argument...\n", argv[0]);

+                break;

+            }

+            filePtahLen = strlen(optarg);

+            if(filePtahLen < sizeof(filePath))

+            {

+                memcpy((char *)filePath, optarg, filePtahLen);

+                goto HD_UPG;

+            }

+

+            //sleep(1);

+        }

+            break;

+        case 'V':

+        {

+            printf("check version\n");

+            fd = OpenUart((char *)PORT_NAME);

+            if (fd < 0)

+            {

+

+                printf("open uart failed %d\n", fd);

+                return -1;

+            }

+            get_mon_ver(fd, newVersionBuf, sizeof(newVersionBuf));

+            printf("version is: %s\n", newVersionBuf);

+            uart_close(fd);

+            return 0;

+        }

+            break;

+

+        default:

+        {

+            printf("please input correct parameters\n");

+        }

+            break;

+        }

+    }

+

+    //芯片上电

+HD_UPG:

+    fd = OpenUart((char *)PORT_NAME);

+    if (fd < 0)

+    {

+

+        printf("open uart failed %d\n", fd);

+        return -1;

+    }

+    ret = read_bin_file(filePath, g_bin_buff);

+    if (ret < 0)

+    {

+        printf("open file failed %d\n", fd);

+        return -1;

+    }

+

+    /*go to boot-mode need change pin status*/

+    lynq_gpio_init(15,1,0,0);

+    lynq_gpio_value_set(15, 0);

+    usleep(100000);//100ms

+    lynq_gpio_init(126,1,1,0);

+    lynq_gpio_value_set(126, 1);

+    usleep(1000000);//1s

+    lynq_gpio_value_set(126, 0);

+    usleep(100000);//100ms

+    lynq_gpio_direction_set(15, 0);

+    lynq_gpio_pullsel_set(15, 0);

+    lynq_gpio_deinit(15);

+    lynq_gpio_deinit(126);

+

+    ret = fw_update_boot(fd, g_bin_buff, g_bin_buff_size);

+    if (ret < 0)

+    {

+        printf("open file failed %d\n", fd);

+        return -1;

+    }

+    sleep(1);

+    if(ret == HDBD_UPG_SUCESS)

+    {

+        printf("upgrade sucess!\r\n");

+    }

+    else

+    {

+        printf("upgrade FAIL, fail style:%d\r\n",ret);

+    }

+    uart_close(fd);

+    return ret;

+}

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/makefile b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/makefile
new file mode 100755
index 0000000..04660b9
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/makefile
@@ -0,0 +1,43 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+				-std=gnu++14 \
+				-g -Os \
+				-flto \
+				-fpermissive \
+
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+				-I.\
+				-I$(ROOT)$(includedir) \
+
+
+
+
+LOCAL_LIBS := \
+			-L. \
+			-ldl \
+			-lstdc++ \
+			-lpthread \
+			-llynq-gpio \
+
+
+
+SOURCES = $(wildcard *.c )
+
+EXECUTABLE = lynq-gnss-update
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CC) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/port.c b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/port.c
new file mode 100755
index 0000000..e72ebd3
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/port.c
@@ -0,0 +1,468 @@
+#include "port.h"

+

+/**

+  * @brief  Send Data to serial port

+  * @param  fd:file desc

+  * @param  cmd:data pointer

+  * @param  cmd_len:data length

+  * @retval SUCCESS/FAIL

+  */

+int uart_send(int fd, uint8_t *cmd, int cmd_len)

+{

+    int ret = FAIL;

+

+    ret = write(fd, cmd, cmd_len);

+    if(ret < 0)

+    {

+        HDBD_LOG("[%s %d]write port failed,ret: %d\n", __FUNCTION__, __LINE__, ret);

+        return FAIL;

+    }

+

+    return SUCCESS;

+}

+

+

+/**

+  * @brief  Receive data from serial port0

+  * @param  fd:file desc

+  * @param  buf:receive buffer

+  * @param  actual_length:receive data length

+  * @param  timeout:para of timeout

+  * @retval SUCCESS/FAIL

+  */

+int uart_recv(int fd, uint8_t *buf, int *actual_length, int timeout)

+{

+    int ret;

+    int temp = 0;

+    int len = *actual_length;

+    uint8_t tempBuf[128] = {0};

+    int errorCount = 0;

+    fd_set rd;

+    struct timeval tv;

+    tv.tv_sec = timeout;

+    tv.tv_usec = 0;

+

+    FD_ZERO(&rd);

+    FD_SET(fd, &rd);

+    *actual_length = 0;

+    HDBD_LOG("[%s %d] len:%d\n", __FUNCTION__, __LINE__, len);

+    while(1)

+    {

+        ret = select(fd + 1, &rd, NULL, NULL, &tv);

+        if(ret > 0){

+            if (FD_ISSET(fd, &rd)) {

+                temp = read(fd, tempBuf, 128);

+                if(temp > 0)

+                {

+                    errorCount = 0;

+                    if((*actual_length + temp) <= len)

+                    {

+                        memcpy(buf+*actual_length, tempBuf, temp);

+                        *actual_length += temp;

+                    }

+                    else

+                    {

+                        memcpy(buf+*actual_length, tempBuf, (len - *actual_length));

+                        *actual_length = len;

+                    }

+                }

+                else

+                {

+                    errorCount++;

+                }

+                HDBD_LOG("[%s %d]len:%d, *actual_length:%d, temp:%d\n", __FUNCTION__, __LINE__, len, *actual_length, temp);

+            }

+        }

+        else if(ret == 0)

+        {

+            HDBD_LOG("[%s %d]timeout\n", __FUNCTION__, __LINE__);

+            if(*actual_length <= 2)

+            {

+                goto ERR1;

+            }

+            else

+            {

+                break;

+            }

+        }

+        else

+        {

+            HDBD_LOG("[%s %d] select error!\n", __FUNCTION__, __LINE__);

+            goto ERR1;

+        }

+

+        if((*actual_length >= len) || (errorCount >= 5))

+        {

+            HDBD_LOG("[%s %d]*actual_length:%d, recv sucess,break\n", __FUNCTION__, __LINE__);

+            break;

+        }

+

+    }

+

+    HDBD_LOG("[%s %d]*actual_length:%d, ret:%d\n", __FUNCTION__, __LINE__, *actual_length, ret);

+    return SUCCESS;

+

+ERR1:

+    return FAIL;

+}

+

+int UartRead(int fd, uint8_t *RxBuff, long RxLen)

+{

+    int GetRxLen=0;

+    int index;

+    while(RxLen){

+        index = read(fd, RxBuff+GetRxLen, 1);

+        GetRxLen += index;

+        RxLen--;

+        if(index == 0)

+        {

+            return GetRxLen;

+        }

+    }

+

+    return GetRxLen ;

+}

+

+/**

+  * @brief  Write gpio node

+  * @param  path:path of gpio node

+  * @param  value:'1' or '0'

+  * @retval SUCCESS/FAIL

+  */

+int write_gpio(char const* path, int value)

+{

+    int fd = -1;

+    char buffer[20] = {0};

+    int bytes = 0;

+    ssize_t amt = 0;

+

+    memset(buffer, 0x0, sizeof(buffer));

+    fd = open(path, O_RDWR);

+

+    if (fd >= 0)

+    {

+        bytes = snprintf(buffer, sizeof(buffer), "%d\n", value);

+        amt = write(fd, buffer, (size_t)bytes);

+        close(fd);

+        return amt == -1 ? -errno : 0;

+    }

+    else

+    {

+        HDBD_LOG("[%s %d]write_int failed to open %s, errno is %d \n", __FUNCTION__, __LINE__, path, errno);

+    }

+

+    return -errno;

+}

+

+/**

+  * @brief  Read gpio node

+  * @param  path:path of gpio node

+  * @param  value:'1' or '0'

+  * @retval SUCCESS/FAIL

+  */

+int read_gpio(char const* path)

+{

+    int fd = -1;

+    char buffer[20] = {0};

+    ssize_t amt = 0;

+

+    memset(buffer, 0x0, sizeof(buffer));

+    fd = open(path, O_RDWR);

+

+    if (fd >= 0)

+    {

+        amt = read(fd, buffer, 1);

+        close(fd);

+        HDBD_LOG("[%s %d]read to <%s>, value is <%zd> \n", __FUNCTION__, __LINE__, path, amt);

+        return 0;

+    }

+    else

+    {

+        HDBD_LOG("[%s %d]read failed to open <%s>, errno is <%d> \n", __FUNCTION__, __LINE__, path, errno);

+    }

+

+    return -1;

+}

+

+/**

+  * @brief  Set serial port Para

+  * @param  fd:file desc

+  * @param  speed:baudrate

+  * @param  flow_ctrl:flow control flag

+  * @param  databits:data bits

+  * @param  stopbits:stop bits

+  * @param  parity:parity flag

+  * @retval SUCCESS/FAIL

+  */

+int uart_set(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity)

+{

+    int   i;

+    int   speed_arr[11] = {B921600, B576000, B460800,B230400, B115200, B19200, B9600, B4800, B2400, B1200, B300};

+    int   name_arr[11]  = {921600,576000,460800,230400, 115200,  19200,  9600,  4800,  2400,  1200,  300};

+

+    struct termios options;

+

+    if ( tcgetattr( fd, &options)  !=  0)

+    {

+        HDBD_LOG("[%s %d]get serial options Fail\n", __FUNCTION__, __LINE__);

+        return FAIL;

+    }

+

+    for ( i = 0;  i < 11;  i++) /* sizeof(speed_arr) / sizeof(int) */

+    {

+        if  (speed == name_arr[i])

+        {

+            cfsetispeed(&options, speed_arr[i]);

+            cfsetospeed(&options, speed_arr[i]);

+            break;

+        }

+    }

+

+    options.c_cflag |= CLOCAL;

+    options.c_cflag |= CREAD;

+

+    switch (flow_ctrl)

+    {

+

+    case 0 :

+        options.c_cflag &= ~CRTSCTS;

+        break;

+

+    case 1 :

+        options.c_cflag |= CRTSCTS;

+        break;

+    case 2 :

+        options.c_cflag |= IXON | IXOFF | IXANY;

+        break;

+    }

+

+    options.c_cflag &= ~CSIZE;

+    switch (databits)

+    {

+    case 5    :

+        options.c_cflag |= CS5;

+        break;

+    case 6    :

+        options.c_cflag |= CS6;

+        break;

+    case 7    :

+        options.c_cflag |= CS7;

+        break;

+    case 8:

+        options.c_cflag |= CS8;

+        break;

+    default:

+        HDBD_LOG("[%s %d] Unsupported data size\n", __FUNCTION__, __LINE__);

+        return FAIL;

+    }

+

+    switch (parity)

+    {

+    case 'n':

+    case 'N':

+        options.c_cflag &= ~PARENB;

+        options.c_iflag &= ~INPCK;

+        break;

+    case 'o':

+    case 'O':

+        options.c_cflag |= (PARODD | PARENB);

+        options.c_iflag |= INPCK;

+        break;

+    case 'e':

+    case 'E':

+        options.c_cflag |= PARENB;

+        options.c_cflag &= ~PARODD;

+        options.c_iflag |= INPCK;

+        break;

+    case 's':

+    case 'S':

+        options.c_cflag &= ~PARENB;

+        options.c_cflag &= ~CSTOPB;

+        break;

+    default:

+        HDBD_LOG("[%s %d] Unsupported parity\n", __FUNCTION__, __LINE__);

+        return FAIL;

+    }

+

+    switch (stopbits)

+    {

+    case 1:

+        options.c_cflag &= ~CSTOPB; break;

+    case 2:

+        options.c_cflag |= CSTOPB; break;

+    default:

+        HDBD_LOG("[%s %d] Unsupported stop bits\n", __FUNCTION__, __LINE__);

+        return FAIL;

+    }

+

+    options.c_oflag &= ~OPOST;

+    options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);

+    options.c_cc[VTIME] = 1;

+    options.c_cc[VMIN] = 1;

+    tcflush(fd, TCIFLUSH);

+

+    if (tcsetattr(fd, TCSANOW, &options) != 0)

+    {

+        HDBD_LOG("[%s %d] com set error!\n", __FUNCTION__, __LINE__);

+        return FAIL;

+    }

+    

+    return SUCCESS;

+}

+

+/**

+  * @brief  Init serial port

+  * @param  fd:file desc

+  * @param  speed:baudrate

+  * @param  flow_ctrl:flow control flag

+  * @param  databits:data bits

+  * @param  stopbits:stop bits

+  * @param  parity:parity flag

+  * @retval SUCCESS/FAIL

+  */

+int uart_init(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity)

+{

+    if (uart_set(fd, speed, flow_ctrl, databits, stopbits, parity) == FAIL)

+    {

+        HDBD_LOG("[%s %d] Uart init false\n", __FUNCTION__, __LINE__);

+        return FAIL;

+    }

+    else

+    {

+        return  SUCCESS;

+    }

+}

+

+/**

+  * @brief  Init serial port

+  * @param  fd:uart fd

+  * @param  selector:TCIOFLUSH/TCIFLUSH

+  */

+void clearBuffer(int fd, int selector)

+{

+    tcflush(fd, selector);

+}

+

+/**

+  * @brief  open serial port

+  * @param  GPS_DEVICE:uart port

+  * @retval SUCCESS/FAIL

+  */

+int uart_open(unsigned char * GPS_DEVICE)

+{

+    int fd = -1;

+    int uart_init_ret = -1;

+    fd = open((char *)GPS_DEVICE, O_RDWR|O_NOCTTY|O_NDELAY);

+

+    if( fd < 0)

+    {

+        HDBD_LOG("[%s %d] : open port ERROR..state->fd=%d, errno=%d\n",__FUNCTION__, __LINE__, fd, errno);

+        return -1;

+    }

+

+    HDBD_LOG("[%s %d] : open port succceed..state->fd=%d OK\n", __FUNCTION__, __LINE__, fd);

+

+    /* set port */

+    if(fcntl( fd,F_SETFL,0)<0)

+    {

+        HDBD_LOG("[%s %d] : fcntl F_SETFL Fail\n", __FUNCTION__, __LINE__);

+        return -1;

+    }

+

+    tcflush(fd, TCIOFLUSH);

+

+    uart_init_ret = uart_init(fd, 115200, 0, 8, 1, 'N');

+    if (-1 == uart_init_ret)

+    {

+        HDBD_LOG("[%s %d] : uart_init_ret is <%d>, return -1\n", __FUNCTION__, __LINE__, uart_init_ret);

+        return -1;

+    }

+

+    HDBD_LOG("[%s %d] : Port setup finished..OK\n", __FUNCTION__, __LINE__);

+    return fd;

+}

+

+int uart_close(int fd)

+{

+    close(fd);

+    return 0;

+}

+

+

+void SetOpt(int fd)

+{

+    static struct termios termold, termnew;

+    tcgetattr(fd, &termold);

+    bzero(&termnew, sizeof(termnew));

+

+    termnew.c_iflag &= ~(ICRNL | IGNCR);

+    termnew.c_cflag |= CLOCAL | CREAD;

+    termnew.c_cflag &= ~CSIZE;

+    termnew.c_cflag |= CS8;

+    termnew.c_cflag &= ~CRTSCTS;

+    termnew.c_cflag &= ~PARENB;

+

+    cfsetispeed(&termnew, B115200);

+    cfsetospeed(&termnew, B115200);

+

+    termnew.c_cflag &=  ~CSTOPB;

+    termnew.c_cc[VTIME]  = 1;

+    termnew.c_cc[VMIN] = 0;

+    tcflush(fd, TCIFLUSH);

+    tcsetattr(fd, TCSANOW, &termnew);

+}

+

+/*

+* band : 0->460800, 1->115200, 2->9600, other->115200

+*/

+int set_baudrate(int fd, uint8_t baud)

+{

+    static struct termios termold, termnew;

+    tcgetattr(fd, &termold);

+    bzero(&termnew, sizeof(termnew));

+

+    termnew.c_iflag &= ~(ICRNL | IGNCR);

+    termnew.c_cflag |= CLOCAL | CREAD;

+    termnew.c_cflag &= ~CSIZE;

+    termnew.c_cflag |= CS8;

+    termnew.c_cflag &= ~CRTSCTS;

+    termnew.c_cflag &= ~PARENB;

+

+    if(baud == 1)

+    {

+        cfsetispeed(&termnew, B460800);

+        cfsetospeed(&termnew, B460800);

+    }

+    else if(baud = 2)

+    {

+        cfsetispeed(&termnew, B115200);

+        cfsetospeed(&termnew, B115200);

+    }

+    else if(baud)

+    {

+        cfsetispeed(&termnew, B9600);

+        cfsetospeed(&termnew, B9600);

+    }

+    else

+    {

+        cfsetispeed(&termnew, B115200);

+        cfsetospeed(&termnew, B115200);

+    }

+    termnew.c_cflag &=  ~CSTOPB;

+    termnew.c_cc[VTIME]  = 1;

+    termnew.c_cc[VMIN] = 0;

+    tcflush(fd, TCIFLUSH);

+    tcsetattr(fd, TCSANOW, &termnew);

+}

+

+int OpenUart(char* UART_DEV)

+{

+    int fd=0;

+    fd = open(UART_DEV , O_RDWR|O_NOCTTY);

+    if (fd < 0)

+    {

+        return -1;

+    }

+    SetOpt(fd);

+    return  fd;

+}

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/port.h b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/port.h
new file mode 100755
index 0000000..e90ad61
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/port.h
@@ -0,0 +1,49 @@
+#ifndef  __HD8040_PORT_H

+#define  __HD8040_PORT_H

+

+#include <stdio.h>

+#include <stdlib.h>

+#include <unistd.h>

+#include <string.h>

+#include <errno.h>

+#include <fcntl.h>

+#include <termios.h>

+#include <sys/types.h>

+#include <sys/wait.h>

+#include <sys/un.h>

+#include <sys/time.h>

+#include <dirent.h>

+#include <sys/stat.h>

+

+#define SUCCESS 0

+#define FAIL -1

+

+#ifndef HDBD_LOG

+#define HDBD_LOG printf

+#endif

+

+typedef unsigned char  uint8_t;

+typedef unsigned short int uint16_t;

+typedef unsigned int   uint32_t;

+/* For communication buadrate */

+#define COMM_BAUDRATE_PHONE 115200

+

+/* For upgrade baudrate */

+#define UPGRADE_BAUDRATE_PHONE 460800

+

+/* <Function define Config begin */

+#define DEBUG_RUN_TIME 0

+/* Function define Config end> */

+

+/* Function Declaration */

+/* Basic operation for serial port */

+extern int uart_set(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity);

+extern int uart_init(int fd, int speed, int flow_ctrl, int databits, int stopbits, int parity);

+extern int uart_send(int fd, uint8_t *cmd, int cmd_len);

+extern int uart_recv(int fd, uint8_t *buf, int *actual_length, int timeout);

+extern void clearBuffer(int fd, int selector);

+extern int uart_open(unsigned char * GPS_DEVICE);

+extern int uart_close(int fd);

+extern int OpenUart(char* UART_DEV);

+extern int set_baudrate(int fd, uint8_t baud);

+#endif

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/lynq-gnss-update.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/lynq-gnss-update.bb
index 9ada3c1..12ac78a 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/lynq-gnss-update.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-gnss-update/lynq-gnss-update.bb
@@ -1,33 +1,34 @@
-# Package summary

-SUMMARY = "lynq-gnss-update"

-# License, for example MIT

-LICENSE = "MIT"

-# License checksum file is always required

-LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

+#inherit externalsrc package

+#inherit externalsrc package systemd

+DESCRIPTION = "lynq-gnss-update"

+DEPENDS += "liblynq-gpio"

+LICENSE = "CLOSED"

 

-SRC_URI = " file://lynq-gnss-update.cpp"

+LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e07e8d88e26263e71d3a9e2aa9a2ff"

+SRC_URI = " file://port.c \

+            file://port.h \

+            file://fwup.c \

+            file://main.c \

+            file://hd8040_upgrade.h \

+            file://makefile \

+"

 

 SRC-DIR = "${S}/../lynq-gnss-update"

+FILES_${PN} += "${bindir}/"

 TARGET_CC_ARCH += "${LDFLAGS}"

-

-#Parameters passed to do_compile()

-EXTRA_OEMAKE = "'TARGET_PLATFORM = ${TARGET_PLATFORM}'\"

-EXTRA_OEMAKE += "'MOBILETEK_RIL_CFG = ${MOBILETEK_RIL_CFG}'"

-

-LOCAL_C_INCLUDES = "-I."

-

-LOCAL_LIBS = "-L. -ldl -lstdc++"

-

-#INHIBIT_PACKAGE_STRIP = "1"

+SYSTEMD_PACKAGES = "${PN}"

 S = "${WORKDIR}"

-

 #INHIBIT_PACKAGE_STRIP = "1"

 do_compile () {

-

-	${CXX} -Wall lynq-gnss-update.cpp ${LOCAL_LIBS} ${LOCAL_C_INCLUDES} -o lynq-gnss-update

+	if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then

+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"

+	else

+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"

+	fi

 }

 

+

 do_install() {

 	install -d ${D}${bindir}/

 	install -m 0755 ${S}/lynq-gnss-update ${D}${bindir}/

-}
\ No newline at end of file
+}

diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
index 2522423..b05400c 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
@@ -56,6 +56,10 @@
 /*Warren add forT800 platform 2021/12/25 start*/
 #include "lynq_common.h"
 #include "lynq_interface.h"
+#ifdef LED_SUPPORT
+#include "led.h"
+#include <include/lynq_uci.h>
+#endif
 using android::Parcel;
 /*Warren add for t800 ril service  2021/12/25 end*/
 #undef LOG_TAG
@@ -153,6 +157,11 @@
 #define IOT_DATAASST_PDN_APN_TYPE_NET_5     (0x04000000)
 #define IOT_DATAASST_PDN_APN_TYPE_NET_6     (0x08000000)
 
+#ifdef LED_SUPPORT
+#define LED_ON 4
+#define LYNQ_UCI_SECTION "lynq_led"
+#define LYNQ_UCI_NETLED_KEY "lynq_netled_on"
+#endif
 #define LEN 128
 char line[LEN] = {0};
 char csname[27] = {0};
@@ -1517,6 +1526,7 @@
 void updateRILDataCallResponsev11(int num ,RIL_Data_Call_Response_v11* p_cur)
 {
     int i = 0;
+    int pdp_count = 0;
     RLOGD("in updateRILDataCallResponsev11");
     if(num != 1)
     {
@@ -1575,6 +1585,21 @@
             lynq_apn_cid_table[i].used,
             lynq_apn_cid_table[i].address,
             lynq_apn_cid_table[i].dialing);
+            if(lynq_apn_cid_table[i].cid != -1)
+            {
+                pdp_count++;
+            }
+    }
+    if(pdp_count == 1)
+    {
+#ifdef LED_SUPPORT
+        char netled_on[LED_ON] = "";
+        lynq_get_value(LYNQ_UCI_FILE, LYNQ_UCI_SECTION, LYNQ_UCI_NETLED_KEY, netled_on);
+        if(1 == atoi(netled_on))
+        {
+            mbtk_netled_state_update(GPIO_NETLED_PPP_CONNECT);
+        }
+#endif
     }
 }
 //xf.li@20230610 add for T106 end
@@ -1647,6 +1672,7 @@
 #ifdef MOBILETEK_TARGET_PLATFORM_T106
 void handleUnsolDataCalllistChange(int num ,RIL_Data_Call_Response_v11* p_cur){
     int i;
+    int pdp_count = 0;
     RLOGD("num = %d, apn_count = %d", num, apn_count);
     for(int j = 0; j < LYNQ_APN_CHANNEL_MAX; j++)
     {
@@ -1719,6 +1745,21 @@
             lynq_apn_cid_table[i].used,
             lynq_apn_cid_table[i].address,
             lynq_apn_cid_table[i].dialing);
+        if(lynq_apn_cid_table[i].cid != -1)
+        {
+            pdp_count++;
+        }
+    }
+    if(pdp_count == 0)
+    {
+#ifdef LED_SUPPORT
+        char netled_on[LED_ON] = "";
+        lynq_get_value(LYNQ_UCI_FILE, LYNQ_UCI_SECTION, LYNQ_UCI_NETLED_KEY, netled_on);
+        if(1 == atoi(netled_on))
+        {
+            mbtk_netled_state_update(GPIO_NETLED_PPP_CLOSED);
+        }
+#endif
     }
 
 
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQALS.ANT.EPH.CFG.PPS13.240115R1.bin b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQALS.ANT.EPH.CFG.PPS13.240115R1.bin
new file mode 100755
index 0000000..2b26ecb
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQALS.ANT.EPH.CFG.PPS13.240115R1.bin
Binary files differ
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQBS.B1C.ANT.EPH.CFG.PPS13.240308R1.bin b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQBS.B1C.ANT.EPH.CFG.PPS13.240308R1.bin
new file mode 100755
index 0000000..cb718dc
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQBS.B1C.ANT.EPH.CFG.PPS13.240308R1.bin
Binary files differ
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/UC6228CI-R3.2.10.100Build8019_mfg.pkg b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/UC6228CI-R3.2.10.100Build8019_mfg.pkg
deleted file mode 100755
index 5310f03..0000000
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/UC6228CI-R3.2.10.100Build8019_mfg.pkg
+++ /dev/null
Binary files differ
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/bootloader_r3.0.0_build6773_uartboot_921600.pkg b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/bootloader_r3.0.0_build6773_uartboot_921600.pkg
deleted file mode 100755
index 3cfd1fb..0000000
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/bootloader_r3.0.0_build6773_uartboot_921600.pkg
+++ /dev/null
Binary files differ
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
index f769e44..e2e4833 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
@@ -371,20 +371,9 @@
     {
         return  -2;
     }
-
     return 0;
 }
 
-int qser_firmware_update(uint32_t h_gnss)
-{
-    int ret;
-    mopen_gnss_firmware_update(h_gnss);
-    if(ret < 0)
-    {
-        return -1;
-    }
-    return 0;
-}
 
 /**
  * @brief      qser_Gnss_Server_Configuration
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
index fd0b9be..0bb8d1f 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
@@ -1044,11 +1044,6 @@
     pthread_mutex_init(&mbtk_gnss_handle->_cond_mutex, NULL);
     pthread_create(&mbtk_gnss_handle->uart_pthread, NULL, (void* (*)(void*))gnss_uart_pthread, (void *)mbtk_gnss_handle);
     pthread_create(&mbtk_gnss_handle->gnss_pthread, NULL, (void* (*)(void*))gnss_info_pthread, (void *)mbtk_gnss_handle);
-    mopen_gnss_get_ant_state_info((uint32)mbtk_gnss_handle);
-    lynq_gnss_get_device_info((uint32)mbtk_gnss_handle);
-    mopen_gnss_get_nmea_config((uint32)mbtk_gnss_handle);
-    lynq_gnss_get_uart((uint32)mbtk_gnss_handle);
-    lynq_gnss_get_aidinfo((uint32)mbtk_gnss_handle);
     *ph_gnss = (uint32)mbtk_gnss_handle;
     mbtk_gnss_handle->phandle = ph_gnss;
 
@@ -1621,78 +1616,6 @@
     return 0;
 }
 
-/**
-* @brief 使用popen调用终端并获取执行结果
-*
-* @param[in] cmd 命令内容
-* @param[out] result 保存结果的地址
-* @return 0或1 执行状态,成功或失败
-*/
-int exec_cmd(const char *cmd, char *result)
-{
-    /*result is not used temporarily*/
-    int ret = -1;
-    ret = system(cmd);
-    if(ret == -1)
-    {
-        ALOGE("cmd system error\n");
-        return ret;
-    }
-    return 0;
-}
-
-/*
-update API:
-Gnss_Update_File_Path:"/data/gnss_update/firmware.pkg"
-Gnss_Bootloader_File_Path: "/data/gnss_update/bootloader.pkg"
- */
-int mopen_gnss_firmware_update(uint32 ph_gnss)
-{
-    int ret;
-    int state = 0;
-    printf("load_datafile start\n");
-    struct mbtk_gnss_handle_t *gnss_handle = (struct mbtk_gnss_handle_t* )ph_gnss;
-    const char* cmd_1 = "lynq-gnss-update downbl -d /dev/ttyS2  -b 230400 -l /data/gnss_update/bootloader.pkg";
-    const char* cmd_2 = "lynq-gnss-update downfw -d /dev/ttyS2 -b 921600 -f /data/gnss_update/firmware.pkg";
-    const char* cmd_3 = "echo \"\$PDTINFO\r\n\" > /dev/ttyS2";
-    if (ph_gnss)
-    {
-        printf("%s gnss thread runing!!!\n", __func__);
-        // 主线程是否在运行
-        if (gnss_handle->gnss_pthread)
-            state = 1;
-        lynq_gnss_client_deinit(ph_gnss);
-    }
-    printf("Mopen Gnss Bootloader Update -> \n");
-    ret = exec_cmd(cmd_1, NULL);
-    if(0 != ret)
-    {
-        ALOGE("Gnss update result: %x\n", ret);
-        return -1;
-    }
-
-    printf("Mopen Gnss Firmware Update -> \n");
-    ret = exec_cmd(cmd_2, NULL);
-    if(0 != ret)
-    {
-        ALOGE("Gnss update result: %x\n", ret);
-        return -1;
-    }
-
-    printf("PDTINFO  -> \n");
-    ret = exec_cmd(cmd_3, NULL);
-    if(0 != ret)
-    {
-        ALOGE("PDTINFO  ->  %x\n", ret);
-        return -1;
-    }
-
-    if (0 == firmware_extren_state)
-        firmware_extren_state = 1;
-
-    return ret;
-}
-
 /*Injection ephemeris AGNSS_TLE_FILE*/
 int lynq_gnss_Injection_ephemeris(uint32 h_gnss)
 {
diff --git a/update_version.sh b/update_version.sh
index 8e5aaa0..21b5761 100755
--- a/update_version.sh
+++ b/update_version.sh
@@ -1,8 +1,8 @@
 #!/bin/bash
 #export LYNQ_VERSION="T106_lynq_version_ap_build_sh"
-LYNQ_AP_VERSION="T106-V2.01.01.02P56U01.AP.12.06"
-LYNQ_CAP_INSIDE_VERSION="CAP.12.06"
-LYNQ_CAP_VERSION="CAP.12.06"
+LYNQ_AP_VERSION="T106-V2.01.01.02P56U01.AP.12.08"
+LYNQ_CAP_INSIDE_VERSION="CAP.12.08"
+LYNQ_CAP_VERSION="CAP.12.08"
 COMMIT_ID="$(git rev-parse HEAD)"
 
 LYNQ_SW_INSIDE_VERSION="LYNQ_CONFIG_VERSION = \"${LYNQ_AP_VERSION}_${LYNQ_CAP_INSIDE_VERSION}\""