public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] hush while confusion
@ 2009-10-22  8:38 David Collier
  2009-10-22 11:31 ` Wolfgang Denk
  0 siblings, 1 reply; 11+ messages in thread
From: David Collier @ 2009-10-22  8:38 UTC (permalink / raw)
  To: u-boot

thanks to everyone I have a working bootcmd which stops if the mmc card
is extracted.

what I'd like to do is put it in a while loop - this is an embedded
system and it has nothing better to do than to try again.

but if I set up 

bootcmd=while [ .... ]; do ; mmcinit && ext2load mmc 0:1 0x10400000
/boot/uImage && bootm 0x10400000 ; done

no matter what I have put in or around the [..] area, it barfs.

Could anyone show me a working example of a hush while loop please? Or
tell me what I'm doing wrong :-)


David Collier

www.dexdyne.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] hush while confusion
  2009-10-22  8:38 [U-Boot] hush while confusion David Collier
@ 2009-10-22 11:31 ` Wolfgang Denk
  2009-10-22 13:22   ` David Collier
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Denk @ 2009-10-22 11:31 UTC (permalink / raw)
  To: u-boot

Dear "David Collier",

In message <memo.20091022093854.2092B@postmaster+dexdyne.com.cix.co.uk> you wrote:
> 
> what I'd like to do is put it in a while loop - this is an embedded
> system and it has nothing better to do than to try again.
> 
> but if I set up 
> 
> bootcmd=while [ .... ]; do ; mmcinit && ext2load mmc 0:1 0x10400000
> /boot/uImage && bootm 0x10400000 ; done
> 
> no matter what I have put in or around the [..] area, it barfs.

Did you understand why it barfs? The '[' is actually a command name,
which usually is a synonym for the 'test' command. U-Boot does not
provide such a coimmand, and the hush shell does not provide it as
shell builtin either, so this _must_ fail.

I am surprised that you did not find this out yourself - U-Boot should
issue a pretty clear error message, something like

	Unknown command '[' - try 'help'

> Could anyone show me a working example of a hush while loop please? Or
> tell me what I'm doing wrong :-)

Here is a (tested and working) example:

	=> mw 200000 0
	=> while itest *200000 == 0 ; do
	> tftp 200000 tqm5200/uImage
	> echo === done ====
	> done
	Using FEC ETHERNET device
	TFTP from server 192.168.1.1; our IP address is 192.168.160.4
	Filename 'tqm5200/uImage'.
	Load address: 0x200000
	Loading: #################################################################
	         ############################################################
	done
	Bytes transferred = 1830503 (1bee67 hex)
	=== done ====
	=> 

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Where shall I begin, please your Majesty?" he asked. "Begin  at  the
beginning,"  the  King said, gravely, "and go on till you come to the
end: then stop."    - Alice's Adventures in Wonderland, Lewis Carroll

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] hush while confusion
  2009-10-22 11:31 ` Wolfgang Denk
@ 2009-10-22 13:22   ` David Collier
  2009-10-22 13:27     ` Örjan Friberg
                       ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: David Collier @ 2009-10-22 13:22 UTC (permalink / raw)
  To: u-boot


OK I have changed it to

while 1==1 ; do ; mmcinit && ext2load mmc 0:1 0x10400000  /boot/uImage &&
bootm 0x10400000 ; done

and if I do run bootcmd it simply says "unknown command 1==1"

so I'm still lost....

I know I have hush installed, cosz if I do your multi-line-version I get
the prompt.

------------------------------------------------------------

All I saw about hush was "bourne-compatible", and "provides
while...do..done" scripting.

I failed to find a proper manual... probably for lack of effort, but I've
just googled again and nothing springs up..

Could you possibly point me at any hush documentation ?

Many thanks

David 


In article <20091022113139.DB6961A00B@gemini.denx.de>, wd at denx.de
(Wolfgang Denk) wrote:

