18

i'm newbie in uboot and tftp programing

based on this url, there is how to make if statement like this if imi $addr; then echo Image OK; else echo Image corrupted!!; fi

and this is my "if" :

=> setenv a true
=> printenv a
a=true
=> setenv b true
=> printenv b
b=true
=> if a b; then echo 'same';fi
Unknown command 'a' - try 'help'
=> if $a $b; then echo 'same';fi
Unknown command 'true' - try 'help'
=> if ${a} ${b}; then echo 'same';fi
Unknown command 'true' - try 'help'
=>
Egy Mohammad Erdin
  • 3,402
  • 6
  • 33
  • 57

1 Answers1

14

I am not sure if it is in all u-boot versions or not, but there should be a test command for comparison. Can you try:

if test "${a}" = "${b}"; then echo "same"; fi

Unfortunately I don't have access to u-boot, so this is all from memory.

vhallac
  • 13,301
  • 3
  • 25
  • 36
  • yup it's correct... i've try this, if echo a b; then echo 'same'.. but before echo same, it also echo a & b variable... thanks... – Egy Mohammad Erdin Apr 13 '11 at 09:22
  • 2
    [Here is the list of the various test operators](https://github.com/u-boot/u-boot/blob/52ba373b7825e9feab8357065155cf43dfe2f4ff/cmd/test.c#L35). – Frederik Aalund Mar 04 '21 at 13:14