All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options
@ 2014-02-28 14:30 Przemyslaw Marczak
  2014-02-28 14:30 ` [U-Boot] [PATCH 1/3] samsung: misc: check_keys(), key_pressed() - remove type static Przemyslaw Marczak
                   ` (5 more replies)
  0 siblings, 6 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-02-28 14:30 UTC (permalink / raw)
  To: u-boot

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(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH 1/3] samsung: misc: check_keys(), key_pressed() - remove type static.
  2014-02-28 14:30 [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
@ 2014-02-28 14:30 ` Przemyslaw Marczak
  2014-03-06  6:51   ` Minkyu Kang
  2014-02-28 14:30 ` [U-Boot] [PATCH 2/3] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-02-28 14:30 UTC (permalink / raw)
  To: u-boot

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 */
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH 2/3] samsung: misc: add gpt restore option to lcd menu
  2014-02-28 14:30 [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
  2014-02-28 14:30 ` [U-Boot] [PATCH 1/3] samsung: misc: check_keys(), key_pressed() - remove type static Przemyslaw Marczak
@ 2014-02-28 14:30 ` Przemyslaw Marczak
  2014-02-28 14:30 ` [U-Boot] [PATCH 3/3] samsung: misc: add env default " Przemyslaw Marczak
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-02-28 14:30 UTC (permalink / raw)
  To: u-boot

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,
 };
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH 3/3] samsung: misc: add env default option to lcd menu
  2014-02-28 14:30 [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
  2014-02-28 14:30 ` [U-Boot] [PATCH 1/3] samsung: misc: check_keys(), key_pressed() - remove type static Przemyslaw Marczak
  2014-02-28 14:30 ` [U-Boot] [PATCH 2/3] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
@ 2014-02-28 14:30 ` Przemyslaw Marczak
  2014-02-28 14:36 ` [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-02-28 14:30 UTC (permalink / raw)
  To: u-boot

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,
 };
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options
  2014-02-28 14:30 [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
                   ` (2 preceding siblings ...)
  2014-02-28 14:30 ` [U-Boot] [PATCH 3/3] samsung: misc: add env default " Przemyslaw Marczak
@ 2014-02-28 14:36 ` Przemyslaw Marczak
  2014-04-02  9:41 ` [U-Boot] [PATCH v2 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  2014-04-03  8:27 ` [U-Boot] [PATCH v3 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  5 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-02-28 14:36 UTC (permalink / raw)
  To: u-boot

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
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH 1/3] samsung: misc: check_keys(), key_pressed() - remove type static.
  2014-02-28 14:30 ` [U-Boot] [PATCH 1/3] samsung: misc: check_keys(), key_pressed() - remove type static Przemyslaw Marczak
@ 2014-03-06  6:51   ` Minkyu Kang
  2014-03-21  9:13     ` Przemyslaw Marczak
  0 siblings, 1 reply; 40+ messages in thread
From: Minkyu Kang @ 2014-03-06  6:51 UTC (permalink / raw)
  To: u-boot

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.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH 1/3] samsung: misc: check_keys(), key_pressed() - remove type static.
  2014-03-06  6:51   ` Minkyu Kang
@ 2014-03-21  9:13     ` Przemyslaw Marczak
  0 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-03-21  9:13 UTC (permalink / raw)
  To: u-boot

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
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v2 1/4] samsung: misc: allows using environmental macros as args in menu commands
  2014-02-28 14:30 [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
                   ` (3 preceding siblings ...)
  2014-02-28 14:36 ` [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
@ 2014-04-02  9:41 ` Przemyslaw Marczak
  2014-04-02  9:41   ` [U-Boot] [PATCH v2 2/4] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
                     ` (2 more replies)
  2014-04-03  8:27 ` [U-Boot] [PATCH v3 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  5 siblings, 3 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-02  9:41 UTC (permalink / raw)
  To: u-boot

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);
 		}
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v2 2/4] samsung: misc: add gpt restore option to lcd menu
  2014-04-02  9:41 ` [U-Boot] [PATCH v2 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
@ 2014-04-02  9:41   ` Przemyslaw Marczak
  2014-04-02  9:42   ` [U-Boot] [PATCH v2 3/4] samsung: misc: add env default " Przemyslaw Marczak
  2014-04-02  9:42   ` [U-Boot] [PATCH v2 4/4] samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay Przemyslaw Marczak
  2 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-02  9:41 UTC (permalink / raw)
  To: u-boot

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,
 };
 
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v2 3/4] samsung: misc: add env default option to lcd menu
  2014-04-02  9:41 ` [U-Boot] [PATCH v2 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  2014-04-02  9:41   ` [U-Boot] [PATCH v2 2/4] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