> *From:* Wolfgang Denk <wd@denx.de>
> *To:* from_denx_uboot at dexdyne.com
> *CC:* u-boot at lists.denx.de
> *Date:* Thu, 22 Oct 2009 13:31:39 +0200
> 
> Dear "David Collier",
> 
> In message 
> <memo.20091022093854.2092B@postmaster+dexdyne.com.cix.co.uk> you 
> wrote:
> > 
> > what I'd like to do is put it in a while loop - this is an 
> > embedded
> > system and it has nothing better to do than to try again.
> > 
> > but if I set up 
> > 
> > bootcmd=while [ .... ]; do ; mmcinit && ext2load mmc 0:1 
> > 0x10400000
> > /boot/uImage && bootm 0x10400000 ; done
> > 
> > no matter what I have put in or around the [..] area, it barfs.
> 
> Did you understand why it barfs? The '[' is actually a command name,
> which usually is a synonym for the 'test' command. U-Boot does not
> provide such a coimmand, and the hush shell does not provide it as
> shell builtin either, so this _must_ fail.
> 
> I am surprised that you did not find this out yourself - U-Boot 
> should
> issue a pretty clear error message, something like
> 
> 	Unknown command '[' - try 'help'
> 
> > Could anyone show me a working example of a hush while loop 
> > please? Or
> > tell me what I'm doing wrong :-)
> 
> Here is a (tested and working) example:
> 
> 	=> mw 200000 0
> 	=> while itest *200000 == 0 ; do
> 	> tftp 200000 tqm5200/uImage
> 	> echo === done ====
> 	> done
> 	Using FEC ETHERNET device
> 	TFTP from server 192.168.1.1; our IP address is 192.168.160.4
> 	Filename 'tqm5200/uImage'.
> 	Load address: 0x200000
> 	Loading: 
> #################################################################
> 	         
> ############################################################
> 	done
> 	Bytes transferred = 1830503 (1bee67 hex)
> 	=== done ====
> 	=> 
> 
> Best regards,
> 
> Wolfgang Denk
> 
> -- 
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev 
> Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, 
> Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: 
> wd at denx.de
> "Where shall I begin, please your Majesty?" he asked. "Begin  at  
> the
> beginning,"  the  King said, gravely, "and go on till you come to 
> the
> end: then stop."    - Alice's Adventures in Wonderland, Lewis 
> Carroll
> 


Collier

www.dexdyne.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] hush while confusion
  2009-10-22 13:22   ` David Collier
@ 2009-10-22 13:27     ` Örjan Friberg
  2009-10-22 18:07       ` Wolfgang Denk
  2009-10-22 13:28     ` David Collier
  2009-10-22 13:29     ` Wolfgang Denk
  2 siblings, 1 reply; 11+ messages in thread
From: Örjan Friberg @ 2009-10-22 13:27 UTC (permalink / raw)
  To: u-boot

> -----Original Message-----
> From: u-boot-bounces at lists.denx.de [mailto:u-boot-
> bounces at lists.denx.de] On Behalf Of David Collier
> Sent: den 22 oktober 2009 15:22
> To: u-boot at lists.denx.de
> Subject: Re: [U-Boot] hush while confusion
> 
> 
> OK I have changed it to
> 
> while 1==1 ; do ; mmcinit && ext2load mmc 0:1 0x10400000  /boot/uImage
> &&
> bootm 0x10400000 ; done

Replace the "1==1" with ":" and skip the ";" after "do"

/Orjan

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] hush while confusion
  2009-10-22 13:22   ` David Collier
  2009-10-22 13:27     ` Örjan Friberg
@ 2009-10-22 13:28     ` David Collier
  2009-10-22 18:05       ` Wolfgang Denk
  2009-10-22 13:29     ` Wolfgang Denk
  2 siblings, 1 reply; 11+ messages in thread
From: David Collier @ 2009-10-22 13:28 UTC (permalink / raw)
  To: u-boot


sorry - my fault - I failed to grasp the meaning of itest

This now works

