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

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

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

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...

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

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

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...
participants (4)
-
Antonio Di Bacco
-
Robin Gilks
-
Tolunay Orkun
-
Wolfgang Denk