Skip to contentSkip to conversation

samsung: misc: add new lcd menu options

PATCH New Przemyslaw Marczak 4 participants 40 messages Feb 28, 2014 – May 8, 2014

lore
Share & tools
lore
#0 lore raw

cover samsung: misc: add new lcd menu options

Changes:
- small code refactor
- add menu option: gpt restore
- add menu option: env default

Inha Song (1):
samsung: misc: add env default option to lcd menu

Przemyslaw Marczak (2):
samsung: misc: check_keys(), key_pressed() - remove type static.
samsung: misc: add gpt restore option to lcd menu

 board/samsung/common/misc.c |   60 +++++++++++++++++++++----------------------
 include/samsung/misc.h      |    6 +++++
 2 files changed, 36 insertions(+), 30 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/3 samsung: misc: check_keys(), key_pressed() - remove type static.

This patch removes type "static" from those functions declaration. Now it can be used outside.

Change-Id I2244ca3568b73251401e5102f26cc113ea69c1a4
cc Minkyu Kang <[email protected]>
---
 board/samsung/common/misc.c |    5 ++---
 include/samsung/misc.h      |    4 ++++
 2 files changed, 6 insertions(+), 3 deletions(-)
board/samsung/common/misc.c +2 -3
index eb15739..1d6f4e4 100644
@@ -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;
 
include/samsung/misc.h +4 -0
index ede6c15..47beb1f 100644
@@ -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 */
 
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/3 samsung: misc: check_keys(), key_pressed() - remove type static.

Quoted 2 lines · Przemyslaw Marczak

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.

Quoted 54 lines
Change-Id I2244ca3568b73251401e5102f26cc113ea69c1a4
cc Minkyu Kang <[email protected]>
---
 board/samsung/common/misc.c |    5 ++---
 include/samsung/misc.h      |    4 ++++
 2 files changed, 6 insertions(+), 3 deletions(-)
board/samsung/common/misc.c +2 -3
index eb15739..1d6f4e4 100644
@@ -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;
 
include/samsung/misc.h +2 -0
index ede6c15..47beb1f 100644
@@ -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

include/samsung/misc.h enum { · line 28

Quoted 8 lines
include/samsung/misc.h +2 -0
@@ -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.

#3 lore raw

PATCH 1/3 samsung: misc: check_keys(), key_pressed() - remove type static.

Hello Minkyu,

Quoted 12 lines · Minkyu Kang
Quoted 2 lines · Przemyslaw Marczak

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.

Quoted 4 lines
Change-Id I2244ca3568b73251401e5102f26cc113ea69c1a4
cc Minkyu Kang <[email protected]>

I will resend this patchset when some changes will be applied to GPT code. Thanks

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#4 lore raw

PATCH 2/3 samsung: misc: add gpt restore option to lcd menu

In reply to Przemyslaw Marczak

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
cc Minkyu Kang <[email protected]>
---
 board/samsung/common/misc.c |   52 +++++++++++++++++++++----------------------
 include/samsung/misc.h      |    1 +
 2 files changed, 26 insertions(+), 27 deletions(-)
board/samsung/common/misc.c +25 -27
index 1d6f4e4..c66d262 100644
@@ -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);
 		}
include/samsung/misc.h +1 -0
index 47beb1f..ac0fc0b 100644
@@ -17,6 +17,7 @@ enum {
 	BOOT_MODE_THOR,
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
+	BOOT_MODE_GPT,
 	BOOT_MODE_EXIT,
 };
 
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 3/3 samsung: misc: add env default option to lcd menu

In reply to Przemyslaw Marczak

From: Inha Song <[email protected]>

Change-Id Idded38acfeb63c909fa22ff1a1b1ec77b46d7515
cc Minkyu Kang <[email protected]>
---
 board/samsung/common/misc.c |    3 +++
 include/samsung/misc.h      |    1 +
 2 files changed, 4 insertions(+)
board/samsung/common/misc.c +3 -0
index c66d262..0c13aa1 100644
@@ -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",
 	"",
 };
 
include/samsung/misc.h +1 -0
index ac0fc0b..1fb9e38 100644
@@ -18,6 +18,7 @@ enum {
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
 	BOOT_MODE_GPT,
+	BOOT_MODE_ENV,
 	BOOT_MODE_EXIT,
 };
 
Signature · 1 line
1.7.9.5
#6 lore raw

cover samsung: misc: add new lcd menu options