while itest 1 == 1 ; do ; mmcinit && ext2load mmc 0:1 0x10400000
/boot/uImage && bootm 0x10400000 ; done

I could do with a literal "true" - I tried 'true' but that wasn't right -
is there a suitable constant value?

I'd still love to find some teaching stuff on this - I can't keep
bothering important people like you :-)

David

In article <memo.20091022142208.2092E@postmaster+dexdyne.com.cix.co.uk>,
from_denx_uboot at dexdyne.com (David Collier) wrote:

> *From:* "David Collier" <from_denx_uboot@dexdyne.com>
> *To:* u-boot at lists.denx.de
> *Date:* Thu, 22 Oct 2009 14:22 +0100 (BST)
> 
> OK I have changed it to
> 
> while 1==1 ; do ; mmcinit && ext2load mmc 0:1 0x10400000  
> /boot/uImage &&
> bootm 0x10400000 ; done
> 
> and if I do run bootcmd it simply says "unknown command 1==1"
> 
> so I'm still lost....
> 
> I know I have hush installed, cosz if I do your multi-line-version 
> I get
> the prompt.
> 
> ------------------------------------------------------------
> 
> All I saw about hush was "bourne-compatible", and "provides
> while...do..done" scripting.
> 
> I failed to find a proper manual... probably for lack of effort, 
> but I've
> just googled again and nothing springs up..
> 
> Could you possibly point me at any hush documentation ?
> 
> Many thanks
> 
> David 
> 
> 
> In article <20091022113139.DB6961A00B@gemini.denx.de>, wd at denx.de
> (Wolfgang Denk) wrote:
> 
> > *From:* Wolfgang Denk <wd@denx.de>
> > *To:* from_denx_uboot at dexdyne.com
> > *CC:* u-boot at lists.denx.de
> > *Date:* Thu, 22 Oct 2009 13:31:39 +0200
> > 
> > Dear "David Collier",
> > 
> > In message 
> > <memo.20091022093854.2092B@postmaster+dexdyne.com.cix.co.uk> you 
> > wrote:
> > > 
> > > what I'd like to do is put it in a while loop - this is an 
> > > embedded
> > > system and it has nothing better to do than to try again.
> > > 
> > > but if I set up 
> > > 
> > > bootcmd=while [ .... ]; do ; mmcinit && ext2load mmc 0:1 
> > > 0x10400000
> > > /boot/uImage && bootm 0x10400000 ; done
> > > 
> > > no matter what I have put in or around the [..] area, it barfs.
> > 
> > Did you understand why it barfs? The '[' is actually a command 
> > name,
> > which usually is a synonym for the 'test' command. U-Boot does not
> > provide such a coimmand, and the hush shell does not provide it as
> > shell builtin either, so this _must_ fail.
> > 
> > I am surprised that you did not find this out yourself - U-Boot 
> > should
> > issue a pretty clear error message, something like
> > 
> > 	Unknown command '[' - try 'help'
> > 
> > > Could anyone show me a working example of a hush while loop 
> > > please? Or
> > > tell me what I'm doing wrong :-)
> > 
> > Here is a (tested and working) example:
> > 
> > 	=> mw 200000 0
> > 	=> while itest *200000 == 0 ; do
> > 	> tftp 200000 tqm5200/uImage
> > 	> echo === done ====
> > 	> done
> > 	Using FEC ETHERNET device
> > 	TFTP from server 192.168.1.1; our IP address is 192.168.160.4
> > 	Filename 'tqm5200/uImage'.
> > 	Load address: 0x200000
> > 	Loading: 
> > #################################################################
> > 	         
> > ############################################################
> > 	done
> > 	Bytes transferred = 1830503 (1bee67 hex)
> > 	=== done ====
> > 	=> 
> > 
> > Best regards,
> > 
> > Wolfgang Denk
> > 
> > -- 
> > DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev 
> > Zundel
> > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, 
> > Germany
> > Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: 
> > wd at denx.de
> > "Where shall I begin, please your Majesty?" he asked. "Begin  at  
> > the
> > beginning,"  the  King said, gravely, "and go on till you come to 
> > the
> > end: then stop."    - Alice's Adventures in Wonderland, Lewis 
> > Carroll
> > 
> 
> 
> Collier
> 
> www.dexdyne.com
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
> 


