Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a U-Boot macro using itest

Tags:

u-boot

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?

like image 661
user3696153 Avatar asked Mar 16 '26 14:03

user3696153


1 Answers

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

like image 128
Xypron Avatar answered Mar 21 '26 12:03

Xypron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!