@ 2014-04-02  9:42   ` Przemyslaw Marczak
  2014-04-02  9:42   ` [U-Boot] [PATCH v2 4/4] samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay Przemyslaw Marczak
  2 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-02  9:42 UTC (permalink / raw)
  To: u-boot

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,
 };
 
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v2 4/4] samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay
  2014-04-02  9:41 ` [U-Boot] [PATCH v2 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  2014-04-02  9:41   ` [U-Boot] [PATCH v2 2/4] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
  2014-04-02  9:42   ` [U-Boot] [PATCH v2 3/4] samsung: misc: add env default " Przemyslaw Marczak
@ 2014-04-02  9:42   ` Przemyslaw Marczak
  2014-04-02 17:26     ` Gerhard Sittig
  2 siblings, 1 reply; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-02  9:42 UTC (permalink / raw)
  To: u-boot

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;
 }
 
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v2 4/4] samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay
  2014-04-02  9:42   ` [U-Boot] [PATCH v2 4/4] samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay Przemyslaw Marczak
@ 2014-04-02 17:26     ` Gerhard Sittig
  2014-04-03  7:03       ` Przemyslaw Marczak
  0 siblings, 1 reply; 40+ messages in thread
From: Gerhard Sittig @ 2014-04-02 17:26 UTC (permalink / raw)
  To: u-boot

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
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v2 4/4] samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay
  2014-04-02 17:26     ` Gerhard Sittig
@ 2014-04-03  7:03       ` Przemyslaw Marczak
  0 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-03  7:03 UTC (permalink / raw)
  To: u-boot

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
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v3 1/4] samsung: misc: allows using environmental macros as args in menu commands
  2014-02-28 14:30 [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
                   ` (4 preceding siblings ...)
  2014-04-02  9:41 ` [U-Boot] [PATCH v2 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
@ 2014-04-03  8:27 ` Przemyslaw Marczak
  2014-04-03  8:27   ` [U-Boot] [PATCH v3 2/4] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
                     ` (3 more replies)
  5 siblings, 4 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-03  8:27 UTC (permalink / raw)
  To: u-boot

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);
 		}
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v3 2/4] samsung: misc: add gpt restore option to lcd menu
  2014-04-03  8:27 ` [U-Boot] [PATCH v3 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
@ 2014-04-03  8:27   ` Przemyslaw Marczak
  2014-04-03  8:27   ` [U-Boot] [PATCH v3 3/4] samsung: misc: add env default " Przemyslaw Marczak
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-03  8:27 UTC (permalink / raw)
  To: u-boot

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,
 };
 
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v3 3/4] samsung: misc: add env default option to lcd menu
  2014-04-03  8:27 ` [U-Boot] [PATCH v3 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  2014-04-03  8:27   ` [U-Boot] [PATCH v3 2/4] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
@ 2014-04-03  8:27   ` Przemyslaw Marczak
  2014-04-03  8:27   ` [U-Boot] [PATCH v3 4/4] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay Przemyslaw Marczak
  2014-04-25 10:20   ` [U-Boot] [PATCH v4 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  3 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-03  8:27 UTC (permalink / raw)
  To: u-boot

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,
 };
 
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v3 4/4] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay
  2014-04-03  8:27 ` [U-Boot] [PATCH v3 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  2014-04-03  8:27   ` [U-Boot] [PATCH v3 2/4] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
  2014-04-03  8:27   ` [U-Boot] [PATCH v3 3/4] samsung: misc: add env default " Przemyslaw Marczak
@ 2014-04-03  8:27   ` Przemyslaw Marczak
  2014-04-25 10:20   ` [U-Boot] [PATCH v4 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  3 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-03  8:27 UTC (permalink / raw)
  To: u-boot

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;
 }
 
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v4 1/5] samsung: misc: allows using environmental macros as args in menu commands
  2014-04-03  8:27 ` [U-Boot] [PATCH v3 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
                     ` (2 preceding siblings ...)
  2014-04-03  8:27   ` [U-Boot] [PATCH v3 4/4] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay Przemyslaw Marczak
@ 2014-04-25 10:20   ` Przemyslaw Marczak
  2014-04-25 10:20     ` [U-Boot] [PATCH v4 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
                       ` (4 more replies)
  3 siblings, 5 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-25 10:20 UTC (permalink / raw)
  To: u-boot

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);
 		}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v4 2/5] samsung: misc: add gpt restore option to lcd menu
  2014-04-25 10:20   ` [U-Boot] [PATCH v4 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
@ 2014-04-25 10:20     ` Przemyslaw Marczak
  2014-04-25 10:20     ` [U-Boot] [PATCH v4 3/5] samsung: misc: add env default " Przemyslaw Marczak
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-25 10:20 UTC (permalink / raw)
  To: u-boot

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,
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v4 3/5] samsung: misc: add env default option to lcd menu
  2014-04-25 10:20   ` [U-Boot] [PATCH v4 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  2014-04-25 10:20     ` [U-Boot] [PATCH v4 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
@ 2014-04-25 10:20     ` Przemyslaw Marczak
  2014-04-25 10:20     ` [U-Boot] [PATCH v4 4/5] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay Przemyslaw Marczak
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-25 10:20 UTC (permalink / raw)
  To: u-boot

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,
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v4 4/5] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay
  2014-04-25 10:20   ` [U-Boot] [PATCH v4 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  2014-04-25 10:20     ` [U-Boot] [PATCH v4 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
  2014-04-25 10:20     ` [U-Boot] [PATCH v4 3/5] samsung: misc: add env default " Przemyslaw Marczak
@ 2014-04-25 10:20     ` Przemyslaw Marczak
  2014-04-28 13:44       ` Gerhard Sittig
  2014-04-25 10:20     ` [U-Boot] [PATCH v4 5/5] samsung: misc: remove download mode info screen Przemyslaw Marczak
  2014-04-30 11:28     ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  4 siblings, 1 reply; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-25 10:20 UTC (permalink / raw)
  To: u-boot

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;
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v4 5/5] samsung: misc: remove download mode info screen
  2014-04-25 10:20   ` [U-Boot] [PATCH v4 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
                       ` (2 preceding siblings ...)
  2014-04-25 10:20     ` [U-Boot] [PATCH v4 4/5] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay Przemyslaw Marczak
@ 2014-04-25 10:20     ` Przemyslaw Marczak
  2014-04-30 11:28     ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  4 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-25 10:20 UTC (permalink / raw)
  To: u-boot

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);
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v4 4/5] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay
  2014-04-25 10:20     ` [U-Boot] [PATCH v4 4/5] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay Przemyslaw Marczak
@ 2014-04-28 13:44       ` Gerhard Sittig
  2014-04-28 14:03         ` Gerhard Sittig
  2014-04-30 10:10         ` Przemyslaw Marczak
  0 siblings, 2 replies; 40+ messages in thread
From: Gerhard Sittig @ 2014-04-28 13:44 UTC (permalink / raw)
  To: u-boot

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
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v4 4/5] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay
  2014-04-28 13:44       ` Gerhard Sittig
@ 2014-04-28 14:03         ` Gerhard Sittig
  2014-04-30 10:10         ` Przemyslaw Marczak
  1 sibling, 0 replies; 40+ messages in thread
From: Gerhard Sittig @ 2014-04-28 14:03 UTC (permalink / raw)
  To: u-boot

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
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office@denx.de

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v4 4/5] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay
  2014-04-28 13:44       ` Gerhard Sittig
  2014-04-28 14:03         ` Gerhard Sittig
@ 2014-04-30 10:10         ` Przemyslaw Marczak
  1 sibling, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-30 10:10 UTC (permalink / raw)
  To: u-boot

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.
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands
  2014-04-25 10:20   ` [U-Boot] [PATCH v4 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
                       ` (3 preceding siblings ...)
  2014-04-25 10:20     ` [U-Boot] [PATCH v4 5/5] samsung: misc: remove download mode info screen Przemyslaw Marczak
@ 2014-04-30 11:28     ` Przemyslaw Marczak
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
                         ` (4 more replies)
  4 siblings, 5 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-30 11:28 UTC (permalink / raw)
  To: u-boot

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);
 		}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 2/5] samsung: misc: add gpt restore option to lcd menu
  2014-04-30 11:28     ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
