diff --git a/mbtk/mbtk_device_info/main.c b/mbtk/mbtk_device_info/main.c
new file mode 100755
index 0000000..5be2289
--- /dev/null
+++ b/mbtk/mbtk_device_info/main.c
@@ -0,0 +1,230 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "mbtk_device.h"
+
+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 = {
+        {MBTK_DEVICE_INFO_ITEM_BASIC, 0},
+        {MBTK_DEVICE_INFO_ITEM_FOTA, 0},
+        {MBTK_DEVICE_INFO_ITEM_MODEM, 0},
+        {MBTK_DEVICE_INFO_ITEM_LOG, 0},
+    }
+};
+
+static mbtk_device_info_basic_t item_basic = {
+    .name = MBTK_DEVICE_INFO_ITEM_STR_BASIC,
+    .version = MBTK_DEVICE_INFO_CURR_VERSION,
+    .project = {0},
+    .project_cust = {0},
+    .ab_support = 1,            // Default for ab system.
+    .revision_out = {0},
+    .revision_in = {0}
+};
+
+static mbtk_device_info_fota_t item_fota = {
+    .name = MBTK_DEVICE_INFO_ITEM_STR_FOTA,
+    .version = MBTK_DEVICE_INFO_CURR_VERSION,
+    .state = 0
+};
+
+static mbtk_device_info_modem_t item_modem = {
+    .name = MBTK_DEVICE_INFO_ITEM_STR_MODEM,
+    .version = MBTK_DEVICE_INFO_CURR_VERSION,
+    .band_area = MBTK_MODEM_BAND_AREA_ALL,  // Default for all bands.
+    .band_gsm = MBTK_BAND_ALL_GSM_DEFAULT,
+    .band_wcdma = MBTK_BAND_ALL_WCDMA_DEFAULT,
+    .band_tdlte = MBTK_BAND_ALL_TDLTE_DEFAULT,
+    .band_fddlte = MBTK_BAND_ALL_FDDLTE_DEFAULT
+};
+
+static mbtk_device_info_log_t item_log = {
+    .name = MBTK_DEVICE_INFO_ITEM_STR_LOG,
+    .version = MBTK_DEVICE_INFO_CURR_VERSION,
+    .state = 0
+};
+
+static void help()
+{
+    printf("device_info_generate -a [a/ab] -b [revision_out] -c [revision_in] -d [project] -e [project_cust] -f [cn/eu/all] -o [out_bin]\n");
+}
+
+static int update_and_write_header(int fd, mbtk_device_info_header_t *header)
+{
+    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);
+
+    if(sizeof(mbtk_device_info_header_t) != write(fd, header, sizeof(mbtk_device_info_header_t))) {
+        printf("Write header fail:%d\n", errno);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int write_item_basic(int fd, mbtk_device_info_basic_t *item_basic)
+{
+    if(sizeof(mbtk_device_info_basic_t) != write(fd, item_basic, sizeof(mbtk_device_info_basic_t))) {
+        printf("Write item basic fail:%d\n", errno);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int write_item_fota(int fd, mbtk_device_info_fota_t *item_fota)
+{
+    if(sizeof(mbtk_device_info_fota_t) != write(fd, item_fota, sizeof(mbtk_device_info_fota_t))) {
+        printf("Write item fota fail:%d\n", errno);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int write_item_modem(int fd, mbtk_device_info_modem_t *item_modem)
+{
+    if(sizeof(mbtk_device_info_modem_t) != write(fd, item_modem, sizeof(mbtk_device_info_modem_t))) {
+        printf("Write item modem fail:%d\n", errno);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int write_item_log(int fd, mbtk_device_info_log_t *item_log)
+{
+    if(sizeof(mbtk_device_info_log_t) != write(fd, item_log, sizeof(mbtk_device_info_log_t))) {
+        printf("Write item log fail:%d\n", errno);
+        return -1;
+    }
+
+    return 0;
+}
+
+/*
+*
+* device_info_generate -a [a/ab] -b [revision_out] -c [revision_in] -d [project] -e [project_cust] -f [cn/eu/all] -o [out_bin]
+*
+*/
+int main(int argc, char *argv[])
+{
+    int ch;
+    char out_bin[128] = {0};
+    while((ch = getopt(argc, argv, "a:b:c:d:e:f:o:"))!= -1){
+        switch(ch)
+        {
+            case 'a':
+                if(strcmp(optarg, "ab") == 0) {
+                    item_basic.ab_support = 1;
+                } else if(strcmp(optarg, "a") == 0) {
+                    item_basic.ab_support = 0;
+                } else {
+                    printf("Must be a/ab.\n");
+                    return -1;
+                }
+                break;
+            case 'b':
+                if(strlen(optarg) > 0)
+                    memcpy(item_basic.revision_out, optarg, strlen(optarg));
+                break;
+            case 'c':
+                if(strlen(optarg) > 0)
+                    memcpy(item_basic.revision_in, optarg, strlen(optarg));
+                break;
+            case 'd':
+                if(strlen(optarg) > 0)
+                    memcpy(item_basic.project, optarg, strlen(optarg));
+                break;
+            case 'e':
+                if(strlen(optarg) > 0)
+                    memcpy(item_basic.project_cust, optarg, strlen(optarg));
+                break;
+            case 'f':
+                if(strcmp(optarg, "cn") == 0) {
+                    item_modem.band_area = MBTK_MODEM_BAND_AREA_CN;
+                    item_modem.band_gsm = MBTK_BAND_CN_GSM_DEFAULT;
+                    item_modem.band_wcdma = MBTK_BAND_CN_WCDMA_DEFAULT;
+                    item_modem.band_tdlte = MBTK_BAND_CN_TDLTE_DEFAULT;
+                    item_modem.band_fddlte = MBTK_BAND_CN_FDDLTE_DEFAULT;
+                } else if(strcmp(optarg, "eu") == 0) {
+                    item_modem.band_area = MBTK_MODEM_BAND_AREA_EU;
+                    item_modem.band_gsm = MBTK_BAND_EU_GSM_DEFAULT;
+                    item_modem.band_wcdma = MBTK_BAND_EU_WCDMA_DEFAULT;
+                    item_modem.band_tdlte = MBTK_BAND_EU_TDLTE_DEFAULT;
+                    item_modem.band_fddlte = MBTK_BAND_EU_FDDLTE_DEFAULT;
+                } else {
+                    item_modem.band_area = MBTK_MODEM_BAND_AREA_ALL;
+                    item_modem.band_gsm = MBTK_BAND_ALL_GSM_DEFAULT;
+                    item_modem.band_wcdma = MBTK_BAND_ALL_WCDMA_DEFAULT;
+                    item_modem.band_tdlte = MBTK_BAND_ALL_TDLTE_DEFAULT;
+                    item_modem.band_fddlte = MBTK_BAND_ALL_FDDLTE_DEFAULT;
+                    printf("Set to default band.\n");
+                }
+                break;
+            case 'o':
+                if(strlen(optarg) > 0)
+                    memcpy(out_bin, optarg, strlen(optarg));
+                break;
+            default:
+                help();
+                return -1;
+        }
+    }
+    if(strlen(item_basic.revision_out) == 0 || strlen(out_bin) == 0) {
+        help();
+        return -1;
+    }
+
+    printf("Version:%s, Bin:%s\n", item_basic.revision_out, out_bin);
+
+    int fd = open(out_bin, O_WRONLY | O_TRUNC | O_CREAT, 0644);
+    if(fd < 0) {
+        printf("Open(%s) fail:%d\n", out_bin, errno);
+        return -1;
+    }
+
+    if(update_and_write_header(fd, &info_header)) {
+        printf("update_and_write_header() fail.");
+        goto fail;
+    }
+
+    if(write_item_basic(fd, &item_basic)) {
+        printf("update_and_write_item_basic() fail.");
+        goto fail;
+    }
+
+    if(write_item_fota(fd, &item_fota)) {
+        printf("update_and_write_item_fota() fail.");
+        goto fail;
+    }
+
+    if(write_item_modem(fd, &item_modem)) {
+        printf("update_and_write_item_modem() fail.");
+        goto fail;
+    }
+
+    if(write_item_log(fd, &item_log)) {
+        printf("update_and_write_item_log() fail.");
+        goto fail;
+    }
+
+    printf("Success generate device_info bin:%s\n", out_bin);
+    close(fd);
+    return 0;
+fail:
+    close(fd);
+    return -1;
+}
+
