This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: custom code to bypass redboot abort script


n.b. this should really have been posted to ecos-patches

Jose Vasconcellos wrote:
I have a device that does not have an easily accessible serial port.
Access to redboot is normally done via telnet from the ethernet port.
Of course, if there's a boot script installed then there's no opportunity
to abort the script. It does have a button, so I wanted the user to
power-on with the button pressed to bypass or abort the start-up script.
I had to rework packages/redboot/current/main.c

The following patch creates a function redboot_abort_script that handles
the existing console check. The idea is to be able to replace this routine
for unusual cases.

I don't see what your patch does other than factor out this portion of the code. Are you expecting to add other features, such as the ability to add a platform defined test which simulates ^C?

Also if your platform doesn't have a serial port, how does one see the
message/prompt?

diff -r 690e1f51d092 packages/redboot/current/src/main.c
--- a/packages/redboot/current/src/main.c    Sun May 04 17:02:34 2008 -0400
+++ b/packages/redboot/current/src/main.c    Mon Aug 25 15:05:11 2008 -0400
@@ -234,6 +234,25 @@
}
#endif

+// Check for ^C on console
+bool redboot_abort_script(int script_timeout_ms)
+{
+ int res = _GETS_CTRLC; // Treat 0 timeout as ^C
+ diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
+ script_timeout_ms/1000, script_timeout_ms%1000);
+
+ 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;
+ }
+ return res == _GETS_CTRLC;
+}


//
// This is the main entry point for RedBoot
@@ -337,26 +356,10 @@
# endif
if (script) {
// Give the guy a chance to abort any boot script
- unsigned 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 = (unsigned char *)0;
- 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) {
+ res = redboot_abort_script(script_timeout_ms);
+ if (res) {

I don't like this change. I would prefer it still use the full test (res == _GETS_CTRLC).

            script = (unsigned char *)0;  // Disable script
-        } else {
-            script = hold_script;  // Re-enable script
        }
    }
#endif

Perhaps you can expand on what you're really after here. Please post further discussion to the patches list.

--
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]