[U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options

Changes: - small code refactor - add menu option: gpt restore - add menu option: env default
Inha Song (1): samsung: misc: add env default option to lcd menu
Przemyslaw Marczak (2): samsung: misc: check_keys(), key_pressed() - remove type static. samsung: misc: add gpt restore option to lcd menu
board/samsung/common/misc.c | 60 +++++++++++++++++++++---------------------- include/samsung/misc.h | 6 +++++ 2 files changed, 36 insertions(+), 30 deletions(-)

This patch removes type "static" from those functions declaration. Now it can be used outside.
Change-Id: I2244ca3568b73251401e5102f26cc113ea69c1a4 Signed-off-by: Przemyslaw Marczak p.marczak@samsung.com cc: Minkyu Kang mk7.kang@samsung.com --- board/samsung/common/misc.c | 5 ++--- include/samsung/misc.h | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index eb15739..1d6f4e4 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -15,7 +15,6 @@ #include <asm/arch/cpu.h> #include <asm/arch/gpio.h> #include <asm/gpio.h> -#include <linux/input.h> #include <power/pmic.h> #include <mmc.h>
@@ -72,7 +71,7 @@ static int power_key_pressed(u32 reg) return !!(status & mask); }
-static int key_pressed(int key) +int key_pressed(int key) { int value;
@@ -94,7 +93,7 @@ static int key_pressed(int key) return value; }
-static int check_keys(void) +int check_keys(void) { int keys = 0;
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index ede6c15..47beb1f 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -1,6 +1,8 @@ #ifndef __SAMSUNG_MISC_COMMON_H__ #define __SAMSUNG_MISC_COMMON_H__
+#include <linux/input.h> + #ifdef CONFIG_REVISION_TAG u32 get_board_rev(void); #endif @@ -19,6 +21,8 @@ enum { };
void keys_init(void); +int check_keys(void); +int key_pressed(int key); void check_boot_mode(void); #endif /* CONFIG_LCD_MENU */

On 28/02/14 23:30, Przemyslaw Marczak wrote:
This patch removes type "static" from those functions declaration. Now it can be used outside.
outside where? I think there's no reason to make them to non-static function. If you want to use it at outside then please send the patch together.
Change-Id: I2244ca3568b73251401e5102f26cc113ea69c1a4 Signed-off-by: Przemyslaw Marczak p.marczak@samsung.com cc: Minkyu Kang mk7.kang@samsung.com
board/samsung/common/misc.c | 5 ++--- include/samsung/misc.h | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index eb15739..1d6f4e4 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -15,7 +15,6 @@ #include <asm/arch/cpu.h> #include <asm/arch/gpio.h> #include <asm/gpio.h> -#include <linux/input.h> #include <power/pmic.h> #include <mmc.h>
@@ -72,7 +71,7 @@ static int power_key_pressed(u32 reg) return !!(status & mask); }
-static int key_pressed(int key) +int key_pressed(int key) { int value;
@@ -94,7 +93,7 @@ static int key_pressed(int key) return value; }
-static int check_keys(void) +int check_keys(void) { int keys = 0;
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index ede6c15..47beb1f 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -1,6 +1,8 @@ #ifndef __SAMSUNG_MISC_COMMON_H__ #define __SAMSUNG_MISC_COMMON_H__
+#include <linux/input.h>
#ifdef CONFIG_REVISION_TAG u32 get_board_rev(void); #endif @@ -19,6 +21,8 @@ enum { };
void keys_init(void); +int check_keys(void); +int key_pressed(int key); void check_boot_mode(void); #endif /* CONFIG_LCD_MENU */
Thanks, Minkyu Kang.

Hello Minkyu,
On 03/06/2014 07:51 AM, Minkyu Kang wrote:
On 28/02/14 23:30, Przemyslaw Marczak wrote:
This patch removes type "static" from those functions declaration. Now it can be used outside.
outside where? I think there's no reason to make them to non-static function. If you want to use it at outside then please send the patch together.
Change-Id: I2244ca3568b73251401e5102f26cc113ea69c1a4 Signed-off-by: Przemyslaw Marczak p.marczak@samsung.com cc: Minkyu Kang mk7.kang@samsung.com
I will resend this patchset when some changes will be applied to GPT code. Thanks

Function cmd_process() runs commands with directly given list of arguments but it doesn't expand given macros. Command gpt expects expanded macro e.g. $partitions as an argument so it needs to be called with 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()
Change-Id: I2749d0b3661e2430bedd215d4024f5ae68f358db Signed-off-by: Przemyslaw Marczak p.marczak@samsung.com cc: Minkyu Kang mk7.kang@samsung.com --- board/samsung/common/misc.c | 52 +++++++++++++++++++++---------------------- include/samsung/misc.h | 1 + 2 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index 1d6f4e4..c66d262 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -115,12 +115,13 @@ 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"}, + {"GPT", "gpt"}, + {"EXIT", ""}, };
static char * @@ -129,18 +130,18 @@ mode_info[BOOT_MODE_EXIT + 1] = { "downloader", "mass storage", "firmware update", + "restore", "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", + "gpt write mmc 0 $partitions", + "", };
static void display_board_info(void) @@ -181,11 +182,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(); @@ -199,31 +199,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; @@ -263,7 +261,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]); }
@@ -304,7 +302,7 @@ static void download_menu(void)
if (run) { if (mode_leave_menu(mode)) - break; + run_command("reset", 0);
display_download_menu(mode); } diff --git a/include/samsung/misc.h b/include/samsung/misc.h index 47beb1f..ac0fc0b 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -17,6 +17,7 @@ enum { BOOT_MODE_THOR, BOOT_MODE_UMS, BOOT_MODE_DFU, + BOOT_MODE_GPT, BOOT_MODE_EXIT, };