Collier

www.dexdyne.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] hush while confusion
  2009-10-22 13:22   ` David Collier
  2009-10-22 13:27     ` Örjan Friberg
  2009-10-22 13:28     ` David Collier
@ 2009-10-22 13:29     ` Wolfgang Denk
  2 siblings, 0 replies; 11+ messages in thread
From: Wolfgang Denk @ 2009-10-22 13:29 UTC (permalink / raw)
  To: u-boot

Dear "David Collier",

In message <memo.20091022142208.2092E@postmaster+dexdyne.com.cix.co.uk> you wrote:
> 
> OK I have changed it to
> 
> while 1==1 ; do ; mmcinit && ext2load mmc 0:1 0x10400000  /boot/uImage &&
> bootm 0x10400000 ; done
> 
> and if I do run bootcmd it simply says "unknown command 1==1"
> 
> so I'm still lost....

Well, this is not valid shell syntax. Bash will reject this, too:

	bash: 1==1: command not found

[after correcting the other syntax errors, or course(

> I failed to find a proper manual... probably for lack of effort, but I've
> just googled again and nothing springs up..

So just use standard POSIX scripting, and/or try the syntax in a real
shell.

> Could you possibly point me at any hush documentation ?

I'm afraid there ain't any. But - what for? It's just a shell ;-)

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Winners never talk about glorious victories. That's  because  they're
the  ones  who  see  what the battlefield looks like afterwards. It's
only the losers who have glorious victories.
                                      - Terry Pratchett, _Small Gods_

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] hush while confusion
  2009-10-22 13:28     ` David Collier
@ 2009-10-22 18:05       ` Wolfgang Denk
  2009-10-23  8:57         ` David Collier
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Denk @ 2009-10-22 18:05 UTC (permalink / raw)
  To: u-boot

Dear "David Collier",

In message <memo.20091022142824.2092F@postmaster+dexdyne.com.cix.co.uk> you wrote:
> 
> This now works
> 
> while itest 1 == 1 ; do ; mmcinit && ext2load mmc 0:1 0x10400000
> /boot/uImage && bootm 0x10400000 ; done
> 
> I could do with a literal "true" - I tried 'true' but that wasn't right -
> is there a suitable constant value?

Not yet - a patch to add "true" and "false" commands was submitted a
week ago and will make it into the next release - see
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/69887/focus=69886

> I'd still love to find some teaching stuff on this - I can't keep
> bothering important people like you :-)

Try: "man sh" :-)

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
News is what a chap who doesn't care much  about  anything  wants  to
read. And it's only news until he's read it. After that it's dead.
                           - Evelyn Waugh _Scoop_ (1938) bk. 1, ch. 5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] hush while confusion
  2009-10-22 13:27     ` Örjan Friberg
@ 2009-10-22 18:07       ` Wolfgang Denk
  2009-10-22 18:18         ` Örjan Friberg
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Denk @ 2009-10-22 18:07 UTC (permalink / raw)
  To: u-boot

Dear =?iso-8859-1?Q?=D6rjan_Friberg?=,

In message <A646FE253FDF3D4F9742732015311CD44F7E10@fg-server.flatfrog.local> you wrote:
>
> > OK I have changed it to
> > 
> > while 1==1 ; do ; mmcinit && ext2load mmc 0:1 0x10400000  /boot/uImage
> > &&
> > bootm 0x10400000 ; done
> 
> Replace the "1==1" with ":" and skip the ";" after "do"

I recommend to try things out before posting:

	=> while : ; do echo foo ; done
	Unknown command ':' - try 'help'
	=> 

U-Boot does not know (yet) about the ':' command.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Virtue is a relative term.
	-- Spock, "Friday's Child", stardate 3499.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] hush while confusion
  2009-10-22 18:07       ` Wolfgang Denk
@ 2009-10-22 18:18         ` Örjan Friberg
  0 siblings, 0 replies; 11+ messages in thread