@ 2014-04-30 11:28       ` Przemyslaw Marczak
  2014-05-08  2:36         ` Minkyu Kang
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 3/5] samsung: misc: add env default " Przemyslaw Marczak
                         ` (3 subsequent siblings)
  4 siblings, 1 reply; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-30 11:28 UTC (permalink / raw)
  To: u-boot

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,
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 3/5] samsung: misc: add env default option to lcd menu
  2014-04-30 11:28     ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
@ 2014-04-30 11:28       ` Przemyslaw Marczak
  2014-05-08  2:36         ` Minkyu Kang
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 4/5] samsung: misc: menu: increase delay in menu main loop Przemyslaw Marczak
                         ` (2 subsequent siblings)
  4 siblings, 1 reply; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-30 11:28 UTC (permalink / raw)
  To: u-boot

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,
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 4/5] samsung: misc: menu: increase delay in menu main loop
  2014-04-30 11:28     ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 3/5] samsung: misc: add env default " Przemyslaw Marczak
@ 2014-04-30 11:28       ` Przemyslaw Marczak
  2014-05-05 13:35         ` Gerhard Sittig
  2014-05-08  2:36         ` Minkyu Kang
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen Przemyslaw Marczak
  2014-05-08  2:36       ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Minkyu Kang
  4 siblings, 2 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-30 11:28 UTC (permalink / raw)
  To: u-boot

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) {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen
  2014-04-30 11:28     ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
                         ` (2 preceding siblings ...)
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 4/5] samsung: misc: menu: increase delay in menu main loop Przemyslaw Marczak
@ 2014-04-30 11:28       ` Przemyslaw Marczak
  2014-05-05 13:27         ` Minkyu Kang
  2014-05-08  2:36         ` Minkyu Kang
  2014-05-08  2:36       ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Minkyu Kang
  4 siblings, 2 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-04-30 11:28 UTC (permalink / raw)
  To: u-boot

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);
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen Przemyslaw Marczak
@ 2014-05-05 13:27         ` Minkyu Kang
  2014-05-06  8:45           ` Przemyslaw Marczak
  2014-05-08  2:36         ` Minkyu Kang
  1 sibling, 1 reply; 40+ messages in thread