In reply to Przemyslaw Marczak

Hello,

Quoted 8 lines · Przemyslaw Marczak

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

Quoted 8 lines

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

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#7 lore raw

PATCH v2 1/4 samsung: misc: allows using environmental macros as args in menu commands

In reply to Przemyslaw Marczak

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

---
Changes v2:
- new commit after separate previous commit

---
 board/samsung/common/misc.c | 49 ++++++++++++++++++++-------------------------
 1 file changed, 22 insertions(+), 27 deletions(-)
board/samsung/common/misc.c +22 -27
index 3ff4289..95d1758 100644
@@ -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);
 		}
Signature · 1 line
1.9.0
#8 lore raw

PATCH v2 2/4 samsung: misc: add gpt restore option to lcd menu

This menu option allows restore gpt.
This is usefull and no needs access to the u-boot console. For proper operation:
- each partition uuid should be set in environment or
- CONFIG_RANDOM_UUID should be defined for automatically uuid setting

After operation success device is going to be reset.

---
Changes v2:
- commit separation

---
 board/samsung/common/misc.c | 3 +++
 include/samsung/misc.h      | 1 +
 2 files changed, 4 insertions(+)
board/samsung/common/misc.c +3 -0
index 95d1758..2fd104d 100644
@@ -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",
 	"",
 };
 
include/samsung/misc.h +1 -0
index ede6c15..c3d844b 100644
@@ -15,6 +15,7 @@ enum {
 	BOOT_MODE_THOR,
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
+	BOOT_MODE_GPT,
 	BOOT_MODE_EXIT,
 };
 
Signature · 1 line
1.9.0
#9 lore raw

PATCH v2 3/4 samsung: misc: add env default option to lcd menu

In reply to Przemyslaw Marczak

From: Inha Song <[email protected]>

This change allows reset device environment to default without using u-boot console, which is useful for system developers.

---
Changes v2:
- extend commit message

---
 board/samsung/common/misc.c | 3 +++
 include/samsung/misc.h      | 1 +
 2 files changed, 4 insertions(+)
board/samsung/common/misc.c +3 -0
index 2fd104d..65b5c30 100644
@@ -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",
 	"",
 };
 
include/samsung/misc.h +1 -0
index c3d844b..10653a1 100644
@@ -16,6 +16,7 @@ enum {
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
 	BOOT_MODE_GPT,
+	BOOT_MODE_ENV,
 	BOOT_MODE_EXIT,
 };
 
Signature · 1 line
1.9.0
#10 lore raw

PATCH v2 4/4 samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay

In reply to Przemyslaw Marczak

This change prevents gpio keys debouncing by adding 50 ms delay when key pressed condition met.

---
Changes v2:
- new commit

---
 board/samsung/common/misc.c | 4 ++++
 1 file changed, 4 insertions(+)
board/samsung/common/misc.c +4 -0
index 65b5c30..5b43821 100644
@@ -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;
 }
 
Signature · 1 line
1.9.0
#11 lore raw

PATCH v2 4/4 samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay

Quoted 3 lines · Przemyslaw Marczak

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

Signature · 3 lines
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
#12 lore raw

PATCH v2 4/4 samsung: misc: keys: fix gpio key debouncing by adding 50 ms delay

Hi,

Quoted 5 lines · Gerhard Sittig
Quoted 3 lines · Przemyslaw Marczak

This change prevents gpio keys debouncing by adding 50 ms delay when key pressed condition met.

Quoted 7 lines

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

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#13 lore raw

PATCH v3 1/4 samsung: misc: allows using environmental macros as args in menu commands

In reply to Przemyslaw Marczak

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

---
Changes v2:
- new commit after separate previous commit

Changes v3:
- none

---
 board/samsung/common/misc.c | 49 ++++++++++++++++++++-------------------------
 1 file changed, 22 insertions(+), 27 deletions(-)
board/samsung/common/misc.c +22 -27
index 3ff4289..95d1758 100644
@@ -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);
 		}
Signature · 1 line
1.9.0
#14 lore raw

PATCH v3 2/4 samsung: misc: add gpt restore option to lcd menu

This menu option allows restore gpt.
This is usefull and no needs access to the u-boot console. For proper operation:
- each partition uuid should be set in environment or
- CONFIG_RANDOM_UUID should be defined for automatically uuid setting

After operation success device is going to be reset.

---
Changes v2:
- commit separation

