[U-Boot] [[PATCH V2 1/1] console: Improve TFTP booting performance

Jim Lin jilin at nvidia.com
Thu Mar 21 11:23:28 CET 2013


TFTP booting is observed a little bit slow, especially when a USB
keyboard is installed.
The fix is to check whether Ctrl-C key is pressed every
CONFIG_CTRLC_POLL_S second.

Signed-off-by: Jim Lin <jilin at nvidia.com>
---
Changes in V2:
 1. Change configuration name from CONFIG_CTRLC_POLL_MS to CONFIG_CTRLC_POLL_S.
 2. New code will be executed only when CONFIG_CTRLC_POLL_S is defined in
    configuration header file.
 3. Add description in README.console.

 common/console.c   |   16 ++++++++++++++++
 doc/README.console |   10 ++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/common/console.c b/common/console.c
index bf73178..b09e129 100644
--- a/common/console.c
+++ b/common/console.c
@@ -521,12 +521,28 @@ int vprintf(const char *fmt, va_list args)
 	return i;
 }
 
+#ifdef CONFIG_CTRLC_POLL_S
+/*
+ * Process Ctrl-C every CONFIG_CTRLC_POLL_S second(s) to improve performance
+ * (like TFTP boot) when interlaced with other tasks like USB KB
+ * polling.
+ */
+static unsigned long ctrlc_ts = (CONFIG_CTRLC_POLL_S * CONFIG_SYS_HZ);
+#endif
+
 /* test if ctrl-c was pressed */
 static int ctrlc_disabled = 0;	/* see disable_ctrl() */
 static int ctrlc_was_pressed = 0;
 int ctrlc(void)
 {
 	if (!ctrlc_disabled && gd->have_console) {
+#ifdef CONFIG_CTRLC_POLL_S
+		if (get_timer(ctrlc_ts) < (CONFIG_CTRLC_POLL_S
+				* CONFIG_SYS_HZ))
+			return 0;
+		else
+			ctrlc_ts = get_timer(0);
+#endif
 		if (tstc()) {
 			switch (getc()) {
 			case 0x03:		/* ^C - Control C */
diff --git a/doc/README.console b/doc/README.console
index b353f9f..6b38b8c 100644
--- a/doc/README.console
+++ b/doc/README.console
@@ -116,3 +116,13 @@ CREDITS for other contact informations):
 
 - MPC823FADS with AD7176 on a PAL TV (YCbYCr)	- arsenio at tin.it
 - GENIETV    with AD7177 on a PAL TV (YCbYCr)	- arsenio at tin.it
+
+Config Switches:
+----------------
+CONFIG_CTRLC_POLL_S	define a value to check whether Ctrl-C is pressed
+			every defined second(s). This is to improve TFTP
+			booting if USB KB is installed and polling is used.
+			For example:
+			Define the following in configuration header file
+			#define CONFIG_CTRLC_POLL_S	1
+			for console to check Ctrl-C every second.
-- 
1.7.7



More information about the U-Boot mailing list