[U-Boot-Users] Hush shell and simple calculations

Robin Gilks robin.gilks at tait.co.nz
Tue May 23 02:08:37 CEST 2006


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 


More information about the U-Boot mailing list