mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* RFC: Force a 2s delay on startup to allow bypassing /dev/env0.
@ 2012-05-05 21:26 Krzysztof Halasa
  2012-05-06 17:16 ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Krzysztof Halasa @ 2012-05-05 21:26 UTC (permalink / raw)
  To: barebox

Just requesting comments. I'm using this on my hw.

The idea is that /env/bin/init may be uninterruptible and the user
may be unable to recover control over the barebox. Perhaps there is
a better way?

Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>

diff --git a/common/startup.c b/common/startup.c
index abd1b77..fde99d5 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -30,6 +30,7 @@
  * @brief Main entry into the C part of barebox
  */
 #include <common.h>
+#include <clock.h>
 #include <init.h>
 #include <command.h>
 #include <malloc.h>
@@ -117,6 +118,8 @@ void start_barebox (void)
 	int result;
 #ifdef CONFIG_COMMAND_SUPPORT
 	struct stat s;
+	uint64_t start;
+	int stop = 0;
 #endif
 
 	for (initcall = __barebox_initcalls_start;
@@ -130,6 +133,17 @@ void start_barebox (void)
 
 	display_meminfo();
 
+#ifdef CONFIG_COMMAND_SUPPORT
+	start = get_time_ns();
+	printf("\nPress Control-C to stop.");
+	while (!is_timeout(start, 2 * SECOND))
+		if (ctrlc()) {
+			stop = 1;
+			break;
+		}
+	putchar('\n');
+#endif
+
 #ifdef CONFIG_ENV_HANDLING
 	if (envfs_load(default_environment_path, "/env")) {
 #ifdef CONFIG_DEFAULT_ENVIRONMENT
@@ -141,14 +155,16 @@ void start_barebox (void)
 	}
 #endif
 #ifdef CONFIG_COMMAND_SUPPORT
-	printf("running /env/bin/init...\n");
-
-	if (!stat("/env/bin/init", &s)) {
+	if (stop)
+		printf("skipping /env/bin/init\n");
+	else if (!stat("/env/bin/init", &s)) {
+		printf("running /env/bin/init...\n");
 		run_command("source /env/bin/init", 0);
-	} else {
-		printf("not found\n");
-	}
+	} else
+		printf("/env/bin/init not found\n");
+
 #endif
+
 	/* main_loop() can return to retry autoboot, if so just run it again. */
 	for (;;)
 		run_shell();

-- 
Krzysztof Halasa

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: RFC: Force a 2s delay on startup to allow bypassing /dev/env0.
  2012-05-05 21:26 RFC: Force a 2s delay on startup to allow bypassing /dev/env0 Krzysztof Halasa
@ 2012-05-06 17:16 ` Sascha Hauer
  2012-05-06 17:50   ` Krzysztof Halasa
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2012-05-06 17:16 UTC (permalink / raw)
  To: Krzysztof Halasa; +Cc: barebox

On Sat, May 05, 2012 at 11:26:22PM +0200, Krzysztof Halasa wrote:
> Just requesting comments. I'm using this on my hw.
> 
> The idea is that /env/bin/init may be uninterruptible and the user
> may be unable to recover control over the barebox. Perhaps there is
> a better way?

Being able to interrupt before environment processing is a good thing to
have, the delay though is not acceptable because it would increase the
boot time on some systems by 400%. It should work without the delay
aswell.

Sascha


> 
> Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
> 
> diff --git a/common/startup.c b/common/startup.c
> index abd1b77..fde99d5 100644
> --- a/common/startup.c
> +++ b/common/startup.c
> @@ -30,6 +30,7 @@
>   * @brief Main entry into the C part of barebox
>   */
>  #include <common.h>
> +#include <clock.h>
>  #include <init.h>
>  #include <command.h>
>  #include <malloc.h>
> @@ -117,6 +118,8 @@ void start_barebox (void)
>  	int result;
>  #ifdef CONFIG_COMMAND_SUPPORT
>  	struct stat s;
> +	uint64_t start;
> +	int stop = 0;
>  #endif
>  
>  	for (initcall = __barebox_initcalls_start;
> @@ -130,6 +133,17 @@ void start_barebox (void)
>  
>  	display_meminfo();
>  
> +#ifdef CONFIG_COMMAND_SUPPORT
> +	start = get_time_ns();
> +	printf("\nPress Control-C to stop.");
> +	while (!is_timeout(start, 2 * SECOND))
> +		if (ctrlc()) {
> +			stop = 1;
> +			break;
> +		}
> +	putchar('\n');
> +#endif
> +
>  #ifdef CONFIG_ENV_HANDLING
>  	if (envfs_load(default_environment_path, "/env")) {
>  #ifdef CONFIG_DEFAULT_ENVIRONMENT
> @@ -141,14 +155,16 @@ void start_barebox (void)
>  	}
>  #endif
>  #ifdef CONFIG_COMMAND_SUPPORT
> -	printf("running /env/bin/init...\n");
> -
> -	if (!stat("/env/bin/init", &s)) {
> +	if (stop)
> +		printf("skipping /env/bin/init\n");
> +	else if (!stat("/env/bin/init", &s)) {
> +		printf("running /env/bin/init...\n");
>  		run_command("source /env/bin/init", 0);
> -	} else {
> -		printf("not found\n");
> -	}
> +	} else
> +		printf("/env/bin/init not found\n");
> +
>  #endif
> +
>  	/* main_loop() can return to retry autoboot, if so just run it again. */
>  	for (;;)
>  		run_shell();
> 
> -- 
> Krzysztof Halasa
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: RFC: Force a 2s delay on startup to allow bypassing /dev/env0.
  2012-05-06 17:16 ` Sascha Hauer
@ 2012-05-06 17:50   ` Krzysztof Halasa
  2012-05-06 18:08     ` Sascha Hauer
  2012-05-07  0:14     ` Marc Reilly
  0 siblings, 2 replies; 5+ messages in thread
From: Krzysztof Halasa @ 2012-05-06 17:50 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Sascha Hauer <s.hauer@pengutronix.de> writes:

> Being able to interrupt before environment processing is a good thing to
> have, the delay though is not acceptable because it would increase the
> boot time on some systems by 400%. It should work without the delay
> aswell.

Actually the delay is a bit problematic for me as well.
Unfortunately the boot code has to initialize the serial port, clearing
the incoming FIFO. This means I can't "queue" the ^C character, barebox
has to wait for it (maybe not for the whole 2 seconds).

Or am I mistaken?
-- 
Krzysztof Halasa

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: RFC: Force a 2s delay on startup to allow bypassing /dev/env0.
  2012-05-06 17:50   ` Krzysztof Halasa
@ 2012-05-06 18:08     ` Sascha Hauer
  2012-05-07  0:14     ` Marc Reilly
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2012-05-06 18:08 UTC (permalink / raw)
  To: Krzysztof Halasa; +Cc: barebox

On Sun, May 06, 2012 at 07:50:14PM +0200, Krzysztof Halasa wrote:
> Sascha Hauer <s.hauer@pengutronix.de> writes:
> 
> > Being able to interrupt before environment processing is a good thing to
> > have, the delay though is not acceptable because it would increase the
> > boot time on some systems by 400%. It should work without the delay
> > aswell.
> 
> Actually the delay is a bit problematic for me as well.
> Unfortunately the boot code has to initialize the serial port, clearing
> the incoming FIFO. This means I can't "queue" the ^C character, barebox
> has to wait for it (maybe not for the whole 2 seconds).
> 
> Or am I mistaken?

On my boards I can still interrupt even with autoboot_timeout=0. Have
you tried it? It may be a bit dependent on the UART driver, I don't
know.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: RFC: Force a 2s delay on startup to allow bypassing /dev/env0.
  2012-05-06 17:50   ` Krzysztof Halasa
  2012-05-06 18:08     ` Sascha Hauer
@ 2012-05-07  0:14     ` Marc Reilly
  1 sibling, 0 replies; 5+ messages in thread
From: Marc Reilly @ 2012-05-07  0:14 UTC (permalink / raw)
  To: barebox; +Cc: Krzysztof Halasa


[-- Attachment #1.1: Type: text/plain, Size: 854 bytes --]

On Monday, May 07, 2012 03:50:14 AM Krzysztof Halasa wrote:
> Sascha Hauer <s.hauer@pengutronix.de> writes:
> > Being able to interrupt before environment processing is a good thing to
> > have, the delay though is not acceptable because it would increase the
> > boot time on some systems by 400%. It should work without the delay
> > aswell.

I agree, adding 2 seconds to boot time wouldn't be very well received.

Our board has several gpio buttons which are checked for a specific press 
configuration at startup, eg, when buttons 1,3 and 4 only are held down, the 
auto boot is delayed.
This is obviously dependent on board hardware, but does make any delay 
optional. 

This is in our init script itself, but could just as easily be coded to check 
before the init script is run. You could set it up as a board installed 
callback...

Cheers,
Marc

[-- Attachment #1.2: Type: text/html, Size: 3756 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2012-05-07  0:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-05 21:26 RFC: Force a 2s delay on startup to allow bypassing /dev/env0 Krzysztof Halasa
2012-05-06 17:16 ` Sascha Hauer
2012-05-06 17:50   ` Krzysztof Halasa
2012-05-06 18:08     ` Sascha Hauer
2012-05-07  0:14     ` Marc Reilly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox