Add dev_info v2(Default is v1)

Change-Id: I49693856ab5c97a5df3c199ed75091c4eee1800b
diff --git a/mbtk/Make.defines b/mbtk/Make.defines
index d364ff9..7e2ded7 100755
--- a/mbtk/Make.defines
+++ b/mbtk/Make.defines
@@ -78,6 +78,10 @@
 DEFINE += -DMBTK_SOURCE_VERSION_2

 endif

 

+ifeq ($(MBTK_DEV_INFO_VERSION), 2)

+DEFINE += -DMBTK_DEV_INFO_VERSION_2

+endif

+

 LIB_DIR = \

 	-L$(OUT_DIR)/lib

 

diff --git a/mbtk/include/mbtk/mbtk_device_v2.h b/mbtk/include/mbtk/mbtk_device_v2.h
new file mode 100755
index 0000000..711b893
--- /dev/null
+++ b/mbtk/include/mbtk/mbtk_device_v2.h
@@ -0,0 +1,136 @@
+/*
+* mbtk_device.h
+*
+* MBTK device_info partition data header.
+*
+* Author : lb
+* Date   : 2023/12/30 11:36:35
+*/
+#ifndef _MBTK_DEVICE_V2_H
+#define _MBTK_DEVICE_V2_H
+//#include "mbtk_type.h"
+
+#define MBTK_DEVICE_INFO_PARTITION_NAME "device_info"
+#define MBTK_DEVICE_INFO_PARTITION_TAG 0x87878787
+#define MBTK_DEVICE_INFO_CURR_VERSION 2
+
+#define MBTK_DEV_INFO_PARTITION_ADDR 0x02A20000
+
+// 78,147,482,134742231
+#define MBTK_BAND_ALL_GSM_DEFAULT 78             // GSM : ASR default.
+#define MBTK_BAND_ALL_WCDMA_DEFAULT 147          // WCDMA : ASR default.
+#define MBTK_BAND_ALL_TDLTE_DEFAULT 482          // TDD-LTE : ASR default.
+#define MBTK_BAND_ALL_FDDLTE_DEFAULT 134742231   // FDD-LTE : ASR default.
+#define MBTK_BAND_ALL_EXT_LTE_DEFAULT 0          // EXT-LTE
+#define MBTK_BAND_CN_GSM_DEFAULT 11             // GSM : B3/B8 (PGSM 900/DCS GSM 1800/EGSM 900)
+#define MBTK_BAND_CN_WCDMA_DEFAULT 145          // WCDMA : B1/B5/B8
+#define MBTK_BAND_CN_TDLTE_DEFAULT 482          // TDD-LTE : B34/B38/B39/B40/B41
+#define MBTK_BAND_CN_FDDLTE_DEFAULT 149         // FDD-LTE : B1/B3/B5/B8
+#define MBTK_BAND_CN_EXT_LTE_DEFAULT 0          // EXT-LTE
+#define MBTK_BAND_EU_GSM_DEFAULT 11             // GSM : B3/B8 (PGSM 900/DCS GSM 1800/EGSM 900)
+#define MBTK_BAND_EU_WCDMA_DEFAULT 145          // WCDMA : B1/B5/B8
+#define MBTK_BAND_EU_TDLTE_DEFAULT 416          // TDD-LTE : B38/B40/B41
+#define MBTK_BAND_EU_FDDLTE_DEFAULT 134742229   // FDD-LTE : B1/B3/B5/B7/B8/B20/B28
+#define MBTK_BAND_EU_EXT_LTE_DEFAULT 0          // EXT-LTE
+#define MBTK_BAND_SA_GSM_DEFAULT 79             // GSM : B2/B3/B5/B8(GSM 850/PGSM 900/EGSM 900/DCS GSM 1800/PCS GSM 1900)
+#define MBTK_BAND_SA_WCDMA_DEFAULT 155          // WCDMA : B1/B2/B4/B5/B8
+#define MBTK_BAND_SA_TDLTE_DEFAULT 128          // TDD-LTE : B40
+#define MBTK_BAND_SA_FDDLTE_DEFAULT 134217951  // FDD-LTE : B1/B2/B3/B4/B5/B7/B8/B28
+#define MBTK_BAND_SA_EXT_LTE_DEFAULT 2          // EXT-LTE : B66
+
+#define MBTK_DEVICE_INFO_ITEM_STR_BASIC "BASIC"
+#define MBTK_DEVICE_INFO_ITEM_STR_FOTA "FOTA"
+#define MBTK_DEVICE_INFO_ITEM_STR_MODEM "MODEM"
+#define MBTK_DEVICE_INFO_ITEM_STR_LOG "LOG"
+
+#define MBTK_DEVICE_INFO_ITEM_ADDR_BASIC    0x100   // Header is 0x100
+#define MBTK_DEVICE_INFO_ITEM_ADDR_FOTA     0x500   // Basic is 1k
+#define MBTK_DEVICE_INFO_ITEM_ADDR_MODEM    0x900   // Fota is 1k
+#define MBTK_DEVICE_INFO_ITEM_ADDR_LOG      0xD00   // Modem is 1k
+
+typedef enum {
+    MBTK_DEVICE_INFO_ITEM_BASIC = 0,
+    MBTK_DEVICE_INFO_ITEM_FOTA,
+    MBTK_DEVICE_INFO_ITEM_MODEM,
+    MBTK_DEVICE_INFO_ITEM_LOG,
+
+    MBTK_DEVICE_INFO_ITEM_NUM
+} mbtk_device_info_item_enum;
+
+typedef struct {
+    mbtk_device_info_item_enum item;
+    uint32 addr;
+} mbtk_device_info_item_header_t;
+
+typedef struct {
+    uint32 tag;
+    uint32 version;             // Default : 0x01
+    uint32 item_count;
+    mbtk_device_info_item_header_t item_header[MBTK_DEVICE_INFO_ITEM_NUM];
+} mbtk_device_info_header_t;
+
+typedef enum {
+    MBTK_REBOOT_FLAG_NORMAL = 0,
+    MBTK_REBOOT_FLAG_DOWNLOAD,
+    MBTK_REBOOT_FLAG_POWER_OFF,  //Power off and restart
+    MBTK_REBOOT_FLAG_HARDWARE,   //Hardware restart
+    MBTK_REBOOT_FLAG_COMMAND,    //"reboot" "reboot -f" Command restart
+    MBTK_REBOOT_FLAG_ABNORMAL,   //Abnormal restart
+    MBTK_REBOOT_FLAG_UNKNOWN,    //unknown restart
+} mbtk_device_info_reboot_flag_enum;
+
+typedef struct {
+    uint8 name[16];
+    uint32 version;             // Default : 0x01
+    uint8 project[16];          // T108 / L508_X6
+    uint8 project_cust[16];     // T108_C1 / L508_X6_C1  (Refer to: Custom_Model in blf file.)
+    uint32 ab_support;          // 1 for ab
+    mbtk_device_info_reboot_flag_enum reboot_flag;
+    uint8 revision_out[48];     // L508_X6v01.01b04.00
+    uint8 revision_in[64];
+    uint8 build_time[64];
+} mbtk_device_info_basic_t;
+
+typedef struct {
+    uint8 name[16];
+    uint32 version;             // Default : 0x01
+    uint32 state;               //
+} mbtk_device_info_fota_t;
+
+typedef enum {
+    MBTK_MODEM_BAND_AREA_ALL,
+    MBTK_MODEM_BAND_AREA_CN,
+    MBTK_MODEM_BAND_AREA_EU,
+    MBTK_MODEM_BAND_AREA_SA
+} mbtk_modem_band_area_enum;
+
+typedef struct {
+    uint8 name[16];
+    uint32 version;             // Default : 0x01
+    mbtk_modem_band_area_enum band_area;
+    uint32 band_gsm;
+    uint32 band_wcdma;
+    uint32 band_tdlte;
+    uint32 band_fddlte;
+    uint32 band_lte_ext;
+    uint32 net_pref;    // Refor to : mbtk_net_pref_enum
+} mbtk_device_info_modem_t;
+
+typedef struct {
+    uint8 name[16];
+    uint32 version;             // Default : 0x01
+    uint32 state;               //
+} mbtk_device_info_log_t;
+
+
+/*
+* MBTK_DEVICE_INFO_ITEM_BASIC - mbtk_device_info_basic_t
+* MBTK_DEVICE_INFO_ITEM_FOTA - mbtk_device_info_fota_t
+* MBTK_DEVICE_INFO_ITEM_MODEM - mbtk_device_info_modem_t
+* MBTK_DEVICE_INFO_ITEM_LOG - mbtk_device_info_log_t
+*/
+int mbtk_dev_info_read(mbtk_device_info_item_enum item_type, void *item_ptr, int item_size);
+int mbtk_dev_info_write(mbtk_device_info_item_enum item_type, void *item_ptr, int item_size);
+
+#endif /* _MBTK_DEVICE_V2_H */
+
diff --git a/mbtk/include/mbtk/mbtk_ril_api.h b/mbtk/include/mbtk/mbtk_ril_api.h
index 6c3a197..ea00cd0 100755
--- a/mbtk/include/mbtk/mbtk_ril_api.h
+++ b/mbtk/include/mbtk/mbtk_ril_api.h
@@ -261,7 +261,10 @@
     MBTK_NET_PREF_GSM_UMTS_LTE_AUTO,
     MBTK_NET_PREF_GSM_UMTS_LTE_GSM_PREF,
     MBTK_NET_PREF_GSM_UMTS_LTE_UMTS_PREF,
