[ECOS] Is there any way to branch in Boot Script

Sergei Gavrikov w3sg@SoftHome.net
Wed Jul 18 18:10:00 GMT 2007


On Tue, Jul 17, 2007 at 04:37:33PM +0900, ariga masahiro wrote:
> Hi,Everyone,
> 
> I beseech you to help me out of next predicament.
> 
> What I want to do is this:
>  In RedBoot Boot Script,read Target Board DIPSW-settled value,
>  and compare already-written value in a certain address.
>  (for example,use mcmp command)
>  If same, continue next Boot Script command.
>  If differs,quit Boot Script and return to RedBoot's prompt.
> 
> My questions are:
>  1.Is there any way to know mcmp result(that is ,succeeded or errored).
>    Preferably in RedBoot Boot Script.
>  2.Is there any way to use branching statement(like,if-else),
>    in RedBoot Boot Script

It's pity, but RedBoot != shell, so it hasn't such behaviours. Some guys
dream about those behaviours :-) But, every RedBoot command (redboot.h)
is just it

typedef void cmd_fun(int argc, char *argv[]);

Therefore, it is no way to return any result (Ups, I did think about
`argv' :). Also, there is no global variable, something like the DOS
`errorlevel' (to check/collect the fails) there. More that, if the
RedBoot's parser does meet wrong line in a script, it passes the line a
bit noisely and then it continues to parse a rest of the script.
 
>  3.Is there any way to realize above-mentioned "what I want to do".

I had same needs (to read the DIP switches). And I did use such a way.
Well, if your RedBoot/eCos aren't fucked binaries, i.e. if you have the
target sources, you can put same stuff in your plf_misc.c file

---------------------------------------------------------->8
#include <pkgconf/system.h>

#ifdef CYGPKG_REDBOOT
#include <redboot.h>            // script declaration

#define DIPSW_MASK (1 << 7)     // FIXME: put yours

#ifdef CYGSEM_REDBOOT_PLF_STARTUP
void
cyg_plf_redboot_startup (void)
{
    int             switches = 0;

    // put a code to read the switches here

    if (switches & DIPSW_MASK)
        // don't run the script
        script = 0;
}
#endif // CYGSEM_REDBOOT_PLF_STARTUP
#endif // CYGPKG_REDBOOT
---------------------------------------------------------->8

Note: before to build RedBoot with this tweak, set this option in your
`ecos.ecc':

cdl_option CYGSEM_REDBOOT_PLF_STARTUP {user_value 1};

For more details, look at cyg_start () in redboot/current/src/main.c,
you would find your own way for that.


Sergei



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



More information about the Ecos-discuss mailing list