public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] Hush shell and simple calculations
@ 2006-05-22 20:14 Antonio Di Bacco
  2006-05-22 20:23 ` Wolfgang Denk
  2006-05-23  0:08 ` Robin Gilks
  0 siblings, 2 replies; 6+ messages in thread
From: Antonio Di Bacco @ 2006-05-22 20:14 UTC (permalink / raw)
  To: u-boot

I don't manage to do some simple calculations like:

echo $((1+1))

Bye,
Antonio

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

* [U-Boot-Users] Hush shell and simple calculations
  2006-05-22 20:14 [U-Boot-Users] Hush shell and simple calculations Antonio Di Bacco
@ 2006-05-22 20:23 ` Wolfgang Denk
  2006-05-23  0:08 ` Robin Gilks
  1 sibling, 0 replies; 6+ messages in thread
From: Wolfgang Denk @ 2006-05-22 20:23 UTC (permalink / raw)
  To: u-boot

In message <200605222214.38257.antonio.dibacco@aruba.it> you wrote:
> I don't manage to do some simple calculations like:
> 
> echo $((1+1))

That's true. This ain't no bash. Arithmetic expansion is not supported.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The computer can't tell you the emotional story. It can give you  the
exact mathematical design, but what's missing is the eyebrows.
- Frank Zappa

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

* [U-Boot-Users] Hush shell and simple calculations
  2006-05-22 20:14 [U-Boot-Users] Hush shell and simple calculations Antonio Di Bacco
  2006-05-22 20:23 ` Wolfgang Denk
@ 2006-05-23  0:08 ` Robin Gilks
  2006-05-23  8:42   ` Wolfgang Denk
  1 sibling, 1 reply; 6+ messages in thread
From: Robin Gilks @ 2006-05-23  0:08 UTC (permalink / raw)
  To: u-boot

Antonio Di Bacco wrote:
> I don't manage to do some simple calculations like:
> 
> echo $((1+1))
> 
> Bye,
> Antonio

I've solved this with a new command 'eval' which is used to set a 
variable based on an expression. For example, I wanted to determine the 
start address of the kernel in flash for both 4 and 8meg parts but since 
its sits above U-Boot in the memory map (and U-Boot has to be 1M down 
from the top for high boot), it has to be calculated depending on the 
flash size. In this case, the new variable 'kb' contains the address of 
the beginning of the kernel of either 40340000 or 40740000 for either 4M 
or 8M devices.
     "eval kb $flash - c00c0000;"		\

This is work I did a couple of years ago and I'm no longer on the 
project so I'm not able to provide a 'formal' patch. To use it, put the 
file cmd_eval.c into ...uboot/common/ and make the following mods

in cmd_confdefs.h add
#define CFG_CMD_EVAL	0x0080000000000000U	/* Eval arithmetics             */

in your board config add
#define CONFIG_COMMANDS (   (    CONFIG_CMD_DFL \
                   ...............
                   | CFG_CMD_EVAL		\
		
in ..../uboot/common/Makefile
COBJS	= main.o ACEX1K.o altera.o bedbug.o \
           ............
	  cmd_eval.o

And that should be it.

I hope it helps...

-- 
Robin Gilks
Senior Design Engineer          Phone: (+64)(3) 357 1569
Tait Electronics                Fax  :  (+64)(3) 359 4632
PO Box 1645 Christchurch        Email : robin.gilks at tait.co.nz
New Zealand

=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
 altered or corrupted during transmission.
=======================================================================

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cmd_eval.c
Url: http://lists.denx.de/pipermail/u-boot/attachments/20060523/185a34b4/attachment.txt 

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

* [U-Boot-Users] Hush shell and simple calculations
  2006-05-23  0:08 ` Robin Gilks
@ 2006-05-23  8:42   ` Wolfgang Denk
  2006-05-23 16:00     ` Tolunay Orkun
  2006-05-23 21:48     ` Robin Gilks
  0 siblings, 2 replies; 6+ messages in thread
From: Wolfgang Denk @ 2006-05-23  8:42 UTC (permalink / raw)
  To: u-boot

In message <44725285.1030006@tait.co.nz> you wrote:
> 
> I've solved this with a new command 'eval' which is used to set a 

I think that's a typo. An 'eval' command that does not behave exactly
as the standard shell 'eval' should have been named 'evil' ;-)


Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The light at the end of the tunnel is usually a "No Exit" sign.

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

* [U-Boot-Users] Hush shell and simple calculations
  2006-05-23  8:42   ` Wolfgang Denk
@ 2006-05-23 16:00     ` Tolunay Orkun
  2006-05-23 21:48     ` Robin Gilks
  1 sibling, 0 replies; 6+ messages in thread
From: Tolunay Orkun @ 2006-05-23 16:00 UTC (permalink / raw)
  To: u-boot

Wolfgang Denk wrote:
> In message <44725285.1030006@tait.co.nz> you wrote:
>> I've solved this with a new command 'eval' which is used to set a 
> 
> I think that's a typo. An 'eval' command that does not behave exactly
> as the standard shell 'eval' should have been named 'evil' ;-)

Maybe 'eval' is not the best name but lacking back tick capability it 
seems to me that you need to pass the name of (local?) environment 
variable to receive such assignment.

Perhaps we can add such functionality as another command (propose: iexpr)

I think I would really use this right now.

Best regards,
Tolunay

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

* [U-Boot-Users] Hush shell and simple calculations
  2006-05-23  8:42   ` Wolfgang Denk
  2006-05-23 16:00     ` Tolunay Orkun
@ 2006-05-23 21:48     ` Robin Gilks
  1 sibling, 0 replies; 6+ messages in thread
From: Robin Gilks @ 2006-05-23 21:48 UTC (permalink / raw)
  To: u-boot

Wolfgang Denk wrote:
> In message <44725285.1030006@tait.co.nz> you wrote:
>> I've solved this with a new command 'eval' which is used to set a 
> 
> I think that's a typo. An 'eval' command that does not behave exactly
> as the standard shell 'eval' should have been named 'evil' ;-)

:-)

Since hush doesn't do many things that a ?standard? shell does I won't 
loose any sleep over it.

iexpr works for me...

-- 
Robin Gilks
Senior Design Engineer          Phone: (+64)(3) 357 1569
Tait Electronics                Fax  :  (+64)(3) 359 4632
PO Box 1645 Christchurch        Email : robin.gilks at tait.co.nz
New Zealand

=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
 altered or corrupted during transmission.
=======================================================================

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

end of thread, other threads:[~2006-05-23 21:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-22 20:14 [U-Boot-Users] Hush shell and simple calculations Antonio Di Bacco
2006-05-22 20:23 ` Wolfgang Denk
2006-05-23  0:08 ` Robin Gilks
2006-05-23  8:42   ` Wolfgang Denk
2006-05-23 16:00     ` Tolunay Orkun
2006-05-23 21:48     ` Robin Gilks

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