-    MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF
+    MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF,
+
+    // Last item.
+    MBTK_NET_PREF_MAX
 } mbtk_net_pref_enum;
 
 typedef struct
diff --git a/mbtk/libmbtk_lib/common/mbtk_device_info.c b/mbtk/libmbtk_lib/common/mbtk_device_info.c
index 31d9523..d1cb7de 100755
--- a/mbtk/libmbtk_lib/common/mbtk_device_info.c
+++ b/mbtk/libmbtk_lib/common/mbtk_device_info.c
@@ -24,11 +24,17 @@
 #include <mtd/mtd-user.h>
 
 #include "mbtk_type.h"
-#include "mbtk_device.h"
 #include "mbtk_log.h"
 #include "mbtk_str.h"
 #include "mbtk_mtd.h"
 
+#ifdef MBTK_DEV_INFO_VERSION_2
+#include "mbtk_device_v2.h"
+#else
+#include "mbtk_device.h"
+#endif
+
+
 /*
 * MBTK_DEVICE_INFO_ITEM_BASIC - mbtk_device_info_basic_t
 * MBTK_DEVICE_INFO_ITEM_FOTA - mbtk_device_info_fota_t
diff --git a/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h b/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
index efd67fc..97f31b2 100755
--- a/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
+++ b/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
@@ -225,6 +225,7 @@
     // URC message
     RIL_URC_MSG_BEGIN = 0x2000,
     RIL_URC_MSG_GET_SIM_STATE,     //check sim status
+    RIL_URC_MSG_BAND_SET,     // Band set message
     RIL_URC_MSG_NET_STATE_LOG,      // Save Network state into file.
     RIL_URC_MSG_END,
 
diff --git a/mbtk/mbtk_rild_v2/inc/ril_info.h b/mbtk/mbtk_rild_v2/inc/ril_info.h
index 71e6bd7..6dcf807 100755
--- a/mbtk/mbtk_rild_v2/inc/ril_info.h
+++ b/mbtk/mbtk_rild_v2/inc/ril_info.h
@@ -16,7 +16,11 @@
 #include "atchannel.h"
 #include "at_tok.h"
 #include "mbtk_list.h"
+#ifdef MBTK_DEV_INFO_VERSION_2
+#include "mbtk_device_v2.h"
+#else
 #include "mbtk_device.h"
+#endif
 #include "mbtk_queue.h"
 #include "mbtk_ril.h"
 
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index 0068bd3..a17e3d7 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -98,6 +98,7 @@
 

 void data_call_state_change_cb(int cid, bool action, bool auto_change, int reason);

 static int send_pack_to_queue(sock_cli_info_t* cli_info, void* pack);

+int req_band_set(ATPortType_enum port, mbtk_band_info_t* band, int *cme_err);

 

 /* Called on command thread */

 static void onATTimeout()