From: Inha Song ideal.song@samsung.com
Change-Id: Idded38acfeb63c909fa22ff1a1b1ec77b46d7515 Signed-off-by: Inha Song ideal.song@samsung.com Acked-by: Przemyslaw Marczak p.marczak@samsung.com cc: Minkyu Kang mk7.kang@samsung.com --- board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index c66d262..0c13aa1 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -121,6 +121,7 @@ mode_name[BOOT_MODE_EXIT + 1][2] = { {"UMS", "ums"}, {"DFU", "dfu"}, {"GPT", "gpt"}, + {"ENV", "env"}, {"EXIT", ""}, };
@@ -131,6 +132,7 @@ mode_info[BOOT_MODE_EXIT + 1] = { "mass storage", "firmware update", "restore", + "default", "and run normal boot" };
@@ -141,6 +143,7 @@ mode_cmd[BOOT_MODE_EXIT + 1] = { "ums 0 mmc 0", "dfu 0 mmc 0", "gpt write mmc 0 $partitions", + "env default -a; saveenv", "", };
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index ac0fc0b..1fb9e38 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -18,6 +18,7 @@ enum { BOOT_MODE_UMS, BOOT_MODE_DFU, BOOT_MODE_GPT, + BOOT_MODE_ENV, BOOT_MODE_EXIT, };

Hello,
On 02/28/2014 03:30 PM, Przemyslaw Marczak wrote:
Changes:
- small code refactor
- add menu option: gpt restore
- add menu option: env default
Inha Song (1): samsung: misc: add env default option to lcd menu
Przemyslaw Marczak (2): samsung: misc: check_keys(), key_pressed() - remove type static. samsung: misc: add gpt restore option to lcd menu
board/samsung/common/misc.c | 60 +++++++++++++++++++++---------------------- include/samsung/misc.h | 6 +++++ 2 files changed, 36 insertions(+), 30 deletions(-)
Sorry for the Change-Id in the commits. It's from gerrit - I forgot remove it.
Thank you

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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - new commit after separate previous commit --- board/samsung/common/misc.c | 49 ++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 27 deletions(-)
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); }

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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - commit separation --- board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
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", "", };
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index ede6c15..c3d844b 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -15,6 +15,7 @@ enum { BOOT_MODE_THOR, BOOT_MODE_UMS, BOOT_MODE_DFU, + BOOT_MODE_GPT, BOOT_MODE_EXIT, };

