[Feature][ZXW-130]merge P50U02 version
Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: I4f29ec5bb7c59385f23738d2b7ca84e67c100f69
diff --git a/ap/app/flags_tool/src/main.c b/ap/app/flags_tool/src/main.c
index 403349e..7e64a78 100755
--- a/ap/app/flags_tool/src/main.c
+++ b/ap/app/flags_tool/src/main.c
@@ -34,6 +34,8 @@
/*******************************************************************************
* Macro definitions *
******************************************************************************/
+#define FLAGS_UTILS_GET _IOWR('b', 1, T_FLAGS_INFO)
+#define FLAGS_UTILS_SET _IOWR('b', 2, T_FLAGS_INFO)
/*******************************************************************************
@@ -57,11 +59,14 @@
static int excute_command_get_ubifs_status(char *option_para);
static int excute_command_set_ubifs_status(char *option_para);
+static int excute_command_kernel_get(char *option_para);
+static int excute_command_kernel_set(char *option_para);
+
/*******************************************************************************
* Global variable declarations *
******************************************************************************/
-static char * g_short_string = "higsub";
+static char * g_short_string = "higsubtq";
static struct option g_long_options[] =
{
@@ -71,6 +76,8 @@
{"set", no_argument, NULL, 's'},
{"get-ubifs-status", no_argument, NULL, 'u'},
{"set-ubifs-status", no_argument, NULL, 'b'},
+ {"kernel-get", no_argument, NULL, 't'},
+ {"kernel-set", no_argument, NULL, 'q'},
{0, 0, 0, 0}
};
@@ -81,7 +88,9 @@
{'g', excute_command_get},
{'s', excute_command_set},
{'u', excute_command_get_ubifs_status},
- {'b', excute_command_set_ubifs_status}
+ {'b', excute_command_set_ubifs_status},
+ {'t', excute_command_kernel_get},
+ {'q', excute_command_kernel_set}
};
@@ -96,7 +105,9 @@
" -g, --get get flags data \n"
" -s, --set set flags data \n"
" -u, --get-ubifs-status get ubifs status \n"
- " -b, --set-ubifs-status set ubifs status \n");
+ " -b, --set-ubifs-status set ubifs status \n"
+ " -t, --kernel-get kernel-get flags data \n"
+ " -q, --kernel-set kernel-set flags data \n");
return;
}
@@ -254,6 +265,102 @@
}
+static int excute_command_kernel_get(char *option_para)
+{
+ int fd = -1;
+ T_FLAGS_INFO flags_info = {0};
+
+ fd = open("/dev/chardevnode0", O_RDWR);
+ if (-1 == open)
+ {
+ printf("kernel get open chardevnode fail, errno=%d \n", errno);
+ return -1;
+ }
+
+ if (ioctl(fd, FLAGS_UTILS_GET, &flags_info) < 0)
+ {
+ printf("Err: ioctl cmd(0x%x) fail, errno=%d \n", FLAGS_UTILS_GET, errno);
+
+ close(fd);
+ return -1;
+ }
+
+ printf("magic_start = 0x%x \n", flags_info.magic_start);
+
+ printf("boot_fota_flag.boot_to = 0x%x \n", flags_info.boot_fota_flag.boot_to);
+ printf("boot_fota_flag.fota_status = %u \n", flags_info.boot_fota_flag.fota_status);
+ printf("boot_fota_flag.system.status = 0x%x \n", flags_info.boot_fota_flag.system.status);
+ printf("boot_fota_flag.system.try_cnt = %d \n", flags_info.boot_fota_flag.system.try_cnt);
+ printf("boot_fota_flag.system2.status = 0x%x \n", flags_info.boot_fota_flag.system2.status);
+ printf("boot_fota_flag.system2.try_cnt = %d \n", flags_info.boot_fota_flag.system2.try_cnt);
+
+ printf("boot_env.dualsys_type = 0x%x \n", flags_info.boot_env.dualsys_type);
+ printf("boot_env.system_boot_env = %s \n", flags_info.boot_env.system_boot_env);
+ printf("boot_env.system2_boot_env = %s \n", flags_info.boot_env.system2_boot_env);
+
+ printf("ubifs_status.fs_status = %d \n", flags_info.ubifs_status.fs_status);
+ printf("ubifs_status.fs_mtd_name = %s \n", flags_info.ubifs_status.fs_mtd_name);
+ printf("ubifs_status.fs_ubi_vol_name = %s \n", flags_info.ubifs_status.fs_ubi_vol_name);
+
+ printf("magic_end = 0x%x \n", flags_info.magic_end);
+
+ close(fd);
+ return 0;
+}
+
+
+static int excute_command_kernel_set(char *option_para)
+{
+ int fd = -1;
+ T_FLAGS_INFO flags_info = {0};
+
+ char system_boot_env[128] = "bootEnv1";
+ char system2_boot_env[128] = "2bootEnv";
+
+ char fs_mtd_name[16] = "nameMTD";
+ char fs_ubi_vol_name[16] = "nameVOL";
+
+ fd = open("/dev/chardevnode0", O_RDWR);
+ if (-1 == open)
+ {
+ printf("kernel set open chardevnode fail, errno=%d \n", errno);
+ return -1;
+ }
+
+ flags_info.magic_start = FLAGS_MAGIC;
+
+ flags_info.boot_fota_flag.boot_to = DUAL_SYSTEM;
+ flags_info.boot_fota_flag.fota_status = 0;
+ flags_info.boot_fota_flag.system.status = DUALSYSTEM_STATUS_BOOTABLE;
+ flags_info.boot_fota_flag.system.try_cnt = 5;
+ flags_info.boot_fota_flag.system2.status = DUALSYSTEM_STATUS_BOOTABLE;
+ flags_info.boot_fota_flag.system2.try_cnt = 13;
+
+ flags_info.boot_env.dualsys_type = DUALSYSTEM_AB;
+ strncpy(flags_info.boot_env.system_boot_env, system_boot_env, sizeof(flags_info.boot_env.system_boot_env));
+ strncpy(flags_info.boot_env.system2_boot_env, system2_boot_env, sizeof(flags_info.boot_env.system2_boot_env));
+
+ flags_info.ubifs_status.fs_status = 0;
+ strncpy(flags_info.ubifs_status.fs_mtd_name, fs_mtd_name, sizeof(flags_info.ubifs_status.fs_mtd_name));
+ strncpy(flags_info.ubifs_status.fs_ubi_vol_name, fs_ubi_vol_name, sizeof(flags_info.ubifs_status.fs_ubi_vol_name));
+
+ flags_info.magic_end = FLAGS_MAGIC;
+
+ if (ioctl(fd, FLAGS_UTILS_SET, &flags_info) < 0)
+ {
+ printf("Err: ioctl cmd(0x%x) fail, errno=%d \n", FLAGS_UTILS_SET, errno);
+
+ close(fd);
+ return -1;
+ }
+
+ printf("Log: kernel set flags success \n");
+
+ close(fd);
+ return 0;
+}
+
+
/*******************************************************************************
* Global function declarations *
******************************************************************************/