@@ -2252,9 +2253,10 @@
 

 static void urc_msg_process(ril_urc_msg_info_t *msg)

 {
+    // data can be NULL (For RIL_URC_MSG_BAND_SET)

     if(!msg->data || msg->data_len <= 0) {

-        LOGE("URC data is NULL.");

-        return;

+        LOGW("URC data is NULL.");

+        // return;

     }

 

     switch(msg->msg) {
@@ -2281,6 +2283,30 @@
             data_call_retry(ATPORTTYPE_0, reg_state);

             break;

         }

+        case RIL_URC_MSG_BAND_SET:

+        {

+            int cme_err = MBTK_RIL_ERR_CME_NON;

+            if(req_band_set(ATPORTTYPE_0, &band_info.band_support, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)

+            {

+                LOGE("Set band fail.");

+            }

+            else // Set band success.

+            {

+                // log_hex("BAND-2", &band_set_info, sizeof(band_set_info_t));

+                band_info.band_set_success = TRUE;

+                if(band_info.band_area == MBTK_MODEM_BAND_AREA_CN) {

+                    property_set("persist.mbtk.band_config", "CN");

+                } else if(band_info.band_area == MBTK_MODEM_BAND_AREA_EU) {

+                    property_set("persist.mbtk.band_config", "EU");

+                } else if(band_info.band_area == MBTK_MODEM_BAND_AREA_SA) {

+                    property_set("persist.mbtk.band_config", "SA");

+                } else {

+                    property_set("persist.mbtk.band_config", "ALL");

+                }

+                LOGD("Set band success.");

+            }

+            break;

+        }

         default:
         {
             LOGE("Unknown URC : %d", msg->msg);
@@ -2506,7 +2532,7 @@
     if(mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_MODEM, &(info_modem), sizeof(mbtk_device_info_modem_t))) {
         LOGD("mbtk_dev_info_read(MODEM) fail, use default band.");
         band_info.band_area = MBTK_MODEM_BAND_AREA_ALL;

-        band_info.band_support.net_pref = MBTK_NET_PREF_UNUSE;

+        band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF;  // 15

         band_info.band_support.gsm_band = MBTK_BAND_ALL_GSM_DEFAULT;

         band_info.band_support.umts_band = MBTK_BAND_ALL_WCDMA_DEFAULT;

         band_info.band_support.tdlte_band = MBTK_BAND_ALL_TDLTE_DEFAULT;

@@ -2514,7 +2540,15 @@
         band_info.band_support.lte_ext_band = MBTK_BAND_ALL_EXT_LTE_DEFAULT;

     } else {
         band_info.band_area = info_modem.band_area;

-        band_info.band_support.net_pref = MBTK_NET_PREF_UNUSE;

+#ifdef MBTK_DEV_INFO_VERSION_2		

+        if(info_modem.net_pref < MBTK_NET_PREF_MAX) {

+            band_info.band_support.net_pref = info_modem.net_pref;

+        } else {

+            band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF;  // 15

+        }

+#else

+		band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF;  // 15

+#endif

         band_info.band_support.gsm_band = info_modem.band_gsm;

         band_info.band_support.umts_band = info_modem.band_wcdma;

         band_info.band_support.tdlte_band = info_modem.band_tdlte;

@@ -2525,24 +2559,24 @@
 //    bool is_first = TRUE;

     while(!band_info.band_set_success) {

         // Set band.

+#if 1

+        ril_urc_msg_info_t *msg = (ril_urc_msg_info_t*)malloc(sizeof(ril_urc_msg_info_t));

+        if(msg) {

+            msg->msg = RIL_URC_MSG_BAND_SET;

+            msg->data = NULL;//mbtk_memcpy(&band_info, sizeof(ril_band_info_t));

+            msg->data_len = 0; //sizeof(ril_band_info_t);

 #if 0

-        info_urc_msg_t *urc = (info_urc_msg_t*)malloc(sizeof(info_urc_msg_t));
-        if(!urc)
-        {
-            LOG("malloc() fail[%d].", errno);
-            break;
-        } else {
-            urc->msg = INFO_URC_MSG_SET_BAND;
-            urc->data = NULL;
-            urc->data_len = 0;
-            send_pack_to_queue(NULL, urc);
-
-            if(is_first) {
-                is_first = FALSE;
-            } else {
-                LOGE("*BAND exec error, will retry in 5s.");
+            if(msg->data == NULL) {
+                LOGE("mbtk_memcpy() fail.");
+                break;
             }
+#endif

+            send_pack_to_queue(NULL, msg);

+

             sleep(5);
+        } else {

+            LOG("malloc() fail[%d].", errno);

+            break;

         }

 #else

         sleep(5);

diff --git a/mbtk/mbtk_rild_v2/src/ril_net.c b/mbtk/mbtk_rild_v2/src/ril_net.c
index fc381f4..502d49e 100755
--- a/mbtk/mbtk_rild_v2/src/ril_net.c
+++ b/mbtk/mbtk_rild_v2/src/ril_net.c
@@ -252,7 +252,7 @@
 OK
 
 */
-static int req_band_set(ATPortType_enum port, mbtk_band_info_t* band, int *cme_err)
+int req_band_set(ATPortType_enum port, mbtk_band_info_t* band, int *cme_err)
 {
     ATResponse *response = NULL;
     char cmd[100] = {0};
diff --git a/mbtk/mbtk_utils/device_info.c b/mbtk/mbtk_utils/device_info.c
index 864cb36..73bc0d1 100755
--- a/mbtk/mbtk_utils/device_info.c
+++ b/mbtk/mbtk_utils/device_info.c
@@ -1,6 +1,12 @@
 #include <string.h>
 #include "mbtk_type.h"
+
+#ifdef MBTK_DEV_INFO_VERSION_2
+#include "mbtk_device_v2.h"
+#else
 #include "mbtk_device.h"
+#endif
+
 
 static char* band_2_str(mbtk_modem_band_area_enum band_area)
 {
diff --git a/mbtk/mbtk_utils/mbtk_reboot.c b/mbtk/mbtk_utils/mbtk_reboot.c
index d839ae6..3a85294 100755
--- a/mbtk/mbtk_utils/mbtk_reboot.c
+++ b/mbtk/mbtk_utils/mbtk_reboot.c
@@ -1,6 +1,10 @@
 #include <string.h>
 #include "mbtk_type.h"
+#ifdef MBTK_DEV_INFO_VERSION_2
+#include "mbtk_device_v2.h"
+#else
 #include "mbtk_device.h"
+#endif
 #include "mbtk_utils.h"
 #if 0
 static char* band_2_str(mbtk_modem_band_area_enum band_area)
diff --git a/mbtk/mbtk_utils_linux/Makefile b/mbtk/mbtk_utils_linux/Makefile
index 61d3770..6683eb2 100755
--- a/mbtk/mbtk_utils_linux/Makefile
+++ b/mbtk/mbtk_utils_linux/Makefile
@@ -1,7 +1,9 @@
 BUILD_ROOT = $(shell pwd)/..
 include $(BUILD_ROOT)/Make.defines
 
-
+ifeq ($(MBTK_DEV_INFO_VERSION), 2)
+DEFINE = -DMBTK_DEV_INFO_VERSION_2
+endif
 
 INC_DIR += \
 		-I$(LOCAL_PATH)
@@ -19,13 +21,13 @@
 
 $(BINS):$(OBJS)
 	@echo "  BIN     $@"
-	$(CC) $@.o -o $(OUT_DIR)/bin/$@
+	$(CC) $@.o $(DEFINE) -o $(OUT_DIR)/bin/$@
 
 %.o:%.c
-	$(CC) $(INC_DIR) -c $< -o $@
+	$(CC) $(INC_DIR) $(DEFINE) -c $< -o $@
 
 %.o:%.cpp
-	$(CC) $(INC_DIR) -c $< -o $@
+	$(CC) $(INC_DIR) $(DEFINE) -c $< -o $@
 
 clean:
 	rm -f $(OBJS) $(BINS)
diff --git a/mbtk/mbtk_utils_linux/device_info_generate.c b/mbtk/mbtk_utils_linux/device_info_generate.c
index fda756f..4da38c1 100755
--- a/mbtk/mbtk_utils_linux/device_info_generate.c
+++ b/mbtk/mbtk_utils_linux/device_info_generate.c
@@ -8,17 +8,30 @@
 #include <fcntl.h>
 
 #include "mbtk_type.h"
+
+#ifdef MBTK_DEV_INFO_VERSION_2
+#include "mbtk_device_v2.h"
+#else
 #include "mbtk_device.h"
+#endif
+
 
 static mbtk_device_info_header_t info_header = {
     .tag = MBTK_DEVICE_INFO_PARTITION_TAG,
     .version = MBTK_DEVICE_INFO_CURR_VERSION,
     .item_count = MBTK_DEVICE_INFO_ITEM_NUM,
     .item_header = {
+#ifdef MBTK_DEV_INFO_VERSION_2
+        {MBTK_DEVICE_INFO_ITEM_BASIC, MBTK_DEVICE_INFO_ITEM_ADDR_BASIC},
+        {MBTK_DEVICE_INFO_ITEM_FOTA, MBTK_DEVICE_INFO_ITEM_ADDR_FOTA},
+        {MBTK_DEVICE_INFO_ITEM_MODEM, MBTK_DEVICE_INFO_ITEM_ADDR_MODEM},
+        {MBTK_DEVICE_INFO_ITEM_LOG, MBTK_DEVICE_INFO_ITEM_ADDR_LOG},
+#else
         {MBTK_DEVICE_INFO_ITEM_BASIC, 0},
         {MBTK_DEVICE_INFO_ITEM_FOTA, 0},
         {MBTK_DEVICE_INFO_ITEM_MODEM, 0},
         {MBTK_DEVICE_INFO_ITEM_LOG, 0},
+#endif
     }
 };
 
@@ -59,15 +72,23 @@
 
 static void help()
 {
+#ifdef MBTK_DEV_INFO_VERSION_2
+    printf("device_info_generate -a [a/ab] -b [revision_out] -c [revision_in] -d [project] -e [project_cust] -f [cn/eu/all] -g [build_time] -h [net_pref] -o [out_bin]\n");
+#else
     printf("device_info_generate -a [a/ab] -b [revision_out] -c [revision_in] -d [project] -e [project_cust] -f [cn/eu/all] -g [build_time] -o [out_bin]\n");
+#endif
 }
 
 static int update_and_write_header(int fd, mbtk_device_info_header_t *header)
 {
+#ifdef MBTK_DEV_INFO_VERSION_2
+
+#else
     header->item_header[MBTK_DEVICE_INFO_ITEM_BASIC].addr = sizeof(mbtk_device_info_header_t);
     header->item_header[MBTK_DEVICE_INFO_ITEM_FOTA].addr = header->item_header[MBTK_DEVICE_INFO_ITEM_BASIC].addr + sizeof(mbtk_device_info_basic_t);
     header->item_header[MBTK_DEVICE_INFO_ITEM_MODEM].addr = header->item_header[MBTK_DEVICE_INFO_ITEM_FOTA].addr + sizeof(mbtk_device_info_fota_t);
     header->item_header[MBTK_DEVICE_INFO_ITEM_LOG].addr = header->item_header[MBTK_DEVICE_INFO_ITEM_MODEM].addr + sizeof(mbtk_device_info_modem_t);
+#endif
 
     if(sizeof(mbtk_device_info_header_t) != write(fd, header, sizeof(mbtk_device_info_header_t))) {
         printf("Write header fail:%d\n", errno);
@@ -126,7 +147,11 @@
 {
     int ch;
     char out_bin[128] = {0};
+#ifdef MBTK_DEV_INFO_VERSION_2
+    while((ch = getopt(argc, argv, "a:b:c:d:e:f:g:h:o:"))!= -1){
+#else
     while((ch = getopt(argc, argv, "a:b:c:d:e:f:g:o:"))!= -1){
+#endif
         switch(ch)
         {
             case 'a':
@@ -187,6 +212,12 @@
                     printf("Set to default band.\n");
                 }
                 break;
+#ifdef MBTK_DEV_INFO_VERSION_2
+            case 'h':
+                item_modem.net_pref = (uint32)atoi(optarg);
+                printf("Set net_pref to %d success.\n", item_modem.net_pref);
+                break;
+#endif
             case 'g':
                 if(strlen(optarg) > 0)
                     memcpy(item_basic.build_time, optarg, strlen(optarg));
diff --git a/mbtk/mbtk_utils_linux/ota_update.c b/mbtk/mbtk_utils_linux/ota_update.c
index d064e1b..dbc7bd0 100755
--- a/mbtk/mbtk_utils_linux/ota_update.c
+++ b/mbtk/mbtk_utils_linux/ota_update.c
@@ -7,7 +7,12 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include "mbtk_type.h"
+
+#ifdef MBTK_DEV_INFO_VERSION_2
+#include "mbtk_device_v2.h"
+#else
 #include "mbtk_device.h"
+#endif
 
 /*
 * revision_out start from 0x1000.