How to stop a U-Boot macro using itest

566 Views Asked by At

I need to create a 3-step macro in U-Boot:

  1. Use dhcp to download an image to memory. This sets filesize
  2. Test if $filesize > $SOMELIMIT, print a message, and stop
  3. Would write the downloaded image to flash.

I know how to do steps 1 and 3, but not 2.

I know that I can use the U-Boot command itest to test integer values, but I don't know how to create a compound statement in the if/else/endif clause. And I don't know how to have an "abort macro" step in one of those clauses.

How can I stop a U-Boot command sequence abruptly?

1

There are 1 best solutions below

1
Xypron On

For testing if the result of itest is true you can use the if command. To leave a macro use the exitcommand:

setenv macro 'if itest $filesize > 2048; then exit; else echo bingo; fi; echo continuing'
setenv filesize 10000
run macro

Man-pages for 'if' and 'itest' have been added to https://docs.u-boot.org/en/latest/usage/.