From: Inha Song ideal.song@samsung.com
This change allows reset device environment to default without using u-boot console, which is useful for system developers.
Signed-off-by: Inha Song ideal.song@samsung.com Acked-by: Przemyslaw Marczak p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - extend commit message --- board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
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", "", };
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index c3d844b..10653a1 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -16,6 +16,7 @@ enum { BOOT_MODE_UMS, BOOT_MODE_DFU, BOOT_MODE_GPT, + BOOT_MODE_ENV, BOOT_MODE_EXIT, };

This change prevents gpio keys debouncing by adding 50 ms delay when key pressed condition met.
Signed-off-by: Przemyslaw Marczak p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - new commit --- board/samsung/common/misc.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index 65b5c30..5b43821 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -105,6 +105,10 @@ static int check_keys(void) if (key_pressed(KEY_VOLUMEDOWN)) keys += KEY_VOLUMEDOWN;
+ /* Avoids gpio keys debouncing */ + if (keys) + mdelay(50); + return keys; }

On Wed, 2014-04-02 at 11:42 +0200, Przemyslaw Marczak wrote:
This change prevents gpio keys debouncing by adding 50 ms delay when key pressed condition met.
comment nit: keys are bouncing, de-bouncing is the counter measure, you don't want to avoid it :)
virtually yours Gerhard Sittig

Hi, On 04/02/2014 07:26 PM, Gerhard Sittig wrote:
On Wed, 2014-04-02 at 11:42 +0200, Przemyslaw Marczak wrote:
This change prevents gpio keys debouncing by adding 50 ms delay when key pressed condition met.
comment nit: keys are bouncing, de-bouncing is the counter measure, you don't want to avoid it :)
virtually yours Gerhard Sittig
Ok, I will correct this.
Thanks

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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - new commit after separate previous commit
Changes v3: - none --- board/samsung/common/misc.c | 49 ++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 27 deletions(-)
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); }

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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - commit separation
Changes v3: -none --- board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
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", "", };
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index ede6c15..c3d844b 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -15,6 +15,7 @@ enum { BOOT_MODE_THOR, BOOT_MODE_UMS, BOOT_MODE_DFU, + BOOT_MODE_GPT, BOOT_MODE_EXIT, };

From: Inha Song ideal.song@samsung.com
This change allows reset device environment to default without using u-boot console, which is useful for system developers.
Signed-off-by: Inha Song ideal.song@samsung.com Acked-by: Przemyslaw Marczak p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - extend commit message
Changes v3: - none --- board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
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", "", };
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index c3d844b..10653a1 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -16,6 +16,7 @@ enum { BOOT_MODE_UMS, BOOT_MODE_DFU, BOOT_MODE_GPT, + BOOT_MODE_ENV, BOOT_MODE_EXIT, };

This change prevents gpio keys bouncing by adding 50 ms delay when key pressed condition met.
Signed-off-by: Przemyslaw Marczak p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - new commit
Changes v3: - correct commit message --- board/samsung/common/misc.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index 65b5c30..5b43821 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -105,6 +105,10 @@ static int check_keys(void) if (key_pressed(KEY_VOLUMEDOWN)) keys += KEY_VOLUMEDOWN;
+ /* Avoids gpio keys debouncing */ + if (keys) + mdelay(50); + return keys; }

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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com ---
Changes v2: - new commit after separate previous commit
Changes v3: - none
Changes v4: - none
board/samsung/common/misc.c | 49 ++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 27 deletions(-)
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); }

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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com --- Changes v2: - commit separation
Changes v3: - none
Changes v4: - none
board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
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", "", };
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index ede6c15..c3d844b 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -15,6 +15,7 @@ enum { BOOT_MODE_THOR, BOOT_MODE_UMS, BOOT_MODE_DFU, + BOOT_MODE_GPT, BOOT_MODE_EXIT, };

From: Inha Song ideal.song@samsung.com
This change allows reset device environment to default without using u-boot console, which is useful for system developers.
Signed-off-by: Inha Song ideal.song@samsung.com Acked-by: Przemyslaw Marczak p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com --- Changes v2: - extend commit message
Changes v3: - none
Changes v4: - none
board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
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", "", };
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index c3d844b..10653a1 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -16,6 +16,7 @@ enum { BOOT_MODE_UMS, BOOT_MODE_DFU, BOOT_MODE_GPT, + BOOT_MODE_ENV, BOOT_MODE_EXIT, };

