Fix device_info for v1/v2.
Change-Id: I77c1da11f042bf2523d5768b18c18b9a0e1e0c6e
diff --git a/mbtk/include/mbtk/mbtk_device.h b/mbtk/include/mbtk/mbtk_device.h
index f7e7cef..b2f1729 100755
--- a/mbtk/include/mbtk/mbtk_device.h
+++ b/mbtk/include/mbtk/mbtk_device.h
@@ -6,17 +6,15 @@
* Author : lb
* Date : 2023/12/30 11:36:35
*/
-#ifndef _MBTK_DEVICE_V2_H
-#define _MBTK_DEVICE_V2_H
+#ifndef _MBTK_DEVICE_H
+#define _MBTK_DEVICE_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
+#define MBTK_DEV_INFO_PARTITION_ADDR 0x005C0000
-// 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.
@@ -27,45 +25,11 @@
#define MBTK_BAND_ALL_NR_1_DEFAULT 256 // n41
#define MBTK_BAND_ALL_NR_0_DEFAULT 134217877 // n1/n3/n5/n8/n28
-#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_CN_NR_3_DEFAULT 0
-#define MBTK_BAND_CN_NR_2_DEFAULT 24576 // n78/n79
-#define MBTK_BAND_CN_NR_1_DEFAULT 384 // n40/n41
-#define MBTK_BAND_CN_NR_0_DEFAULT 134217877 // n1/n3/n5/n8/n28
-
-#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_EU_NR_3_DEFAULT 0
-#define MBTK_BAND_EU_NR_2_DEFAULT 12352 // n71/n77/n78
-#define MBTK_BAND_EU_NR_1_DEFAULT 416 // n38/n40/n41
-#define MBTK_BAND_EU_NR_0_DEFAULT 134742229 // n1/n3/n5/n7/n8/n20/n28
-
-#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_BAND_SA_NR_3_DEFAULT MBTK_BAND_ALL_NR_3_DEFAULT
-#define MBTK_BAND_SA_NR_2_DEFAULT MBTK_BAND_ALL_NR_2_DEFAULT
-#define MBTK_BAND_SA_NR_1_DEFAULT MBTK_BAND_ALL_NR_1_DEFAULT
-#define MBTK_BAND_SA_NR_0_DEFAULT MBTK_BAND_ALL_NR_0_DEFAULT
-
#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
#define MBTK_NET_SUPPORT_2G (1)
#define MBTK_NET_SUPPORT_3G (1<<1)
@@ -94,6 +58,11 @@
} mbtk_device_info_header_t;
typedef enum {
+ DEV_INFO_VERSION_V1 = 1,
+ DEV_INFO_VERSION_V2,
+} mbtk_device_info_version_enum;
+
+typedef enum {
MBTK_REBOOT_FLAG_NORMAL = 0,
MBTK_REBOOT_FLAG_DOWNLOAD,
MBTK_REBOOT_FLAG_POWER_OFF, //Power off and restart
@@ -113,13 +82,41 @@
uint8 revision_out[48]; // L508_X6v01.01b04.00
uint8 revision_in[64];
uint8 build_time[64];
- uint8 asr_baseline[64];
+} mbtk_device_info_basic_v1_t;
+
+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];
+ uint8 asr_baseline[128];
+} mbtk_device_info_basic_v2_t;
+
+typedef struct {
+ mbtk_device_info_version_enum version;
+ union {
+ mbtk_device_info_basic_v1_t v1;
+ mbtk_device_info_basic_v2_t v2;
+ } basic;
} mbtk_device_info_basic_t;
typedef struct {
uint8 name[16];
uint32 version; // Default : 0x01
uint32 state; //
+} mbtk_device_info_fota_v1_t, mbtk_device_info_fota_v2_t;
+
+typedef struct {
+ mbtk_device_info_version_enum version;
+ union {
+ mbtk_device_info_fota_v1_t v1;
+ mbtk_device_info_fota_v2_t v2;
+ } fota;
} mbtk_device_info_fota_t;
typedef enum {
@@ -133,6 +130,17 @@
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;
+} mbtk_device_info_modem_v1_t;
+
+typedef struct {
+ uint8 name[16];
+ uint32 version; // Default : 0x01
+ mbtk_modem_band_area_enum band_area;
uint32 net_pref; // Refor to : mbtk_net_pref_enum
uint32 net_support; // 1:GSM 2:WCDMA 4:LTE 8:NR
uint32 band_gsm;
@@ -144,25 +152,33 @@
uint32 band_nr_2;
uint32 band_nr_1;
uint32 band_nr_0;
+} mbtk_device_info_modem_v2_t;
+
+typedef struct {
+ mbtk_device_info_version_enum version;
+ union {
+ mbtk_device_info_modem_v1_t v1;
+ mbtk_device_info_modem_v2_t v2;
+ } modem;
} mbtk_device_info_modem_t;
typedef struct {
uint8 name[16];
uint32 version; // Default : 0x01
uint32 state; //
+} mbtk_device_info_log_v1_t, mbtk_device_info_log_v2_t;
+
+typedef struct {
+ mbtk_device_info_version_enum version;
+ union {
+ mbtk_device_info_log_v1_t v1;
+ mbtk_device_info_log_v2_t v2;
+ } log;
} 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);
int mbtk_dev_info_revision_get(char *revision_out, char *revision_in, char *project_cust, char *band_area,
char* build_time);
-#endif /* _MBTK_DEVICE_V2_H */
-
+#endif /* _MBTK_DEVICE_H */
diff --git a/mbtk/libmbtk_lib/common/mbtk_device_info.c b/mbtk/libmbtk_lib/common/mbtk_device_info.c
index 670a320..3924297 100755
--- a/mbtk/libmbtk_lib/common/mbtk_device_info.c
+++ b/mbtk/libmbtk_lib/common/mbtk_device_info.c
@@ -42,46 +42,6 @@
mbtk_device_info_header_t info_header;
memset(&info_header, 0, sizeof(mbtk_device_info_header_t));
- switch(item_type) {
- case MBTK_DEVICE_INFO_ITEM_BASIC:
- {
- if(item_ptr == NULL || item_size != sizeof(mbtk_device_info_basic_t)) {
- LOGE("ARG error:item-%d, item_size-%d", item_type, item_size);
- return -1;
- }
- break;
- }
- case MBTK_DEVICE_INFO_ITEM_FOTA:
- {
- if(item_ptr == NULL || item_size != sizeof(mbtk_device_info_fota_t)) {
- LOGE("ARG error:item-%d, item_size-%d", item_type, item_size);
- return -1;
- }
- break;
- }
- case MBTK_DEVICE_INFO_ITEM_MODEM:
- {
- if(item_ptr == NULL || item_size != sizeof(mbtk_device_info_modem_t)) {
- LOGE("ARG error:item-%d, item_size-%d", item_type, item_size);
- return -1;
- }
- break;
- }
- case MBTK_DEVICE_INFO_ITEM_LOG:
- {
- if(item_ptr == NULL || item_size != sizeof(mbtk_device_info_log_t)) {
- LOGE("ARG error:item-%d, item_size-%d", item_type, item_size);
- return -1;
- }
- break;
- }
- default:
- {
- LOGE("Item type[%d] error.", item_type);
- return -1;
- }
- }
-
mbtk_partition_info_t *partition_info = mbtk_partition_get();
if(partition_info == NULL) {
LOGE("mbtk_partition_get() fail.");
@@ -121,12 +81,7 @@
goto fail;
}
- if(info_header.version != MBTK_DEVICE_INFO_CURR_VERSION) {
- LOGE("Version error : %d", info_header.version);
- goto fail;
- }
-
- LOGD("Item count:%d", info_header.item_count);
+ LOGD("Dev info version : %d, Item count:%d", info_header.version, info_header.item_count);
if(info_header.item_header[item_type].addr == 0) {
LOGE("No found item : %d", item_type);
@@ -134,9 +89,110 @@
}
lseek(fd, info_header.item_header[item_type].addr, SEEK_SET);
- if (read(fd, item_ptr, item_size) != item_size) {
- LOGE("Read fail:%d", errno);
- goto fail;
+
+
+ switch(item_type) {
+ case MBTK_DEVICE_INFO_ITEM_BASIC:
+ {
+ if(item_ptr == NULL || item_size != sizeof(mbtk_device_info_basic_t)) {
+ LOGE("ARG error:item-%d, item_size-%d", item_type, item_size);
+ goto fail;
+ }
+
+ mbtk_device_info_basic_t *basic_ptr = (mbtk_device_info_basic_t*)item_ptr;
+ basic_ptr->version = (mbtk_device_info_version_enum)info_header.version;
+ if(basic_ptr->version == DEV_INFO_VERSION_V1) {
+ if (read(fd, &(basic_ptr->basic.v1), sizeof(mbtk_device_info_basic_v1_t)) !=
+ sizeof(mbtk_device_info_basic_v1_t)) {
+ LOGE("Read fail:%d", errno);
+ goto fail;
+ }
+ } else {
+ if (read(fd, &(basic_ptr->basic.v2), sizeof(mbtk_device_info_basic_v2_t)) !=
+ sizeof(mbtk_device_info_basic_v2_t)) {
+ LOGE("Read fail:%d", errno);
+ goto fail;
+ }
+ }
+ break;
+ }
+ case MBTK_DEVICE_INFO_ITEM_FOTA:
+ {
+ if(item_ptr == NULL || item_size != sizeof(mbtk_device_info_fota_t)) {
+ LOGE("ARG error:item-%d, item_size-%d", item_type, item_size);
+ goto fail;
+ }
+
+ mbtk_device_info_fota_t *fota_ptr = (mbtk_device_info_fota_t*)item_ptr;
+ fota_ptr->version = (mbtk_device_info_version_enum)info_header.version;
+ if(fota_ptr->version == DEV_INFO_VERSION_V1) {
+ if (read(fd, &(fota_ptr->fota.v1), sizeof(mbtk_device_info_fota_v1_t)) !=
+ sizeof(mbtk_device_info_fota_v1_t)) {
+ LOGE("Read fail:%d", errno);
+ goto fail;
+ }
+ } else {
+ if (read(fd, &(fota_ptr->fota.v2), sizeof(mbtk_device_info_fota_v2_t)) !=
+ sizeof(mbtk_device_info_fota_v2_t)) {
+ LOGE("Read fail:%d", errno);
+ goto fail;
+ }
+ }
+ break;
+ }
+ case MBTK_DEVICE_INFO_ITEM_MODEM:
+ {
+ if(item_ptr == NULL || item_size != sizeof(mbtk_device_info_modem_t)) {
+ LOGE("ARG error:item-%d, item_size-%d", item_type, item_size);
+ goto fail;
+ }
+
+ mbtk_device_info_modem_t *modem_ptr = (mbtk_device_info_modem_t*)item_ptr;
+ modem_ptr->version = (mbtk_device_info_version_enum)info_header.version;
+ if(modem_ptr->version == DEV_INFO_VERSION_V1) {
+ if (read(fd, &(modem_ptr->modem.v1), sizeof(mbtk_device_info_modem_v1_t)) !=
+ sizeof(mbtk_device_info_modem_v1_t)) {
+ LOGE("Read fail:%d", errno);
+ goto fail;
+ }
+ } else {
+ if (read(fd, &(modem_ptr->modem.v2), sizeof(mbtk_device_info_modem_v2_t)) !=
+ sizeof(mbtk_device_info_modem_v2_t)) {
+ LOGE("Read fail:%d", errno);
+ goto fail;
+ }
+ }
+ break;
+ }
+ case MBTK_DEVICE_INFO_ITEM_LOG:
+ {
+ if(item_ptr == NULL || item_size != sizeof(mbtk_device_info_log_t)) {
+ LOGE("ARG error:item-%d, item_size-%d", item_type, item_size);
+ goto fail;
+ }
+
+ mbtk_device_info_log_t *log_ptr = (mbtk_device_info_log_t*)item_ptr;
+ log_ptr->version = (mbtk_device_info_version_enum)info_header.version;
+ if(log_ptr->version == DEV_INFO_VERSION_V1) {
+ if (read(fd, &(log_ptr->log.v1), sizeof(mbtk_device_info_log_v1_t)) !=
+ sizeof(mbtk_device_info_log_v1_t)) {
+ LOGE("Read fail:%d", errno);
+ goto fail;
+ }
+ } else {
+ if (read(fd, &(log_ptr->log.v2), sizeof(mbtk_device_info_log_v2_t)) !=
+ sizeof(mbtk_device_info_log_v2_t)) {
+ LOGE("Read fail:%d", errno);
+ goto fail;
+ }
+ }
+ break;
+ }
+ default:
+ {
+ LOGE("Item type[%d] error.", item_type);
+ goto fail;
+ }
}
close(fd);
@@ -154,49 +210,9 @@
return -1;
}
- switch(item_type) {
- case MBTK_DEVICE_INFO_ITEM_BASIC:
- {
- if(item_size != sizeof(mbtk_device_info_basic_t)) {
- LOGE("item_size != sizeof(mbtk_device_info_basic_t)\n\r");
- return -1;
- }
- break;
- }
- case MBTK_DEVICE_INFO_ITEM_FOTA:
- {
- if(item_size != sizeof(mbtk_device_info_fota_t)) {
- LOGE("item_size != sizeof(mbtk_device_info_fota_t)\n\r");
- return -1;
- }
- break;
- }
- case MBTK_DEVICE_INFO_ITEM_MODEM:
- {
- if(item_size != sizeof(mbtk_device_info_modem_t)) {
- LOGE("item_size != sizeof(mbtk_device_info_modem_t)\n\r");
- return -1;
- }
- break;
- }
- case MBTK_DEVICE_INFO_ITEM_LOG:
- {
- if(item_size != sizeof(mbtk_device_info_log_t)) {
- LOGE("item_size != sizeof(mbtk_device_info_log_t)\n\r");
- return -1;
- }
- break;
- }
- default:
- {
- LOGE("Item type[%d] error.\n\r", item_type);
- return -1;
- }
- }
-
mbtk_partition_info_t info;
memset(&info, 0x0, sizeof(mbtk_partition_info_t));
- if(mbtk_partition_get_by_name("device_info", &info)) {
+ if(mbtk_partition_get_by_name(MBTK_DEVICE_INFO_PARTITION_NAME, &info)) {
LOGE("mbtk_partition_get_by_name() fail.");
return -1;
}
@@ -218,7 +234,7 @@
char *mtd_buff = (char*)malloc(info.erase_size);
if(mtd_buff == NULL) {
LOGE("malloc() failed\n");
- return -1;
+ return -1;
}
memset(mtd_buff, 0xFF, info.erase_size);
int len = read(fd, mtd_buff, info.erase_size);
@@ -240,7 +256,101 @@
ioctl(fd, MEMERASE, &mtdEraseInfo);
mbtk_device_info_header_t *info_header = (mbtk_device_info_header_t*)mtd_buff;
- memcpy(mtd_buff + info_header->item_header[item_type].addr, item_ptr, item_size);
+ switch(item_type) {
+ case MBTK_DEVICE_INFO_ITEM_BASIC:
+ {
+ if(item_size != sizeof(mbtk_device_info_basic_t)) {
+ LOGE("item_size != sizeof(mbtk_device_info_basic_t)\n\r");
+ goto fail;
+ }
+
+ mbtk_device_info_basic_t *basic_ptr = (mbtk_device_info_basic_t*)item_ptr;
+ if(info_header->version != basic_ptr->version) {
+ LOGE("basic version error.");
+ goto fail;
+ }
+
+ if(basic_ptr->version == DEV_INFO_VERSION_V1) {
+ memcpy(mtd_buff + info_header->item_header[item_type].addr, &(basic_ptr->basic.v1),
+ sizeof(mbtk_device_info_basic_v1_t));
+ } else {
+ memcpy(mtd_buff + info_header->item_header[item_type].addr, &(basic_ptr->basic.v2),
+ sizeof(mbtk_device_info_basic_v2_t));
+ }
+ break;
+ }
+ case MBTK_DEVICE_INFO_ITEM_FOTA:
+ {
+ if(item_size != sizeof(mbtk_device_info_fota_t)) {
+ LOGE("item_size != sizeof(mbtk_device_info_fota_t)\n\r");
+ goto fail;
+ }
+
+ mbtk_device_info_fota_t *fota_ptr = (mbtk_device_info_fota_t*)item_ptr;
+ if(info_header->version != fota_ptr->version) {
+ LOGE("fota version error.");
+ goto fail;
+ }
+
+ if(fota_ptr->version == DEV_INFO_VERSION_V1) {
+ memcpy(mtd_buff + info_header->item_header[item_type].addr, &(fota_ptr->fota.v1),
+ sizeof(mbtk_device_info_fota_v1_t));
+ } else {
+ memcpy(mtd_buff + info_header->item_header[item_type].addr, &(fota_ptr->fota.v2),
+ sizeof(mbtk_device_info_fota_v2_t));
+ }
+ break;
+ }
+ case MBTK_DEVICE_INFO_ITEM_MODEM:
+ {
+ if(item_size != sizeof(mbtk_device_info_modem_t)) {
+ LOGE("item_size != sizeof(mbtk_device_info_modem_t)\n\r");
+ goto fail;
+ }
+
+ mbtk_device_info_modem_t *modem_ptr = (mbtk_device_info_modem_t*)item_ptr;
+ if(info_header->version != modem_ptr->version) {
+ LOGE("modem version error.");
+ goto fail;
+ }
+
+ if(modem_ptr->version == DEV_INFO_VERSION_V1) {
+ memcpy(mtd_buff + info_header->item_header[item_type].addr, &(modem_ptr->modem.v1),
+ sizeof(mbtk_device_info_modem_v1_t));
+ } else {
+ memcpy(mtd_buff + info_header->item_header[item_type].addr, &(modem_ptr->modem.v2),
+ sizeof(mbtk_device_info_modem_v2_t));
+ }
+ break;
+ }
+ case MBTK_DEVICE_INFO_ITEM_LOG:
+ {
+ if(item_size != sizeof(mbtk_device_info_log_t)) {
+ LOGE("item_size != sizeof(mbtk_device_info_log_t)\n\r");
+ goto fail;
+ }
+
+ mbtk_device_info_log_t *log_ptr = (mbtk_device_info_log_t*)item_ptr;
+ if(info_header->version != log_ptr->version) {
+ LOGE("log version error.");
+ goto fail;
+ }
+
+ if(log_ptr->version == DEV_INFO_VERSION_V1) {
+ memcpy(mtd_buff + info_header->item_header[item_type].addr, &(log_ptr->log.v1),
+ sizeof(mbtk_device_info_log_v1_t));
+ } else {
+ memcpy(mtd_buff + info_header->item_header[item_type].addr, &(log_ptr->log.v2),
+ sizeof(mbtk_device_info_log_v2_t));
+ }
+ break;
+ }
+ default:
+ {
+ LOGE("Item type[%d] error.\n\r", item_type);
+ goto fail;
+ }
+ }
lseek(fd, 0, SEEK_SET);
if (write(fd, mtd_buff, info.erase_size) != info.erase_size) {
@@ -279,20 +389,40 @@
return -1;
}
- if(strlen((char*)info_basic.revision_out) > 0) {
- memcpy(revision_out, info_basic.revision_out, strlen((char*)info_basic.revision_out));
- }
- if(strlen((char*)info_basic.revision_in) > 0) {
- memcpy(revision_in, info_basic.revision_in, strlen((char*)info_basic.revision_in));
- }
- if(strlen((char*)info_basic.project_cust) > 0) {
- memcpy(project_cust, info_basic.project_cust, strlen((char*)info_basic.project_cust));
- }
- if(strlen((char*)info_basic.build_time) > 0) {
- memcpy(build_time, info_basic.build_time, strlen((char*)info_basic.build_time));
+ mbtk_modem_band_area_enum modem_band_area = MBTK_MODEM_BAND_AREA_ALL;
+ if(info_basic.version == DEV_INFO_VERSION_V1) {
+ if(strlen((char*)info_basic.basic.v1.revision_out) > 0) {
+ memcpy(revision_out, info_basic.basic.v1.revision_out, strlen((char*)info_basic.basic.v1.revision_out));
+ }
+ if(strlen((char*)info_basic.basic.v1.revision_in) > 0) {
+ memcpy(revision_in, info_basic.basic.v1.revision_in, strlen((char*)info_basic.basic.v1.revision_in));
+ }
+ if(strlen((char*)info_basic.basic.v1.project_cust) > 0) {
+ memcpy(project_cust, info_basic.basic.v1.project_cust, strlen((char*)info_basic.basic.v1.project_cust));
+ }
+ if(strlen((char*)info_basic.basic.v1.build_time) > 0) {
+ memcpy(build_time, info_basic.basic.v1.build_time, strlen((char*)info_basic.basic.v1.build_time));
+ }
+
+ modem_band_area = info_modem.modem.v1.band_area;
+ } else {
+ if(strlen((char*)info_basic.basic.v2.revision_out) > 0) {
+ memcpy(revision_out, info_basic.basic.v2.revision_out, strlen((char*)info_basic.basic.v2.revision_out));
+ }
+ if(strlen((char*)info_basic.basic.v2.revision_in) > 0) {
+ memcpy(revision_in, info_basic.basic.v2.revision_in, strlen((char*)info_basic.basic.v2.revision_in));
+ }
+ if(strlen((char*)info_basic.basic.v2.project_cust) > 0) {
+ memcpy(project_cust, info_basic.basic.v2.project_cust, strlen((char*)info_basic.basic.v2.project_cust));
+ }
+ if(strlen((char*)info_basic.basic.v2.build_time) > 0) {
+ memcpy(build_time, info_basic.basic.v2.build_time, strlen((char*)info_basic.basic.v2.build_time));
+ }
+
+ modem_band_area = info_modem.modem.v2.band_area;
}
- switch(info_modem.band_area) {
+ switch(modem_band_area) {
case MBTK_MODEM_BAND_AREA_CN:
memcpy(band_area, "CN", 2);
break;
diff --git a/mbtk/mbtk_rild/src/mbtk_info_server.c b/mbtk/mbtk_rild/src/mbtk_info_server.c
index ad01378..7a51c7e 100755
--- a/mbtk/mbtk_rild/src/mbtk_info_server.c
+++ b/mbtk/mbtk_rild/src/mbtk_info_server.c
@@ -7340,12 +7340,21 @@
band_set_info.band_fddlte = MBTK_BAND_ALL_FDDLTE_DEFAULT;
band_set_info.band_lte_ext = MBTK_BAND_ALL_EXT_LTE_DEFAULT;
} else {
- band_area = info_modem.band_area;
- band_set_info.band_gsm = info_modem.band_gsm;
- band_set_info.band_wcdma = info_modem.band_wcdma;
- band_set_info.band_tdlte = info_modem.band_tdlte;
- band_set_info.band_fddlte = info_modem.band_fddlte;
- band_set_info.band_lte_ext = info_modem.band_lte_ext;
+ if(info_modem.version == DEV_INFO_VERSION_V1) {
+ band_area = info_modem.modem.v1.band_area;
+ band_set_info.band_gsm = info_modem.modem.v1.band_gsm;
+ band_set_info.band_wcdma = info_modem.modem.v1.band_wcdma;
+ band_set_info.band_tdlte = info_modem.modem.v1.band_tdlte;
+ band_set_info.band_fddlte = info_modem.modem.v1.band_fddlte;
+ band_set_info.band_lte_ext = info_modem.modem.v1.band_lte_ext;
+ } else {
+ band_area = info_modem.modem.v2.band_area;
+ band_set_info.band_gsm = info_modem.modem.v2.band_gsm;
+ band_set_info.band_wcdma = info_modem.modem.v2.band_wcdma;
+ band_set_info.band_tdlte = info_modem.modem.v2.band_tdlte;
+ band_set_info.band_fddlte = info_modem.modem.v2.band_fddlte;
+ band_set_info.band_lte_ext = info_modem.modem.v2.band_lte_ext;
+ }
}
bool is_first = TRUE;
@@ -7392,10 +7401,15 @@
}
else
{
- reboot_reason = info_basic.reboot_flag;
- if(info_basic.reboot_flag != MBTK_REBOOT_FLAG_NORMAL)
+ reboot_reason = info_basic.version == DEV_INFO_VERSION_V1 ? info_basic.basic.v1.reboot_flag :
+ info_basic.basic.v2.reboot_flag;
+ if(reboot_reason != MBTK_REBOOT_FLAG_NORMAL)
{
- info_basic.reboot_flag = MBTK_REBOOT_FLAG_NORMAL;
+ if(info_basic.version == DEV_INFO_VERSION_V1) {
+ info_basic.basic.v1.reboot_flag = MBTK_REBOOT_FLAG_NORMAL;
+ } else {
+ info_basic.basic.v2.reboot_flag = MBTK_REBOOT_FLAG_NORMAL;
+ }
ret = mbtk_dev_info_write(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t));
if(ret != 0) {
LOGE("[%s] mbtk_dev_info_write(BASIC) fail.", __func__);
diff --git a/mbtk/mbtk_rild_v2/src/main.c b/mbtk/mbtk_rild_v2/src/main.c
index ae286cc..c4befdf 100755
--- a/mbtk/mbtk_rild_v2/src/main.c
+++ b/mbtk/mbtk_rild_v2/src/main.c
@@ -2910,27 +2910,37 @@
band_info.band_support.nr_0_band = 0;
#endif
} else {
- band_info.band_area = info_modem.band_area;
- band_info.net_support = info_modem.net_support;
- if(info_modem.net_pref < MBTK_NET_PREF_MAX) {
- band_info.band_support.net_pref = info_modem.net_pref;
+ if(info_modem.version == DEV_INFO_VERSION_V1) {
+ band_info.band_area = info_modem.modem.v1.band_area;
+ band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF; // 15
+ band_info.band_support.gsm_band = info_modem.modem.v1.band_gsm;
+ band_info.band_support.umts_band = info_modem.modem.v1.band_wcdma;
+ band_info.band_support.tdlte_band = info_modem.modem.v1.band_tdlte;
+ band_info.band_support.fddlte_band = info_modem.modem.v1.band_fddlte;
+ band_info.band_support.lte_ext_band = info_modem.modem.v1.band_lte_ext;
} else {
- if(band_info.net_support & MBTK_NET_SUPPORT_5G) {
- band_info.band_support.net_pref = MBTK_NET_PREF_LTE_NR_NR_PREF; // 19
+ band_info.band_area = info_modem.modem.v2.band_area;
+ band_info.net_support = info_modem.modem.v2.net_support;
+ if(info_modem.modem.v2.net_pref < MBTK_NET_PREF_MAX) {
+ band_info.band_support.net_pref = info_modem.modem.v2.net_pref;
} else {
- band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF; // 15
+ if(band_info.net_support & MBTK_NET_SUPPORT_5G) {
+ band_info.band_support.net_pref = MBTK_NET_PREF_LTE_NR_NR_PREF; // 19
+ } else {
+ band_info.band_support.net_pref = MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF; // 15
+ }
}
- }
- 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;
- band_info.band_support.fddlte_band = info_modem.band_fddlte;
- band_info.band_support.lte_ext_band = info_modem.band_lte_ext;
+ band_info.band_support.gsm_band = info_modem.modem.v2.band_gsm;
+ band_info.band_support.umts_band = info_modem.modem.v2.band_wcdma;
+ band_info.band_support.tdlte_band = info_modem.modem.v2.band_tdlte;
+ band_info.band_support.fddlte_band = info_modem.modem.v2.band_fddlte;
+ band_info.band_support.lte_ext_band = info_modem.modem.v2.band_lte_ext;
- band_info.band_support.nr_3_band = info_modem.band_nr_3;
- band_info.band_support.nr_2_band = info_modem.band_nr_2;
- band_info.band_support.nr_1_band = info_modem.band_nr_1;
- band_info.band_support.nr_0_band = info_modem.band_nr_0;
+ band_info.band_support.nr_3_band = info_modem.modem.v2.band_nr_3;
+ band_info.band_support.nr_2_band = info_modem.modem.v2.band_nr_2;
+ band_info.band_support.nr_1_band = info_modem.modem.v2.band_nr_1;
+ band_info.band_support.nr_0_band = info_modem.modem.v2.band_nr_0;
+ }
}
}
diff --git a/mbtk/mbtk_servicesd_v2/src/reboot_reason.c b/mbtk/mbtk_servicesd_v2/src/reboot_reason.c
index e40c7f4..f1dfc8c 100755
--- a/mbtk/mbtk_servicesd_v2/src/reboot_reason.c
+++ b/mbtk/mbtk_servicesd_v2/src/reboot_reason.c
@@ -39,8 +39,8 @@
mbtk_device_info_reboot_flag_enum reboot_reason = MBTK_REBOOT_FLAG_NORMAL;
mbtk_device_info_basic_t info_basic = {0};
memset(&info_basic, 0, sizeof(mbtk_device_info_basic_t));
-
-
+
+
ret = mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_BASIC, &(info_basic), sizeof(mbtk_device_info_basic_t));
if(ret != 0)
{
@@ -49,14 +49,27 @@
}
else
{
- reboot_reason = info_basic.reboot_flag;
- if(info_basic.reboot_flag != MBTK_REBOOT_FLAG_NORMAL)
- {
- info_basic.reboot_flag = MBTK_REBOOT_FLAG_NORMAL;
- ret = mbtk_dev_info_write(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t));
- if(ret != 0) {
- LOGE("[%s] mbtk_dev_info_write(BASIC) fail.", __func__);
+ if(info_basic.version == DEV_INFO_VERSION_V1) {
+ reboot_reason = info_basic.basic.v1.reboot_flag;
+ if(reboot_reason != MBTK_REBOOT_FLAG_NORMAL)
+ {
+ info_basic.basic.v1.reboot_flag = MBTK_REBOOT_FLAG_NORMAL;
+ ret = mbtk_dev_info_write(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t));
+ if(ret != 0) {
+ LOGE("[%s] mbtk_dev_info_write(BASIC) fail.", __func__);
+ }
}
+ } else {
+ reboot_reason = info_basic.basic.v2.reboot_flag;
+ if(reboot_reason != MBTK_REBOOT_FLAG_NORMAL)
+ {
+ info_basic.basic.v2.reboot_flag = MBTK_REBOOT_FLAG_NORMAL;
+ ret = mbtk_dev_info_write(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t));
+ if(ret != 0) {
+ LOGE("[%s] mbtk_dev_info_write(BASIC) fail.", __func__);
+ }
+ }
+
}
}
@@ -64,7 +77,7 @@
memset(buff, 0x0, 32);
sprintf(buff, "%d", reboot_reason);
property_set("persist.mbtk.reboot_reason", buff);
-
+
LOGD("[%s] reboot reason exit.", __func__);
return 0;
diff --git a/mbtk/mbtk_utils/device_info.c b/mbtk/mbtk_utils/device_info.c
index a5cc759..976f289 100755
--- a/mbtk/mbtk_utils/device_info.c
+++ b/mbtk/mbtk_utils/device_info.c
@@ -125,35 +125,36 @@
memset(info_modem, 0, sizeof(mbtk_device_info_modem_t));
if(mbtk_dev_info_read(MBTK_DEVICE_INFO_ITEM_MODEM, info_modem, sizeof(mbtk_device_info_modem_t))) {
printf("mbtk_dev_info_read(MODEM) fail, use default band.\n");
- info_modem->band_area = MBTK_MODEM_BAND_AREA_ALL;
+ info_modem->version = DEV_INFO_VERSION_V2;
+ info_modem->modem.v2.band_area = MBTK_MODEM_BAND_AREA_ALL;
#ifdef MBTK_5G_SUPPORT
- info_modem->net_pref = 19; // MBTK_NET_PREF_LTE_NR_NR_PREF
- info_modem->net_support = MBTK_NET_SUPPORT_4G | MBTK_NET_SUPPORT_5G;
+ info_modem->modem.v2.net_pref = 19; // MBTK_NET_PREF_LTE_NR_NR_PREF
+ info_modem->modem.v2.net_support = MBTK_NET_SUPPORT_4G | MBTK_NET_SUPPORT_5G;
- info_modem->band_gsm = 0;
- info_modem->band_wcdma = 0;
- info_modem->band_tdlte = MBTK_BAND_ALL_TDLTE_DEFAULT;
- info_modem->band_fddlte = MBTK_BAND_ALL_FDDLTE_DEFAULT;
- info_modem->band_lte_ext = MBTK_BAND_ALL_EXT_LTE_DEFAULT;
+ info_modem->modem.v2.band_gsm = 0;
+ info_modem->modem.v2.band_wcdma = 0;
+ info_modem->modem.v2.band_tdlte = MBTK_BAND_ALL_TDLTE_DEFAULT;
+ info_modem->modem.v2.band_fddlte = MBTK_BAND_ALL_FDDLTE_DEFAULT;
+ info_modem->modem.v2.band_lte_ext = MBTK_BAND_ALL_EXT_LTE_DEFAULT;
- info_modem->band_nr_3 = MBTK_BAND_ALL_NR_3_DEFAULT;
- info_modem->band_nr_2 = MBTK_BAND_ALL_NR_2_DEFAULT;
- info_modem->band_nr_1 = MBTK_BAND_ALL_NR_1_DEFAULT;
- info_modem->band_nr_0 = MBTK_BAND_ALL_NR_0_DEFAULT;
+ info_modem->modem.v2.band_nr_3 = MBTK_BAND_ALL_NR_3_DEFAULT;
+ info_modem->modem.v2.band_nr_2 = MBTK_BAND_ALL_NR_2_DEFAULT;
+ info_modem->modem.v2.band_nr_1 = MBTK_BAND_ALL_NR_1_DEFAULT;
+ info_modem->modem.v2.band_nr_0 = MBTK_BAND_ALL_NR_0_DEFAULT;
#else
- info_modem->net_pref = 15; // MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF
- info_modem->net_support = MBTK_NET_SUPPORT_2G | MBTK_NET_SUPPORT_3G | MBTK_NET_SUPPORT_4G;
+ info_modem->modem.v2.net_pref = 15; // MBTK_NET_PREF_GSM_UMTS_LTE_LTE_PREF
+ info_modem->modem.v2.net_support = MBTK_NET_SUPPORT_2G | MBTK_NET_SUPPORT_3G | MBTK_NET_SUPPORT_4G;
- info_modem->band_gsm = MBTK_BAND_ALL_GSM_DEFAULT;
- info_modem->band_wcdma = MBTK_BAND_ALL_WCDMA_DEFAULT;
- info_modem->band_tdlte = MBTK_BAND_ALL_TDLTE_DEFAULT;
- info_modem->band_fddlte = MBTK_BAND_ALL_FDDLTE_DEFAULT;
- info_modem->band_lte_ext = MBTK_BAND_ALL_EXT_LTE_DEFAULT;
+ info_modem->modem.v2.band_gsm = MBTK_BAND_ALL_GSM_DEFAULT;
+ info_modem->modem.v2.band_wcdma = MBTK_BAND_ALL_WCDMA_DEFAULT;
+ info_modem->modem.v2.band_tdlte = MBTK_BAND_ALL_TDLTE_DEFAULT;
+ info_modem->modem.v2.band_fddlte = MBTK_BAND_ALL_FDDLTE_DEFAULT;
+ info_modem->modem.v2.band_lte_ext = MBTK_BAND_ALL_EXT_LTE_DEFAULT;
- info_modem->band_nr_3 = 0;
- info_modem->band_nr_2 = 0;
- info_modem->band_nr_1 = 0;
- info_modem->band_nr_0 = 0;
+ info_modem->modem.v2.band_nr_3 = 0;
+ info_modem->modem.v2.band_nr_2 = 0;
+ info_modem->modem.v2.band_nr_1 = 0;
+ info_modem->modem.v2.band_nr_0 = 0;
#endif
}
}
@@ -164,20 +165,24 @@
char rsp[100] = {0};
// Only support 4G/5G
- if(band->net_support & MBTK_NET_SUPPORT_5G) {
+ if(band->modem.v2.net_support & MBTK_NET_SUPPORT_5G) {
// AT*band=19,0,0,482,134742231,0,24576,256,134217877,0
- if(band->band_lte_ext > 0) {
- sprintf(cmd, "serial_atcmd AT*BAND=%d,%d,%d,%d,%d,%d,%d,%d,%d,0,,,,%d", band->net_pref, band->band_gsm, band->band_wcdma, band->band_tdlte, band->band_fddlte,
- band->band_nr_3, band->band_nr_2, band->band_nr_1, band->band_nr_0, band->band_lte_ext);
+ if(band->modem.v2.band_lte_ext > 0) {
+ sprintf(cmd, "serial_atcmd AT*BAND=%d,%d,%d,%d,%d,%d,%d,%d,%d,0,,,,%d", band->modem.v2.net_pref, band->modem.v2.band_gsm,
+ band->modem.v2.band_wcdma, band->modem.v2.band_tdlte, band->modem.v2.band_fddlte,
+ band->modem.v2.band_nr_3, band->modem.v2.band_nr_2, band->modem.v2.band_nr_1,
+ band->modem.v2.band_nr_0, band->modem.v2.band_lte_ext);
} else {
- sprintf(cmd, "serial_atcmd AT*BAND=%d,%d,%d,%d,%d,%d,%d,%d,%d,0", band->net_pref, band->band_gsm, band->band_wcdma, band->band_tdlte, band->band_fddlte,
- band->band_nr_3, band->band_nr_2, band->band_nr_1, band->band_nr_0);
+ sprintf(cmd, "serial_atcmd AT*BAND=%d,%d,%d,%d,%d,%d,%d,%d,%d,0", band->modem.v2.net_pref, band->modem.v2.band_gsm,
+ band->modem.v2.band_wcdma, band->modem.v2.band_tdlte, band->modem.v2.band_fddlte,
+ band->modem.v2.band_nr_3, band->modem.v2.band_nr_2, band->modem.v2.band_nr_1, band->modem.v2.band_nr_0);
}
} else {
- if(band->band_lte_ext > 0) {
- sprintf(cmd, "serial_atcmd AT*BAND=%d,%d,%d,%d,%d,,,,%d", band->net_pref, band->band_gsm, band->band_wcdma, band->band_tdlte, band->band_fddlte, band->band_lte_ext);
+ if(band->modem.v2.band_lte_ext > 0) {
+ sprintf(cmd, "serial_atcmd AT*BAND=%d,%d,%d,%d,%d,,,,%d", band->modem.v2.net_pref, band->modem.v2.band_gsm, band->modem.v2.band_wcdma,
+ band->modem.v2.band_tdlte, band->modem.v2.band_fddlte, band->modem.v2.band_lte_ext);
} else {
- sprintf(cmd, "serial_atcmd AT*BAND=%d,%d,%d,%d,%d", band->net_pref, band->band_gsm, band->band_wcdma, band->band_tdlte, band->band_fddlte);
+ sprintf(cmd, "serial_atcmd AT*BAND=%d,%d,%d,%d,%d", band->modem.v2.net_pref, band->modem.v2.band_gsm, band->modem.v2.band_wcdma, band->modem.v2.band_tdlte, band->modem.v2.band_fddlte);
}
}
@@ -205,11 +210,11 @@
}
else // Set band success.
{
- if(info_modem->band_area == MBTK_MODEM_BAND_AREA_CN) {
+ if(info_modem->modem.v2.band_area == MBTK_MODEM_BAND_AREA_CN) {
property_set("persist.mbtk.band_config", "CN");
- } else if(info_modem->band_area == MBTK_MODEM_BAND_AREA_EU) {
+ } else if(info_modem->modem.v2.band_area == MBTK_MODEM_BAND_AREA_EU) {
property_set("persist.mbtk.band_config", "EU");
- } else if(info_modem->band_area == MBTK_MODEM_BAND_AREA_SA) {
+ } else if(info_modem->modem.v2.band_area == MBTK_MODEM_BAND_AREA_SA) {
property_set("persist.mbtk.band_config", "SA");
} else {
property_set("persist.mbtk.band_config", "ALL");
@@ -258,14 +263,25 @@
uint8 revision_out[48]; // L508_X6v01.01b04.00
uint8 revision_in[64];
*/
- printf("Project:%s\n", info_basic.project);
- printf("Custom_Model:%s\n", info_basic.project_cust);
- printf("Revision_Out:%s\n", info_basic.revision_out);
- printf("Revision_In:%s\n", info_basic.revision_in);
- printf("Build_Time:%s\n", info_basic.build_time);
- printf("AB System:%s\n", info_basic.ab_support ? "Yes" : "No");
- printf("Reboot flag:%d\n", info_basic.reboot_flag);
- printf("ASR Baseline:%s\n", info_basic.asr_baseline);
+ printf("Version:%d\n", info_basic.version);
+ if(info_basic.version == DEV_INFO_VERSION_V1) {
+ printf("Project:%s\n", info_basic.basic.v1.project);
+ printf("Custom_Model:%s\n", info_basic.basic.v1.project_cust);
+ printf("Revision_Out:%s\n", info_basic.basic.v1.revision_out);
+ printf("Revision_In:%s\n", info_basic.basic.v1.revision_in);
+ printf("Build_Time:%s\n", info_basic.basic.v1.build_time);
+ printf("AB System:%s\n", info_basic.basic.v1.ab_support ? "Yes" : "No");
+ printf("Reboot flag:%d\n", info_basic.basic.v1.reboot_flag);
+ } else {
+ printf("Project:%s\n", info_basic.basic.v2.project);
+ printf("Custom_Model:%s\n", info_basic.basic.v2.project_cust);
+ printf("Revision_Out:%s\n", info_basic.basic.v2.revision_out);
+ printf("Revision_In:%s\n", info_basic.basic.v2.revision_in);
+ printf("Build_Time:%s\n", info_basic.basic.v2.build_time);
+ printf("AB System:%s\n", info_basic.basic.v2.ab_support ? "Yes" : "No");
+ printf("Reboot flag:%d\n", info_basic.basic.v2.reboot_flag);
+ printf("ASR Baseline:%s\n", info_basic.basic.v2.asr_baseline);
+ }
mbtk_device_info_modem_t info_modem;
memset(&info_modem, 0, sizeof(mbtk_device_info_modem_t));
@@ -275,18 +291,27 @@
return -1;
}
- printf("net_pref:%d\n", info_modem.net_pref);
- printf("net_support:%s\n", net_support_str_get(info_modem.net_support));
- printf("Band:%s\n", band_2_str(info_modem.band_area));
- printf("Band GSM:0x%08x(%s)\n", info_modem.band_gsm, band_str_get(info_modem.band_gsm, 0));
- printf("Band WCDMA:0x%08x(%s)\n", info_modem.band_wcdma, band_str_get(info_modem.band_wcdma, 0));
- printf("Band TDLTE:0x%08x(%s)\n", info_modem.band_tdlte, band_str_get(info_modem.band_tdlte, 1));
- printf("Band FDDLTE:0x%08x(%s)\n", info_modem.band_fddlte, band_str_get(info_modem.band_fddlte, 0));
- printf("Band EXT_LTE:0x%08x(%s)\n", info_modem.band_lte_ext, band_str_get(info_modem.band_lte_ext, 0));
- printf("Band NR_3:0x%08x(%s)\n", info_modem.band_nr_3, band_str_get(info_modem.band_nr_3, 3));
- printf("Band NR_2:0x%08x(%s)\n", info_modem.band_nr_2, band_str_get(info_modem.band_nr_2, 2));
- printf("Band NR_1:0x%08x(%s)\n", info_modem.band_nr_1, band_str_get(info_modem.band_nr_1, 1));
- printf("Band NR_0:0x%08x(%s)\n", info_modem.band_nr_0, band_str_get(info_modem.band_nr_0, 0));
+ if(info_modem.version == DEV_INFO_VERSION_V1) {
+ printf("Band:%s\n", band_2_str(info_modem.modem.v1.band_area));
+ printf("Band GSM:0x%08x(%s)\n", info_modem.modem.v1.band_gsm, band_str_get(info_modem.modem.v1.band_gsm, 0));
+ printf("Band WCDMA:0x%08x(%s)\n", info_modem.modem.v1.band_wcdma, band_str_get(info_modem.modem.v1.band_wcdma, 0));
+ printf("Band TDLTE:0x%08x(%s)\n", info_modem.modem.v1.band_tdlte, band_str_get(info_modem.modem.v1.band_tdlte, 1));
+ printf("Band FDDLTE:0x%08x(%s)\n", info_modem.modem.v1.band_fddlte, band_str_get(info_modem.modem.v1.band_fddlte, 0));
+ printf("Band EXT_LTE:0x%08x(%s)\n", info_modem.modem.v1.band_lte_ext, band_str_get(info_modem.modem.v1.band_lte_ext, 0));
+ } else {
+ printf("net_pref:%d\n", info_modem.modem.v2.net_pref);
+ printf("net_support:%s\n", net_support_str_get(info_modem.modem.v2.net_support));
+ printf("Band:%s\n", band_2_str(info_modem.modem.v2.band_area));
+ printf("Band GSM:0x%08x(%s)\n", info_modem.modem.v2.band_gsm, band_str_get(info_modem.modem.v2.band_gsm, 0));
+ printf("Band WCDMA:0x%08x(%s)\n", info_modem.modem.v2.band_wcdma, band_str_get(info_modem.modem.v2.band_wcdma, 0));
+ printf("Band TDLTE:0x%08x(%s)\n", info_modem.modem.v2.band_tdlte, band_str_get(info_modem.modem.v2.band_tdlte, 1));
+ printf("Band FDDLTE:0x%08x(%s)\n", info_modem.modem.v2.band_fddlte, band_str_get(info_modem.modem.v2.band_fddlte, 0));
+ printf("Band EXT_LTE:0x%08x(%s)\n", info_modem.modem.v2.band_lte_ext, band_str_get(info_modem.modem.v2.band_lte_ext, 0));
+ printf("Band NR_3:0x%08x(%s)\n", info_modem.modem.v2.band_nr_3, band_str_get(info_modem.modem.v2.band_nr_3, 3));
+ printf("Band NR_2:0x%08x(%s)\n", info_modem.modem.v2.band_nr_2, band_str_get(info_modem.modem.v2.band_nr_2, 2));
+ printf("Band NR_1:0x%08x(%s)\n", info_modem.modem.v2.band_nr_1, band_str_get(info_modem.modem.v2.band_nr_1, 1));
+ printf("Band NR_0:0x%08x(%s)\n", info_modem.modem.v2.band_nr_0, band_str_get(info_modem.modem.v2.band_nr_0, 0));
+ }
}
return 0;
}
diff --git a/mbtk/mbtk_utils/mbtk_reboot.c b/mbtk/mbtk_utils/mbtk_reboot.c
index a355235..d3861e2 100755
--- a/mbtk/mbtk_utils/mbtk_reboot.c
+++ b/mbtk/mbtk_utils/mbtk_reboot.c
@@ -45,7 +45,11 @@
return -1;
}
- info_basic.reboot_flag = MBTK_REBOOT_FLAG_DOWNLOAD;
+ if(info_basic.version == DEV_INFO_VERSION_V1) {
+ info_basic.basic.v1.reboot_flag = MBTK_REBOOT_FLAG_DOWNLOAD;
+ } else {
+ info_basic.basic.v2.reboot_flag = MBTK_REBOOT_FLAG_DOWNLOAD;
+ }
result = mbtk_dev_info_write(MBTK_DEVICE_INFO_ITEM_BASIC, &info_basic, sizeof(mbtk_device_info_basic_t));
if(result) {
printf("mbtk_dev_info_write(BASIC) fail.\n");
diff --git a/mbtk/mbtk_utils_linux/Makefile b/mbtk/mbtk_utils_linux/Makefile
index c2427bc..9e6c72b 100755
--- a/mbtk/mbtk_utils_linux/Makefile
+++ b/mbtk/mbtk_utils_linux/Makefile
@@ -5,8 +5,8 @@
#DEFINE = -DMBTK_DEV_INFO_VERSION_2
#endif
-INC_DIR += \
- -I$(LOCAL_PATH)
+#INC_DIR += \
+# -I$(LOCAL_PATH)
CC=gcc
diff --git a/mbtk/mbtk_utils_linux/mbtk_device.h b/mbtk/mbtk_utils_linux/mbtk_device.h
new file mode 100755
index 0000000..d4e0c03
--- /dev/null
+++ b/mbtk/mbtk_utils_linux/mbtk_device.h
@@ -0,0 +1,155 @@
+/*
+* mbtk_device.h
+*
+* MBTK device_info partition data header.
+*
+* Author : lb
+* Date : 2023/12/30 11:36:35
+*/
+#ifndef _MBTK_DEVICE_H
+#define _MBTK_DEVICE_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
+
+// 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_ALL_NR_3_DEFAULT 0
+#define MBTK_BAND_ALL_NR_2_DEFAULT 24576 // n78/n79
+#define MBTK_BAND_ALL_NR_1_DEFAULT 256 // n41
+#define MBTK_BAND_ALL_NR_0_DEFAULT 134217877 // n1/n3/n5/n8/n28
+
+#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_CN_NR_3_DEFAULT 0
+#define MBTK_BAND_CN_NR_2_DEFAULT 24576 // n78/n79
+#define MBTK_BAND_CN_NR_1_DEFAULT 384 // n40/n41
+#define MBTK_BAND_CN_NR_0_DEFAULT 134217877 // n1/n3/n5/n8/n28
+
+#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_EU_NR_3_DEFAULT 0
+#define MBTK_BAND_EU_NR_2_DEFAULT 12352 // n71/n77/n78
+#define MBTK_BAND_EU_NR_1_DEFAULT 416 // n38/n40/n41
+#define MBTK_BAND_EU_NR_0_DEFAULT 134742229 // n1/n3/n5/n7/n8/n20/n28
+
+#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_BAND_SA_NR_3_DEFAULT MBTK_BAND_ALL_NR_3_DEFAULT
+#define MBTK_BAND_SA_NR_2_DEFAULT MBTK_BAND_ALL_NR_2_DEFAULT
+#define MBTK_BAND_SA_NR_1_DEFAULT MBTK_BAND_ALL_NR_1_DEFAULT
+#define MBTK_BAND_SA_NR_0_DEFAULT MBTK_BAND_ALL_NR_0_DEFAULT
+
+#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
+
+#define MBTK_NET_SUPPORT_2G (1)
+#define MBTK_NET_SUPPORT_3G (1<<1)
+#define MBTK_NET_SUPPORT_4G (1<<2)
+#define MBTK_NET_SUPPORT_5G (1<<3)
+
+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];
+ uint8 asr_baseline[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 net_pref; // Refor to : mbtk_net_pref_enum
+ uint32 net_support; // 1:GSM 2:WCDMA 4:LTE 8:NR
+ uint32 band_gsm;
+ uint32 band_wcdma;
+ uint32 band_tdlte;
+ uint32 band_fddlte;
+ uint32 band_lte_ext;
+ uint32 band_nr_3;
+ uint32 band_nr_2;
+ uint32 band_nr_1;
+ uint32 band_nr_0;
+} mbtk_device_info_modem_t;
+
+typedef struct {
+ uint8 name[16];
+ uint32 version; // Default : 0x01
+ uint32 state; //
+} mbtk_device_info_log_t;
+
+
+#endif /* _MBTK_DEVICE_H */
+
diff --git a/mbtk/mbtk_utils_linux/mbtk_type.h b/mbtk/mbtk_utils_linux/mbtk_type.h
new file mode 100755
index 0000000..c7fc885
--- /dev/null
+++ b/mbtk/mbtk_utils_linux/mbtk_type.h
@@ -0,0 +1,123 @@
+#ifndef MBTK_TYPE_INCLUDE
+#define MBTK_TYPE_INCLUDE
+#include <stdio.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+#ifndef MBTK_PLATFORM_LINUX
+#define MBTK_PLATFORM_LINUX
+#endif
+
+#ifndef MBTK_PLATFORM_QCOMM
+//#define MBTK_PLATFORM_QCOMM
+#endif
+
+#define MBTK_SUCCESS 0
+#define MBTK_FAILE (-1)
+
+#ifndef UNUSED
+#define UNUSED(param) ((void) param)
+#endif
+
+#ifndef UNUSEDPARAM
+#define UNUSEDPARAM(param) ((void) param)
+#endif
+
+#ifndef TRUE
+#define TRUE 1 /* Boolean true value. */
+#endif
+
+#ifndef true
+#define true 1 /* Boolean true value. */
+#endif
+
+#ifndef FALSE
+#define FALSE 0 /* Boolean false value. */
+#endif
+
+#ifndef false
+#define false 0 /* Boolean false value. */
+#endif
+
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+
+#ifndef null
+#define null 0
+#endif
+
+/**
+ * Compiler-digit : 16
+ * char : 1 (%c)
+ * char* : 2
+ * short int : 2
+ * int : 2 (%d)
+ * unsigned int : 2 (%u)
+ * float : 4 (%f)
+ * double : 8 (%f)
+ * long : 4
+ * unsigned long : 4
+ * long long : 8
+ * unsigned long long : 8
+ *
+ *
+ * Compiler-digit : 32
+ * char : 1
+ * char* : 4
+ * short int : 2
+ * int : 4
+ * unsigned int : 4
+ * float : 4
+ * double : 8
+ * long : 4
+ * unsigned long : 4
+ * long long : 8
+ * unsigned long long : 8
+ *
+ *
+ * Compiler-digit : 64
+ * char : 1
+ * char* : 8
+ * short int : 2
+ * int : 4
+ * unsigned int : 4
+ * float : 4
+ * double : 8
+ * long : 8
+ * unsigned long : 8
+ * long long : 8
+ * unsigned long long : 8
+ */
+typedef unsigned char boolean; /* Boolean value type. */
+// typedef unsigned char bool; /* Boolean value type. */
+typedef unsigned long long uint64; /* Unsigned 64 bit value */
+typedef unsigned long long uint64_t; /* Unsigned 64 bit value */
+typedef unsigned int uint32; /* Unsigned 32 bit value */
+typedef unsigned int uint32_t; /* Unsigned 32 bit value */
+typedef unsigned short uint16; /* Unsigned 16 bit value */
+typedef unsigned short uint16_t;
+typedef unsigned char uint8; /* Unsigned 8 bit value */
+typedef unsigned char uint8_t;
+typedef signed long long int64; /* Signed 64 bit value */
+typedef signed long long sint64; /* Signed 64 bit value */
+typedef signed int int32; /* Signed 32 bit value */
+typedef signed int sint32; /* Signed 32 bit value */
+typedef signed short int16; /* Signed 16 bit value */
+typedef signed short sint16; /* Signed 16 bit value */
+typedef signed char int8; /* Signed 8 bit value */
+typedef signed char sint8; /* Signed 8 bit value */
+typedef unsigned char byte; /* byte type */
+
+
+typedef struct
+{
+ char *buffer;
+ int size;
+ int size_max;
+} mbtk_buffer_t;
+
+
+#endif /* MBTK_TYPE_INCLUDE */