From: Minkyu Kang @ 2014-05-05 13:27 UTC (permalink / raw)
  To: u-boot

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 at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>

Thanks,
Minkyu Kang.
-- 
from. prom.
www.promsoft.net

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 4/5] samsung: misc: menu: increase delay in menu main loop
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 4/5] samsung: misc: menu: increase delay in menu main loop Przemyslaw Marczak
@ 2014-05-05 13:35         ` Gerhard Sittig
  2014-05-06  8:32           ` Przemyslaw Marczak
  2014-05-08  2:36         ` Minkyu Kang
  1 sibling, 1 reply; 40+ messages in thread
From: Gerhard Sittig @ 2014-05-05 13:35 UTC (permalink / raw)
  To: u-boot

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
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 4/5] samsung: misc: menu: increase delay in menu main loop
  2014-05-05 13:35         ` Gerhard Sittig
@ 2014-05-06  8:32           ` Przemyslaw Marczak
  0 siblings, 0 replies; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-05-06  8:32 UTC (permalink / raw)
  To: u-boot

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:)
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen
  2014-05-05 13:27         ` Minkyu Kang
@ 2014-05-06  8:45           ` Przemyslaw Marczak
  2014-05-07  8:07             ` Minkyu Kang
  0 siblings, 1 reply; 40+ messages in thread
From: Przemyslaw Marczak @ 2014-05-06  8:45 UTC (permalink / raw)
  To: u-boot

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 at 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 at 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
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen
  2014-05-06  8:45           ` Przemyslaw Marczak
@ 2014-05-07  8:07             ` Minkyu Kang
  0 siblings, 0 replies; 40+ messages in thread
From: Minkyu Kang @ 2014-05-07  8:07 UTC (permalink / raw)
  To: u-boot

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 at 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.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen Przemyslaw Marczak
  2014-05-05 13:27         ` Minkyu Kang
@ 2014-05-08  2:36         ` Minkyu Kang
  1 sibling, 0 replies; 40+ messages in thread
From: Minkyu Kang @ 2014-05-08  2:36 UTC (permalink / raw)
  To: u-boot

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.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 4/5] samsung: misc: menu: increase delay in menu main loop
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 4/5] samsung: misc: menu: increase delay in menu main loop Przemyslaw Marczak
  2014-05-05 13:35         ` Gerhard Sittig
@ 2014-05-08  2:36         ` Minkyu Kang
  1 sibling, 0 replies; 40+ messages in thread
From: Minkyu Kang @ 2014-05-08  2:36 UTC (permalink / raw)
  To: u-boot

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.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 3/5] samsung: misc: add env default option to lcd menu
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 3/5] samsung: misc: add env default " Przemyslaw Marczak
@ 2014-05-08  2:36         ` Minkyu Kang
  0 siblings, 0 replies; 40+ messages in thread
From: Minkyu Kang @ 2014-05-08  2:36 UTC (permalink / raw)
  To: u-boot

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.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 2/5] samsung: misc: add gpt restore option to lcd menu
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
@ 2014-05-08  2:36         ` Minkyu Kang
  0 siblings, 0 replies; 40+ messages in thread