Changes v3:
-none

---
 board/samsung/common/misc.c | 3 +++
 include/samsung/misc.h      | 1 +
 2 files changed, 4 insertions(+)
board/samsung/common/misc.c +3 -0
index 95d1758..2fd104d 100644
@@ -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",
 	"",
 };
 
include/samsung/misc.h +1 -0
index ede6c15..c3d844b 100644
@@ -15,6 +15,7 @@ enum {
 	BOOT_MODE_THOR,
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
+	BOOT_MODE_GPT,
 	BOOT_MODE_EXIT,
 };
 
Signature · 1 line
1.9.0
#15 lore raw

PATCH v3 3/4 samsung: misc: add env default option to lcd menu

In reply to Przemyslaw Marczak

From: Inha Song <[email protected]>

This change allows reset device environment to default without using u-boot console, which is useful for system developers.

---
Changes v2:
- extend commit message

Changes v3:
- none

---
 board/samsung/common/misc.c | 3 +++
 include/samsung/misc.h      | 1 +
 2 files changed, 4 insertions(+)
board/samsung/common/misc.c +3 -0
index 2fd104d..65b5c30 100644
@@ -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",
 	"",
 };
 
include/samsung/misc.h +1 -0
index c3d844b..10653a1 100644
@@ -16,6 +16,7 @@ enum {
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
 	BOOT_MODE_GPT,
+	BOOT_MODE_ENV,
 	BOOT_MODE_EXIT,
 };
 
Signature · 1 line
1.9.0
#16 lore raw

PATCH v3 4/4 samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay

In reply to Przemyslaw Marczak

This change prevents gpio keys bouncing by adding 50 ms delay when key pressed condition met.

---
Changes v2:
- new commit

Changes v3:
- correct commit message

---
 board/samsung/common/misc.c | 4 ++++
 1 file changed, 4 insertions(+)
board/samsung/common/misc.c +4 -0
index 65b5c30..5b43821 100644
@@ -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;
 }
 
Signature · 1 line
1.9.0
#17 lore raw

PATCH v4 1/5 samsung: misc: allows using environmental macros as args in menu commands

In reply to Przemyslaw Marczak

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

---

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(-)
board/samsung/common/misc.c +22 -27
index 3ff4289..95d1758 100644
@@ -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);
 		}
Signature · 1 line
1.9.1
#18 lore raw

PATCH v4 2/5 samsung: misc: add gpt restore option to lcd menu

This menu option allows restore gpt.
This is usefull and no needs access to the u-boot console. For proper operation:
- each partition uuid should be set in environment or
- CONFIG_RANDOM_UUID should be defined for automatically uuid setting

After operation success device is going to be reset.

---
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(+)
board/samsung/common/misc.c +3 -0
index 95d1758..2fd104d 100644
@@ -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",
 	"",
 };
 
include/samsung/misc.h +1 -0
index ede6c15..c3d844b 100644
@@ -15,6 +15,7 @@ enum {
 	BOOT_MODE_THOR,
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
+	BOOT_MODE_GPT,
 	BOOT_MODE_EXIT,
 };
 
Signature · 1 line
1.9.1
#19 lore raw

PATCH v4 3/5 samsung: misc: add env default option to lcd menu

In reply to Przemyslaw Marczak

From: Inha Song <[email protected]>

This change allows reset device environment to default without using u-boot console, which is useful for system developers.

---
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(+)
board/samsung/common/misc.c +3 -0
index 2fd104d..65b5c30 100644
@@ -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",
 	"",
 };
 
include/samsung/misc.h +1 -0
index c3d844b..10653a1 100644
@@ -16,6 +16,7 @@ enum {
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
 	BOOT_MODE_GPT,
+	BOOT_MODE_ENV,
 	BOOT_MODE_EXIT,
 };
 
Signature · 1 line
1.9.1
#20 lore raw

PATCH v4 4/5 samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay

In reply to Przemyslaw Marczak

This change prevents gpio keys bouncing by adding 50 ms delay when key pressed condition met.

---
Changes v2:
- new commit

Changes v3:
- correct commit message

Changes v4:
- none

 board/samsung/common/misc.c | 4 ++++
 1 file changed, 4 insertions(+)
board/samsung/common/misc.c +4 -0
index 65b5c30..5b43821 100644
@@ -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;
 }
 
Signature · 1 line
1.9.1
#21 lore raw

PATCH v4 4/5 samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay

Quoted 6 lines · Przemyslaw Marczak

This change prevents gpio keys bouncing by adding 50 ms delay when key pressed condition met.

[ ... ]

board/samsung/common/misc.c static int check_keys(void) · line 113

Quoted 9 lines
board/samsung/common/misc.c +4 -0
@@ -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

Signature · 3 lines
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
#22 lore raw

PATCH v4 4/5 samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay

Quoted 7 lines · Gerhard Sittig

[ ... ] 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

Signature · 3 lines
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: [email protected]
#23 lore raw

PATCH v4 4/5 samsung: misc: keys: fix gpio key bouncing by adding 50 ms delay

In reply to Gerhard Sittig

Hello Gerhard,

Quoted 35 lines · Gerhard Sittig
Quoted 6 lines · Przemyslaw Marczak

This change prevents gpio keys bouncing by adding 50 ms delay when key pressed condition met.

[ ... ]

board/samsung/common/misc.c static int check_keys(void) · line 113

Quoted 9 lines
board/samsung/common/misc.c +4 -0
@@ -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.

Quoted 7 lines

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.

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#24 lore raw

PATCH v4 5/5 samsung: misc: remove download mode info screen

In reply to Przemyslaw Marczak

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.

---
Changes v4:
- new commit

 board/samsung/common/misc.c | 73 +++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 42 deletions(-)
board/samsung/common/misc.c +31 -42
index 5b43821..c0d8866 100644
@@ -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);
 }
Signature · 1 line
1.9.1
#25 lore raw

PATCH v5 1/5 samsung: misc: allows using environmental macros as args in menu commands

In reply to Przemyslaw Marczak

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

---
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(-)
board/samsung/common/misc.c +22 -27
index 3ff4289..95d1758 100644
@@ -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);
 		}
Signature · 1 line
1.9.1
#26 lore raw

PATCH v5 2/5 samsung: misc: add gpt restore option to lcd menu

This menu option allows restore gpt.
This is usefull and no needs access to the u-boot console. For proper operation:
- each partition uuid should be set in environment or
- CONFIG_RANDOM_UUID should be defined for automatically uuid setting

After operation success device is going to be reset.

---
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(+)
board/samsung/common/misc.c +3 -0
index 95d1758..2fd104d 100644
@@ -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",
 	"",
 };
 
include/samsung/misc.h +1 -0
index ede6c15..c3d844b 100644
@@ -15,6 +15,7 @@ enum {
 	BOOT_MODE_THOR,
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
+	BOOT_MODE_GPT,
 	BOOT_MODE_EXIT,
 };
 
Signature · 1 line
1.9.1
#27 lore raw

PATCH v5 2/5 samsung: misc: add gpt restore option to lcd menu

Quoted 21 lines · Przemyslaw Marczak

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.

---
Changes v2:
- commit separation

Changes v3:
- none

Changes v4:
- none

Quoted 8 lines

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.

#28 lore raw

PATCH v5 3/5 samsung: misc: add env default option to lcd menu

In reply to Przemyslaw Marczak

From: Inha Song <[email protected]>

This change allows reset device environment to default without using u-boot console, which is useful for system developers.

---
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(+)
board/samsung/common/misc.c +3 -0
index 2fd104d..65b5c30 100644
@@ -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",
 	"",
 };
 
include/samsung/misc.h +1 -0
index c3d844b..10653a1 100644
@@ -16,6 +16,7 @@ enum {
 	BOOT_MODE_UMS,
 	BOOT_MODE_DFU,
 	BOOT_MODE_GPT,
+	BOOT_MODE_ENV,
 	BOOT_MODE_EXIT,
 };
 
Signature · 1 line
1.9.1
#29 lore raw

PATCH v5 3/5 samsung: misc: add env default option to lcd menu

Quoted 19 lines · Przemyslaw Marczak

From: Inha Song <[email protected]>

This change allows reset device environment to default without using u-boot console, which is useful for system developers.

---
Changes v2:
- extend commit message

Changes v3:
- none

Changes v4:
- none

Quoted 7 lines

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.

#30 lore raw

PATCH v5 4/5 samsung: misc: menu: increase delay in menu main loop

In reply to Przemyslaw Marczak

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.

---
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(-)
board/samsung/common/misc.c +1 -1
index 65b5c30..2ea275e 100644
@@ -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) {
Signature · 1 line
1.9.1
#31 lore raw

PATCH v5 4/5 samsung: misc: menu: increase delay in menu main loop

Quoted 6 lines · Przemyslaw Marczak

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

Signature · 3 lines
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
#32 lore raw

PATCH v5 4/5 samsung: misc: menu: increase delay in menu main loop

Quoted 8 lines · Gerhard Sittig
Quoted 6 lines · Przemyslaw Marczak

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.

Quoted 8 lines

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

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#33 lore raw

PATCH v5 4/5 samsung: misc: menu: increase delay in menu main loop

In reply to Przemyslaw Marczak
Quoted 19 lines · Przemyslaw Marczak

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.

---
Changes v2:
- new commit

Changes v3:
- correct commit message

Changes v4:
- none

Quoted 8 lines

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.

#34 lore raw

PATCH v5 5/5 samsung: misc: remove download mode info screen

In reply to Przemyslaw Marczak

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.

---
Changes v4:
- new commit

Changes v5:
- none

---
 board/samsung/common/misc.c | 73 +++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 42 deletions(-)
board/samsung/common/misc.c +31 -42
index 2ea275e..03106fd 100644
@@ -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);
 }
Signature · 1 line
1.9.1
#35 lore raw

PATCH v5 5/5 samsung: misc: remove download mode info screen

Dear Przemyslaw Marczak,

Quoted 52 lines · Przemyslaw Marczak

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.

---
Changes v4:
- new commit

Changes v5:
- none

---
 board/samsung/common/misc.c | 73
+++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 42 deletions(-)
board/samsung/common/misc.c +13 -2
index 2ea275e..03106fd 100644
@@ -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);

board/samsung/common/misc.c static void download_menu(void) · line 301

Quoted 10 lines
board/samsung/common/misc.c +9 -0
+
+               /* 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.

Quoted 70 lines
board/samsung/common/misc.c +8 -39
+                       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;
board/samsung/common/misc.c +1 -2
@@ -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

Quoted 5 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Thanks,
Minkyu Kang.

Signature · 2 lines
from. prom.
www.promsoft.net
#36 lore raw

PATCH v5 5/5 samsung: misc: remove download mode info screen

Hello Minkyu,

Quoted 71 lines · Minkyu Kang

Dear Przemyslaw Marczak,

On 30 April 2014 20:28, Przemyslaw Marczak <[email protected] <mailto:[email protected]>> 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.

<mailto:[email protected]>>
Cc: Minkyu Kang <mk7.kang at samsung.com <mailto:[email protected]>>

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

Quoted 2 lines

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

Quoted 76 lines

+ 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:[email protected]>
http://lists.denx.de/mailman/listinfo/u-boot

Quoted 5 lines

Thanks,
Minkyu Kang.
--
from. prom.
www.promsoft.net <http://www.promsoft.net>

Thank you

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#37 lore raw

PATCH v5 5/5 samsung: misc: remove download mode info screen

Dear Przemyslaw Marczak,

Quoted 74 lines · Przemyslaw Marczak

Hello Minkyu,

Quoted 71 lines · Minkyu Kang

Dear Przemyslaw Marczak,

On 30 April 2014 20:28, Przemyslaw Marczak <[email protected] <mailto:[email protected]>> 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.

<mailto:[email protected]>>
Cc: Minkyu Kang <mk7.kang at samsung.com <mailto:[email protected]>>

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

Quoted 5 lines
Quoted 2 lines

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.

#38 lore raw

PATCH v5 5/5 samsung: misc: remove download mode info screen

In reply to Przemyslaw Marczak
Quoted 11 lines · Przemyslaw Marczak

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.

---
Changes v4:
- new commit

Quoted 7 lines

Changes v5:
- none

---
 board/samsung/common/misc.c | 73 +++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 42 deletions(-)

applied to u-boot-samsung.

Thanks,
Minkyu Kang.

#39 lore raw

PATCH v5 1/5 samsung: misc: allows using environmental macros as args in menu commands

In reply to Przemyslaw Marczak
Quoted 23 lines · Przemyslaw Marczak

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

---
Changes v2:
- new commit after separate previous commit

Changes v3:
- none

Changes v4:
- none

Quoted 7 lines

Changes v5:
- none

---
 board/samsung/common/misc.c | 49 ++++++++++++++++++++-------------------------
 1 file changed, 22 insertions(+), 27 deletions(-)

applied to u-boot-samsung.

Thanks,
Minkyu Kang.