[U-Boot-Users] Can U-boot Autodetect arch/ppcversusarch/powerpc from info in the uImage?
Joakim Tjernlund
joakim.tjernlund at transmode.se
Mon Dec 17 15:42:45 CET 2007
On Sun, 2007-12-16 at 22:27 +0100, Joakim Tjernlund wrote:
> > -----Original Message-----
> > From: wd at denx.de [mailto:wd at denx.de]
> > Sent: den 16 december 2007 21:15
> > To: joakim.tjernlund at transmode.se
> > Cc: 'Jerry Van Baren'; u-boot-users at lists.sourceforge.net
> > Subject: Re: [U-Boot-Users] Can U-boot Autodetect
> > arch/ppcversusarch/powerpc from info in the uImage?
> >
> > In message
> > <1197647601.21876.12.camel at gentoo-jocke.transmode.se> you wrote:
> > >
> > > This is what I came up with to make $dtb a hush variable that don't
> > > end up in the environment:
> >
> > > #define FLAG_PARSE_SEMICOLON (1 << 1)
> > > #define FLAG_EXIT_FROM_LOOP 1
> > > int misc_init_r (void)
> > > {
> > > char *bootstr, dtb_str[30], workstr[256];
> > >
> > > u_boot_hush_start();
> >
> > Be careful. You are invoking undefined behaviour heare. The idea is
> > that u_boot_hush_start() is supposed to be called exactly once only.
> > [Yes, I know from looking at the code that at the moment this seems
> > to be OK, but ther eis no guarantee for it.]
>
> Yes, I suspected this. Maybe it would be a good idea to move the call
> to u_boot_hush_start() earlier in common code so that there is no need
> to do it here?
>
> >
> > > sprintf(dtb_str, "dtb=0x%lx", (ulong)dt_blob_start);
> > > /* Set $dtb in local HUSH env.to my OF tree */
> > > if (parse_string_outer(dtb_str,
> > > FLAG_PARSE_SEMICOLON |
> > FLAG_EXIT_FROM_LOOP) != 0) {
> > > /* Add " - $dtb" to $bootcmd if it is missing */
> > > bootstr = getenv("bootcmd");
> > > if (bootstr && !strstr(bootstr, "- $dtb")) {
> > > strcpy(workstr, bootstr);
> > > strcat(workstr, " - $dtb");
> > > setenv("bootcmd", workstr);
> > > }
> > > }
> > > return 0;
> > > }
> > >
> > > It is fairly ugly, but it works. Comments?
> >
> > I don't understand why you make it so complicated when a preboot
> > command would do exactly the same?
>
> hmm, didn't think of that. Will look into that tmw, thanks
There is a chance that the preboot variable will end up in the
environment and that could break the old boot when downgrading.
Anyhow, I got an solution now that works and after a few releases, I
can remove it.
When looking through the code I noticed that there is a lot of #ifdef
CFG_HUSH_PARSER, especially code like this:
#ifndef CFG_HUSH_PARSER
if (run_command (arg, flag) == -1)
return 1;
#else
if (parse_string_outer(arg,
FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0)
return 1;
#endif
It seems to me that arse_string_outer() could be moved inside the
run_command() instead. That would make the code cleaner and make the
image smaller. I guess there is a reason why it is the way it is?
Jocke
More information about the U-Boot
mailing list