From: Minkyu Kang @ 2014-05-08  2:36 UTC (permalink / raw)
  To: u-boot

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.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands
  2014-04-30 11:28     ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
                         ` (3 preceding siblings ...)
  2014-04-30 11:28       ` [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen Przemyslaw Marczak
@ 2014-05-08  2:36       ` Minkyu Kang
  4 siblings, 0 replies; 40+ messages in thread
From: Minkyu Kang @ 2014-05-08  2:36 UTC (permalink / raw)
  To: u-boot

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.

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2014-05-08  2:36 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-28 14:30 [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
2014-02-28 14:30 ` [U-Boot] [PATCH 1/3] samsung: misc: check_keys(), key_pressed() - remove type static Przemyslaw Marczak
2014-03-06  6:51   ` Minkyu Kang
2014-03-21  9:13     ` Przemyslaw Marczak
2014-02-28 14:30 ` [U-Boot] [PATCH 2/3] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
2014-02-28 14:30 ` [U-Boot] [PATCH 3/3] samsung: misc: add env default " Przemyslaw Marczak
2014-02-28 14:36 ` [U-Boot] [PATCH 0/3] samsung: misc: add new lcd menu options Przemyslaw Marczak
2014-04-02  9:41 ` [U-Boot] [PATCH v2 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
2014-04-02  9:41   ` [U-Boot] [PATCH v2 2/4] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
2014-04-02  9:42   ` [U-Boot] [PATCH v2 3/4] samsung: misc: add env default " Przemyslaw Marczak
2014-04-02  9:42   ` [U-Boot] [PATCH v2 4/4] samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay Przemyslaw Marczak
2014-04-02 17:26     ` Gerhard Sittig
2014-04-03  7:03       ` Przemyslaw Marczak
2014-04-03  8:27 ` [U-Boot] [PATCH v3 1/4] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
2014-04-03  8:27   ` [U-Boot] [PATCH v3 2/4] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
2014-04-03  8:27   ` [U-Boot] [PATCH v3 3/4] samsung: misc: add env default " Przemyslaw Marczak
2014-04-03  8:27   ` [U-Boot] [PATCH v3 4/4] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay Przemyslaw Marczak
2014-04-25 10:20   ` [U-Boot] [PATCH v4 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
2014-04-25 10:20     ` [U-Boot] [PATCH v4 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
2014-04-25 10:20     ` [U-Boot] [PATCH v4 3/5] samsung: misc: add env default " Przemyslaw Marczak
2014-04-25 10:20     ` [U-Boot] [PATCH v4 4/5] samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay Przemyslaw Marczak
2014-04-28 13:44       ` Gerhard Sittig
2014-04-28 14:03         ` Gerhard Sittig
2014-04-30 10:10         ` Przemyslaw Marczak
2014-04-25 10:20     ` [U-Boot] [PATCH v4 5/5] samsung: misc: remove download mode info screen Przemyslaw Marczak
2014-04-30 11:28     ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Przemyslaw Marczak
2014-04-30 11:28       ` [U-Boot] [PATCH v5 2/5] samsung: misc: add gpt restore option to lcd menu Przemyslaw Marczak
2014-05-08  2:36         ` Minkyu Kang
2014-04-30 11:28       ` [U-Boot] [PATCH v5 3/5] samsung: misc: add env default " Przemyslaw Marczak
2014-05-08  2:36         ` Minkyu Kang
2014-04-30 11:28       ` [U-Boot] [PATCH v5 4/5] samsung: misc: menu: increase delay in menu main loop Przemyslaw Marczak
2014-05-05 13:35         ` Gerhard Sittig
2014-05-06  8:32           ` Przemyslaw Marczak
2014-05-08  2:36         ` Minkyu Kang
2014-04-30 11:28       ` [U-Boot] [PATCH v5 5/5] samsung: misc: remove download mode info screen Przemyslaw Marczak
2014-05-05 13:27         ` Minkyu Kang
2014-05-06  8:45           ` Przemyslaw Marczak
2014-05-07  8:07             ` Minkyu Kang
2014-05-08  2:36         ` Minkyu Kang
2014-05-08  2:36       ` [U-Boot] [PATCH v5 1/5] samsung: misc: allows using environmental macros as args in menu commands Minkyu Kang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.