From e6bfe79f31a042cfbd2dd9ee159cdd1209535727 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 30 Apr 2014 13:28:06 +0200 Subject: samsung: misc: allows using environmental macros as args in menu commands Function cmd_process() runs commands with directly given list of arguments but it doesn't expand given environmental variables names as macros. Command "gpt" as one of arguments expects expanded macro e.g. $partitions so it needs to be called by function run_command(). Changes: - extend array mode_name by lower case commands names - used by find_cmd() - put each command arguments into one string - used by run_command() - use run_command() instead of cmd_process() Signed-off-by: Przemyslaw Marczak Cc: Minkyu Kang Signed-off-by: Minkyu Kang --- board/samsung/common/misc.c | 49 ++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'board/samsung/common') diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index 3ff4289..95d1758 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -116,12 +116,12 @@ static int check_keys(void) * 4 BOOT_MODE_EXIT */ static char * -mode_name[BOOT_MODE_EXIT + 1] = { - "DEVICE", - "THOR", - "UMS", - "DFU", - "EXIT" +mode_name[BOOT_MODE_EXIT + 1][2] = { + {"DEVICE", ""}, + {"THOR", "thor"}, + {"UMS", "ums"}, + {"DFU", "dfu"}, + {"EXIT", ""}, }; static char * @@ -133,15 +133,13 @@ mode_info[BOOT_MODE_EXIT + 1] = { "and run normal boot" }; -#define MODE_CMD_ARGC 4 - static char * -mode_cmd[BOOT_MODE_EXIT + 1][MODE_CMD_ARGC] = { - {"", "", "", ""}, - {"thor", "0", "mmc", "0"}, - {"ums", "0", "mmc", "0"}, - {"dfu", "0", "mmc", "0"}, - {"", "", "", ""}, +mode_cmd[BOOT_MODE_EXIT + 1] = { + "", + "thor 0 mmc 0", + "ums 0 mmc 0", + "dfu 0 mmc 0", + "", }; static void display_board_info(void) @@ -182,11 +180,10 @@ static void display_board_info(void) static int mode_leave_menu(int mode) { char *exit_option; - char *exit_boot = "boot"; + char *exit_reset = "reset"; char *exit_back = "back"; cmd_tbl_t *cmd; int cmd_result; - int cmd_repeatable; int leave; lcd_clear(); @@ -200,31 +197,29 @@ static int mode_leave_menu(int mode) leave = 0; break; default: - cmd = find_cmd(mode_cmd[mode][0]); + cmd = find_cmd(mode_name[mode][1]); if (cmd) { - printf("Enter: %s %s\n", mode_name[mode], + printf("Enter: %s %s\n", mode_name[mode][0], mode_info[mode]); - lcd_printf("\n\n\t%s %s\n", mode_name[mode], + lcd_printf("\n\n\t%s %s\n", mode_name[mode][0], mode_info[mode]); lcd_puts("\n\tDo not turn off device before finish!\n"); - cmd_result = cmd_process(0, MODE_CMD_ARGC, - *(mode_cmd + mode), - &cmd_repeatable, NULL); + cmd_result = run_command(mode_cmd[mode], 0); if (cmd_result == CMD_RET_SUCCESS) { printf("Command finished\n"); lcd_clear(); lcd_printf("\n\n\t%s finished\n", - mode_name[mode]); + mode_name[mode][0]); - exit_option = exit_boot; + exit_option = exit_reset; leave = 1; } else { printf("Command error\n"); lcd_clear(); lcd_printf("\n\n\t%s command error\n", - mode_name[mode]); + mode_name[mode][0]); exit_option = exit_back; leave = 0; @@ -264,7 +259,7 @@ static void display_download_menu(int mode) for (i = 0; i <= BOOT_MODE_EXIT; i++) lcd_printf("\t%s %s - %s\n\n", selection[i], - mode_name[i], + mode_name[i][0], mode_info[i]); } @@ -305,7 +300,7 @@ static void download_menu(void) if (run) { if (mode_leave_menu(mode)) - break; + run_command("reset", 0); display_download_menu(mode); } -- cgit v1.1 From 5c7b8a379fbd9b069c95332204c359f61a7f1594 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 30 Apr 2014 13:28:07 +0200 Subject: samsung: misc: add gpt restore option to lcd menu This menu option allows restore gpt. This is usefull and no needs access to the u-boot console. For proper operation: - each partition uuid should be set in environment or - CONFIG_RANDOM_UUID should be defined for automatically uuid setting After operation success device is going to be reset. Signed-off-by: Przemyslaw Marczak Cc: Minkyu Kang Signed-off-by: Minkyu Kang --- board/samsung/common/misc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'board/samsung/common') diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index 95d1758..2fd104d 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -121,6 +121,7 @@ mode_name[BOOT_MODE_EXIT + 1][2] = { {"THOR", "thor"}, {"UMS", "ums"}, {"DFU", "dfu"}, + {"GPT", "gpt"}, {"EXIT", ""}, }; @@ -130,6 +131,7 @@ mode_info[BOOT_MODE_EXIT + 1] = { "downloader", "mass storage", "firmware update", + "restore", "and run normal boot" }; @@ -139,6 +141,7 @@ mode_cmd[BOOT_MODE_EXIT + 1] = { "thor 0 mmc 0", "ums 0 mmc 0", "dfu 0 mmc 0", + "gpt write mmc 0 $partitions", "", }; -- cgit v1.1 From 0954dd61baebcd2de627803ed8e00cc70d9e8b0c Mon Sep 17 00:00:00 2001 From: Inha Song Date: Wed, 30 Apr 2014 13:28:08 +0200 Subject: samsung: misc: add env default option to lcd menu This change allows reset device environment to default without using u-boot console, which is useful for system developers. Signed-off-by: Inha Song Acked-by: Przemyslaw Marczak Cc: Minkyu Kang Signed-off-by: Minkyu Kang --- board/samsung/common/misc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'board/samsung/common') diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index 2fd104d..65b5c30 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -122,6 +122,7 @@ mode_name[BOOT_MODE_EXIT + 1][2] = { {"UMS", "ums"}, {"DFU", "dfu"}, {"GPT", "gpt"}, + {"ENV", "env"}, {"EXIT", ""}, }; @@ -132,6 +133,7 @@ mode_info[BOOT_MODE_EXIT + 1] = { "mass storage", "firmware update", "restore", + "default", "and run normal boot" }; @@ -142,6 +144,7 @@ mode_cmd[BOOT_MODE_EXIT + 1] = { "ums 0 mmc 0", "dfu 0 mmc 0", "gpt write mmc 0 $partitions", + "env default -a; saveenv", "", }; -- cgit v1.1 From f418a1cfc84e19d82730876594806931bf48e24a Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 30 Apr 2014 13:28:09 +0200 Subject: samsung: misc: menu: increase delay in menu main loop Increase menu loop delay to 200 ms helps choose the right menu option by user. Before this, each time key was pressed the current menu option was changed few times. Now it changes only once and also changes few times if key is pressed for a longer time. Signed-off-by: Przemyslaw Marczak Cc: Minkyu Kang Signed-off-by: Minkyu Kang --- board/samsung/common/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'board/samsung/common') diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index 65b5c30..2ea275e 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -285,7 +285,7 @@ static void download_menu(void) display_download_menu(mode); last_mode = mode; - mdelay(100); + mdelay(200); key = check_keys(); switch (key) { -- cgit v1.1 From 605d7e2af76fd0f28555685e6b8718d956c1da63 Mon Sep 17 00:00:00 2001 From: Przemyslaw Marczak Date: Wed, 30 Apr 2014 13:28:10 +0200 Subject: samsung: misc: remove download mode info screen This change removes LCD menu download mode info screen. Now key press timeout is checked in function download_menu() and menu options are displayed directly after PWR + VOLUP keys. Signed-off-by: Przemyslaw Marczak Cc: Minkyu Kang Signed-off-by: Minkyu Kang --- board/samsung/common/misc.c | 73 +++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 42 deletions(-) (limited to 'board/samsung/common') diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index 2ea275e..03106fd 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -261,7 +261,7 @@ static void display_download_menu(int mode) selection[mode] = "[=>]"; lcd_clear(); - lcd_printf("\n\t\tDownload Mode Menu\n"); + lcd_printf("\n\n\t\tDownload Mode Menu\n\n"); for (i = 0; i <= BOOT_MODE_EXIT; i++) lcd_printf("\t%s %s - %s\n\n", selection[i], @@ -274,10 +274,38 @@ static void download_menu(void) int mode = 0; int last_mode = 0; int run; - int key; + int key = 0; + int timeout = 15; /* sec */ + int i; display_download_menu(mode); + lcd_puts("\n"); + + /* Start count if no key is pressed */ + while (check_keys()) + continue; + + while (timeout--) { + lcd_printf("\r\tNormal boot will start in: %2.d seconds.", + timeout); + + /* about 1000 ms in for loop */ + for (i = 0; i < 10; i++) { + mdelay(100); + key = check_keys(); + if (key) + break; + } + if (key) + break; + } + + if (!key) { + lcd_clear(); + return; + } + while (1) { run = 0; @@ -315,45 +343,6 @@ static void download_menu(void) lcd_clear(); } -static void display_mode_info(void) -{ - lcd_position_cursor(4, 4); - lcd_printf("%s\n", U_BOOT_VERSION); - lcd_puts("\nDownload Mode Menu\n"); -#ifdef CONFIG_SYS_BOARD - lcd_printf("Board name: %s\n", CONFIG_SYS_BOARD); -#endif - lcd_printf("Press POWER KEY to display MENU options."); -} - -static int boot_menu(void) -{ - int key = 0; - int timeout = 10; - - display_mode_info(); - - while (timeout--) { - lcd_printf("\rNormal boot will start in: %d seconds.", timeout); - mdelay(1000); - - key = key_pressed(KEY_POWER); - if (key) - break; - } - - lcd_clear(); - - /* If PWR pressed - show download menu */ - if (key) { - printf("Power pressed - go to download menu\n"); - download_menu(); - printf("Download mode exit.\n"); - } - - return 0; -} - void check_boot_mode(void) { int pwr_key; @@ -366,7 +355,7 @@ void check_boot_mode(void) power_key_pressed(KEY_PWR_INTERRUPT_REG); if (key_pressed(KEY_VOLUMEUP)) - boot_menu(); + download_menu(); else if (key_pressed(KEY_VOLUMEDOWN)) mode_leave_menu(BOOT_MODE_THOR); } -- cgit v1.1