Skip to contentSkip to conversation

U-boot : compare read and expect value

U-Boot Khalid Tourabi 2 participants 4 messages Dec 10, 2012 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,
I'm newbie and I want to use scripts to test the board peripherals (I2C, SPI, LAN, PCIe, USB, ...) using u-boot.
My problem is how to compare the reading with the expected value? the reading is in an environment variable? If so which one? I searched the forums and docs without success.

Thanks & Best Regards,

Khalid

#1 lore raw

Dear Khalid Tourabi,

Quoted 6 lines · In message <[email protected]> you wrote:

I'm newbie and I want to use scripts to test the board peripherals (I2C, SPI, LAN, PCIe, USB, ...) using u-boot.
My problem is how to compare the reading with the expected value? the reading is in an environment variable? If so which one? I searched the forums and docs without success.

Have a look at the setexpr command...

Best regards,

Wolfgang Denk

Signature · 7 lines
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
Ein weiser Herrscher kann in einem gro?en Land  mehr  Gutes  bewirken
als  in  einem kleinen - ein dummer Herrscher aber auch viel mehr Un-
fug. Da weise Herrscher seltener sind als dumme, war ich schon  immer
gegen gro?e Reiche skeptisch.                   - Herbert Rosendorfer

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Dear Khalid Tourabi,

please don't top post / full quote, and keep the mailing list on Cc:

Quoted 7 lines · In message <[email protected]> you wrote:

Thanks for your answer.

setexpr command allows set the result operation in an environment
variable.
But I want to set the result command (string) in an environment
variable to compare it with the expect value.

Build it from parts. Start with putting the expected value in an environment variable, so you can use setexpr to compareit against the actual value. Then use conditionals to react as needed. Use standard shell scripting methods.

Best regards,

Wolfgang Denk

Signature · 4 lines
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
You can't have everything... where would you put it?  - Steven Wright
#4 lore raw

Dear Wolfgang Denk

Quoted 3 lines

Dear Khalid Tourabi,

please don't top post / full quote, and keep the mailing list on Cc:

Ok sorry thanks.

Quoted 8 lines
Quoted 6 lines · In message<[email protected]> you wrote:

Thanks for your answer.

setexpr command allows set the result operation in an environment
variable.
But I want to set the result command (string) in an environment
variable to compare it with the expect value.

Quoted 9 lines

Build it from parts. Start with putting the expected value in an environment variable, so you can use setexpr to compareit against the actual value. Then use conditionals to react as needed. Use standard shell scripting methods.

Best regards,

Wolfgang Denk

I added setexpr command, but I don't understand how to use it for my need.

For example :

     u-boot# set expct "FF7F7F7F7F7F7FC2"
     u-boot# sspi 8 64 9F
     FF7F7F7F7F7F7FC2
     u-boot#

This SPI command allows to read the NVRAM code ID, I want to compare with $expct unsuccessfully

u-boot# if test "sspi 8 64 9F" = $expct ; then echo Success; else
echo Error; fi;
Success
u-boot# set expct "FF7F7F7F7F7F7FC"
u-boot# if test "sspi 8 64 9F" = $expct ; then echo Success; else

echo Error; fi;
     Success

     $expct either equal to "FF7F7F7F7F7F7FC2" or "FF7F7F7F7F7F7FC" the 

result of if condition is the same.

Many Thanks for your help.

Khalid