From: Örjan Friberg @ 2009-10-22 18:18 UTC (permalink / raw)
  To: u-boot

> -----Original Message-----
> From: Wolfgang Denk [mailto:wd at denx.de]
> Sent: den 22 oktober 2009 20:07
> To: ?rjan Friberg
> Cc: from_denx_uboot at dexdyne.com; u-boot at lists.denx.de
> Subject: Re: [U-Boot] hush while confusion
> 
> Dear =?iso-8859-1?Q?=D6rjan_Friberg?=,
> 
> In message <A646FE253FDF3D4F9742732015311CD44F7E10@fg-
> server.flatfrog.local> you wrote:
> >
> > Replace the "1==1" with ":" and skip the ";" after "do"
> 
> I recommend to try things out before posting:
> 
> 	=> while : ; do echo foo ; done
> 	Unknown command ':' - try 'help'
> 	=>
> 
> U-Boot does not know (yet) about the ':' command.

Apologies, should have known better.  I meant to say "try replacing..." but didn't.

/Orjan

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] hush while confusion
  2009-10-22 18:05       ` Wolfgang Denk
@ 2009-10-23  8:57         ` David Collier
  2009-10-23  9:35           ` Wolfgang Denk
  0 siblings, 1 reply; 11+ messages in thread
From: David Collier @ 2009-10-23  8:57 UTC (permalink / raw)
  To: u-boot

> Not yet - a patch to add "true" and "false" commands was submitted a
> week ago and will make it into the next release - see
> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/69887/focus=6
> 9886

excellent - I'll keep the clumsy-but-working version then.

> > I'd still love to find some teaching stuff on this - I can't keep
> > bothering important people like you :-)
> 
> Try: "man sh" :-)

OK... TVM

I've worked with bash, and naively assumed that that syntax was standard.

David


> 
> Best regards,
> 
> Wolfgang Denk
> 
> -- 
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev 
> Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, 
> Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: 
> wd at denx.de
> News is what a chap who doesn't care much  about  anything  wants  
> to
> read. And it's only news until he's read it. After that it's dead.
>                            - Evelyn Waugh _Scoop_ (1938) bk. 1, ch. 
> 5
> 


David Collier

www.dexdyne.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] hush while confusion
  2009-10-23  8:57         ` David Collier
@ 2009-10-23  9:35           ` Wolfgang Denk
  0 siblings, 0 replies; 11+ messages in thread
From: Wolfgang Denk @ 2009-10-23  9:35 UTC (permalink / raw)
  To: u-boot

Dear "David Collier",

In message <memo.20091023095756.2092H@postmaster+dexdyne.com.cix.co.uk> you wrote:
>
> > Try: "man sh" :-)
> 
> OK... TVM
> 
> I've worked with bash, and naively assumed that that syntax was standard.

Bash is bash and not standard. And hush is hush and not standard
either. But all things you tried so far are covered by bash, hush, and
the POSIX standard ;-)

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If the facts don't fit the theory, change the facts.
                                                   -- Albert Einstein

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-10-23  9:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-22  8:38 [U-Boot] hush while confusion David Collier
2009-10-22 11:31 ` Wolfgang Denk
2009-10-22 13:22   ` David Collier
2009-10-22 13:27     ` Örjan Friberg
2009-10-22 18:07       ` Wolfgang Denk
2009-10-22 18:18         ` Örjan Friberg
2009-10-22 13:28     ` David Collier
2009-10-22 18:05       ` Wolfgang Denk
2009-10-23  8:57         ` David Collier
2009-10-23  9:35           ` Wolfgang Denk
2009-10-22 13:29     ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox