Reputation: 14059
There's a problem with bootloader of my embedded board. Sometimes it fails to boot after restart.
The problem has been tracked down to RedBoot, which waits (0.1s) for "ctrl-C" to abort booting and enter interactive mode where you can edit it. The problem is that while a randomly occurring "ctrl-C" character on unconnected serial console is extremely unlikely, any, random character is sometimes induced "out of air", and then RedBoot stops at the prompt "== Executing boot script in 0.100 seconds - enter ^C to abort" until either one presses enter, deletes the offending character (with backspace) or enters RedBoot with ctrl-C.
Is there some way to disable this "feature" without disabling ability to reach the "RedBoot>" prompt entirely?
Upvotes: 0
Views: 379
Reputation: 36
An old thread, but I just encountered exactly the same problem. In my case it is because the Redboot console serial port is tied to another embedded Windows system that is powered up at the same time. A short burst of noise on the serial port in that scenario is always guaranteed and Redboot would always get stuck as described by the original question!
My fix was quite simple - in main.c
, function cyg_start()
:
diff --git a/packages/redboot/current/src/main.c b/packages/redboot/current/src/main.c
index 0531dcc..9b1ce97 100644
--- a/packages/redboot/current/src/main.c
+++ b/packages/redboot/current/src/main.c
@@ -356,26 +356,11 @@ cyg_start(void)
# endif
if (script) {
// Give the guy a chance to abort any boot script
- char *hold_script = script;
int script_timeout_ms = script_timeout * CYGNUM_REDBOOT_BOOT_SCRIPT_TIMEOUT_RESOLUTION;
diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
script_timeout_ms/1000, script_timeout_ms%1000);
- script = NULL;
- res = _GETS_CTRLC; // Treat 0 timeout as ^C
- while (script_timeout_ms >= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT) {
- res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
- if (res >= _GETS_OK) {
- diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
- script_timeout_ms/1000, script_timeout_ms%1000);
- continue; // Ignore anything but ^C
- }
- if (res != _GETS_TIMEOUT) break;
- script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT;
- }
- if (res == _GETS_CTRLC) {
+ if (_rb_break(script_timeout_ms)) {
script = NULL; // Disable script
- } else {
- script = hold_script; // Re-enable script
}
}
#endif
CTRL-C is still able to be used to abort the boot script if required, but any other character (including a spurious character created by noise) is interpreted immediately as a timeout. In my scenario this is perfect as the only time you would want to be able to type CTRL-C is if you manually reset the Redboot board and has a serial console open on the embedded Windows system to watch what was happening.
Upvotes: 2