This change prevents gpio keys bouncing by adding 50 ms delay when key pressed condition met.
Signed-off-by: Przemyslaw Marczak p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com --- Changes v2: - new commit
Changes v3: - correct commit message
Changes v4: - none
board/samsung/common/misc.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index 65b5c30..5b43821 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -105,6 +105,10 @@ static int check_keys(void) if (key_pressed(KEY_VOLUMEDOWN)) keys += KEY_VOLUMEDOWN;
+ /* Avoids gpio keys debouncing */ + if (keys) + mdelay(50); + return keys; }

On Fri, 2014-04-25 at 12:20 +0200, Przemyslaw Marczak wrote:
This change prevents gpio keys bouncing by adding 50 ms delay when key pressed condition met.
[ ... ] @@ -105,6 +105,10 @@ static int check_keys(void) if (key_pressed(KEY_VOLUMEDOWN)) keys += KEY_VOLUMEDOWN;
- /* Avoids gpio keys debouncing */
- if (keys)
mdelay(50);
- return keys;
}
The approach might have helped in your case, since you tested it and found it's good. I'm just wondering whether the code really does correct de-bouncing.
The delay does decrease the polling frequency (assuming that the routine is called in a loop). But you return data that was sampled before the delay. You don't re-fetch samples after the delay. And this would not necessarily help either, I'm afraid.
In case the GPIO (or the key_pressed() call) does debouncing, you wouldn't need it here. If the key_pressed() result still is bouncy, then the above logic would not debounce it. What you need is some kind of "trigger" where you notice that the line levels are changing, and a delayed fetch of the lines' values after they have settled. Without the first condition, you always have the risk of sampling arbitrary data that does not reflect the keys' status.
nit: The comment still appears to be misleading, you don't want to avoid debouncing. :)
virtually yours Gerhard Sittig

On Mon, 2014-04-28 at 15:44 +0200, Gerhard Sittig wrote:
[ ... ] What you need is some kind of "trigger" where you notice that the line levels are changing, and a delayed fetch of the lines' values after they have settled. Without the first condition, you always have the risk of sampling arbitrary data that does not reflect the keys' status.
Let me mention another approach here for completeness.
You might want to fetch samples into some buffer (a "FIFO" of a certain depth), and only pass along "pressed" or "released" conditions when a certain number of successive samples have the same level and this level is different from what you have passed along previously. That is, you only report changes in the keys' condition after they have become stable.
This approach might be the least intrusive in the context of the routine that you modify in your patch. And it can be acceptably cheap both in terms of computation as well as in storage.
bool last_reported = 0; int last_sampled = 0;
last_sampled <<= 1; last_sampled &= 0xfff; last_sampled |= (key_pressed() ? 1 : 0;
if (last_reported && last_sampled == 0) { /* report the "released" edge */ last_reported = false; } if (!last_reported && last_sampled == 0xfff) { /* report the "pressed" edge */ last_reported = true; } /* other cases either are no changes, or changes that * have not yet become stable */
Just pick a depth and sampling frequency that matches the characteristics of the mechanical bouncing of the switches. Several ten milliseconds is a good estimate (and most users won't notice the delay). This might be a useful helper for other boards to use, too.
virtually yours Gerhard Sittig

Hello Gerhard,
On 04/28/2014 03:44 PM, Gerhard Sittig wrote:
On Fri, 2014-04-25 at 12:20 +0200, Przemyslaw Marczak wrote:
This change prevents gpio keys bouncing by adding 50 ms delay when key pressed condition met.
[ ... ] @@ -105,6 +105,10 @@ static int check_keys(void) if (key_pressed(KEY_VOLUMEDOWN)) keys += KEY_VOLUMEDOWN;
- /* Avoids gpio keys debouncing */
- if (keys)
mdelay(50);
- return keys; }
The approach might have helped in your case, since you tested it and found it's good. I'm just wondering whether the code really does correct de-bouncing.
The delay does decrease the polling frequency (assuming that the routine is called in a loop). But you return data that was sampled before the delay. You don't re-fetch samples after the delay. And this would not necessarily help either, I'm afraid.
In case the GPIO (or the key_pressed() call) does debouncing, you wouldn't need it here. If the key_pressed() result still is bouncy, then the above logic would not debounce it. What you need is some kind of "trigger" where you notice that the line levels are changing, and a delayed fetch of the lines' values after they have settled. Without the first condition, you always have the risk of sampling arbitrary data that does not reflect the keys' status.
nit: The comment still appears to be misleading, you don't want to avoid debouncing. :)
virtually yours Gerhard Sittig
This is right notice. Actually the problem was not a key bouncing. The right problem is about the menu loop where check_keys() is called too many times for a one second. And changing menu position few times in a second is useless and hard to choose proper menu option.
Putting delay into check_keys() function was good enough to make this menu more useful but in fact this was not a solution for key bouncing.
Function check_keys() should be as fast as it could be. So I think that I need only increase a delay in the menu loop which is now 100ms.
Increasing it to 200ms gives good results. It's a simple solution.
What do you think about this?
Thank you for comments.

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 p.marczak@samsung.com --- Changes v4: - new commit
board/samsung/common/misc.c | 73 +++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 42 deletions(-)
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c index 5b43821..c0d8866 100644 --- a/board/samsung/common/misc.c +++ b/board/samsung/common/misc.c @@ -265,7 +265,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], @@ -278,10 +278,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;
@@ -319,45 +347,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; @@ -370,7 +359,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); }

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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - new commit after separate previous commit
Changes v3: - none
Changes v4: - none
Changes v5: - none
--- board/samsung/common/misc.c | 49 ++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 27 deletions(-)
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); }

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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - commit separation
Changes v3: - none
Changes v4: - none
Changes v5: - none
--- board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
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", "", };
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index ede6c15..c3d844b 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -15,6 +15,7 @@ enum { BOOT_MODE_THOR, BOOT_MODE_UMS, BOOT_MODE_DFU, + BOOT_MODE_GPT, BOOT_MODE_EXIT, };

On 30/04/14 20:28, Przemyslaw Marczak wrote:
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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
Changes v2:
- commit separation
Changes v3:
- none
Changes v4:
- none
Changes v5:
- none
board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
applied to u-boot-samsung.
Thanks, Minkyu Kang.

From: Inha Song ideal.song@samsung.com
This change allows reset device environment to default without using u-boot console, which is useful for system developers.
Signed-off-by: Inha Song ideal.song@samsung.com Acked-by: Przemyslaw Marczak p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - extend commit message
Changes v3: - none
Changes v4: - none
Changes v5: - none
--- board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
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", "", };
diff --git a/include/samsung/misc.h b/include/samsung/misc.h index c3d844b..10653a1 100644 --- a/include/samsung/misc.h +++ b/include/samsung/misc.h @@ -16,6 +16,7 @@ enum { BOOT_MODE_UMS, BOOT_MODE_DFU, BOOT_MODE_GPT, + BOOT_MODE_ENV, BOOT_MODE_EXIT, };

On 30/04/14 20:28, Przemyslaw Marczak wrote:
From: Inha Song ideal.song@samsung.com
This change allows reset device environment to default without using u-boot console, which is useful for system developers.
Signed-off-by: Inha Song ideal.song@samsung.com Acked-by: Przemyslaw Marczak p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
Changes v2:
- extend commit message
Changes v3:
- none
Changes v4:
- none
Changes v5:
- none
board/samsung/common/misc.c | 3 +++ include/samsung/misc.h | 1 + 2 files changed, 4 insertions(+)
applied to u-boot-samsung.
Thanks, Minkyu Kang.

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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v2: - new commit
Changes v3: - correct commit message
Changes v4: - none
Changes v5: - move mdelay() from check_keys() to menu loop - update commit msg
--- board/samsung/common/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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) {

On Wed, 2014-04-30 at 13:28 +0200, Przemyslaw Marczak wrote:
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.
Since this description better reflects the motivation of the change, and because there appears to be no need to actually de-bounce the keys, I think this patch is good.
virtually yours Gerhard Sittig

On 05/05/2014 03:35 PM, Gerhard Sittig wrote:
On Wed, 2014-04-30 at 13:28 +0200, Przemyslaw Marczak wrote:
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.
Since this description better reflects the motivation of the change, and because there appears to be no need to actually de-bounce the keys, I think this patch is good.
virtually yours Gerhard Sittig
Thanks:)

