This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Is there any way to branch in Boot Script
- From: Sergei Gavrikov <w3sg at SoftHome dot net>
- To: ariga masahiro <ariga at link-lab dot co dot jp>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Wed, 18 Jul 2007 21:24:20 +0300
- Subject: Re: [ECOS] Is there any way to branch in Boot Script
- References: <001901c7c845$567efd10$1c0110ac@ariga> <20070718180907.GA9721@ubuntu>
On Wed, Jul 18, 2007 at 09:09:07PM +0300, Sergei Gavrikov wrote:
> 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.
>
A bit more, redboot.cdl contains yet another option... So, with a code
above, you can run an alternate script instead default one, if you put
there something like this
cdl_option CYGDAT_REDBOOT_DEFAULT_BOOT_SCRIPT {1 {alt_script}};
Note: a declaration/filling that `alt_script' is your deal, certainly.
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