On 30/04/14 20:28, Przemyslaw Marczak wrote:
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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
Changes v2:
- new commit
Changes v3:
- correct commit message
Changes v4:
- none
Changes v5:
- move mdelay() from check_keys() to menu loop
- update commit msg
board/samsung/common/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
applied to u-boot-samsung.
Thanks, Minkyu Kang.

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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
--- Changes v4: - new commit
Changes v5: - none
--- board/samsung/common/misc.c | 73 +++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 42 deletions(-)
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); }

Dear Przemyslaw Marczak,
On 30 April 2014 20:28, Przemyslaw Marczak p.marczak@samsung.com wrote:
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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
Changes v4:
- new commit
Changes v5:
- none
board/samsung/common/misc.c | 73 +++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 42 deletions(-)
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)
maybe, unnecessary if statement.
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);
}
1.9.1
U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Thanks, Minkyu Kang.

Hello Minkyu,
On 05/05/2014 03:27 PM, Minkyu Kang wrote:
Dear Przemyslaw Marczak,
On 30 April 2014 20:28, Przemyslaw Marczak <p.marczak@samsung.com mailto:p.marczak@samsung.com> wrote:
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 <p.marczak@samsung.com <mailto:p.marczak@samsung.com>> Cc: Minkyu Kang <mk7.kang@samsung.com <mailto:mk7.kang@samsung.com>> --- Changes v4: - new commit Changes v5: - none --- board/samsung/common/misc.c | 73 +++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 42 deletions(-) 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)
maybe, unnecessary if statement.
Please take a notice that there are two loops: "while" and "for", so the second "if (key)" is necessary for break a "while" loop on "user event".
+ 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); } -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de <mailto:U-Boot@lists.denx.de> http://lists.denx.de/mailman/listinfo/u-boot
Thanks, Minkyu Kang. -- from. prom. www.promsoft.net http://www.promsoft.net
Thank you

Dear Przemyslaw Marczak,
On 06/05/14 17:45, Przemyslaw Marczak wrote:
Hello Minkyu,
On 05/05/2014 03:27 PM, Minkyu Kang wrote:
Dear Przemyslaw Marczak,
On 30 April 2014 20:28, Przemyslaw Marczak <p.marczak@samsung.com mailto:p.marczak@samsung.com> wrote:
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 <p.marczak@samsung.com <mailto:p.marczak@samsung.com>> Cc: Minkyu Kang <mk7.kang@samsung.com <mailto:mk7.kang@samsung.com>> --- Changes v4: - new commit Changes v5: - none --- board/samsung/common/misc.c | 73 +++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 42 deletions(-) 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)
maybe, unnecessary if statement.
Please take a notice that there are two loops: "while" and "for", so the second "if (key)" is necessary for break a "while" loop on "user event".
Ah, I see :) actually, I doubt that need to two loops... anyway OK.
Thanks, Minkyu Kang.

On 30/04/14 20:28, Przemyslaw Marczak wrote:
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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
Changes v4:
- new commit
Changes v5:
- none
board/samsung/common/misc.c | 73 +++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 42 deletions(-)
applied to u-boot-samsung.
Thanks, Minkyu Kang.

On 30/04/14 20:28, Przemyslaw Marczak wrote:
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 p.marczak@samsung.com Cc: Minkyu Kang mk7.kang@samsung.com
Changes v2:
- new commit after separate previous commit
Changes v3:
- none
Changes v4:
- none
Changes v5:
- none
board/samsung/common/misc.c | 49 ++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 27 deletions(-)
applied to u-boot-samsung.
Thanks, Minkyu Kang.
participants (4)
-
Gerhard Sittig
-
Minkyu Kang
-
Minkyu Kang
-
Przemyslaw Marczak