How to check if file exists in u-boot script?
<p>I would like, from my u-boot script, to check the existence of a file on a device before running the image on this device.
Indeed, this would ensure to have access to the requested device before booting from it.
How could I test the file existence using u-boot console commands?</p>

<p>The following test does a ls on the USB stick, and here are the results with USB stick present:</p>

<pre><code>&gt; if ext2ls usb 0; then echo "USB ON"; else echo "USB KO"; fi
    &lt;DIR&gt;       4096 .
    &lt;DIR&gt;       4096 ..
    &lt;DIR&gt;      16384 lost+found
    &lt;DIR&gt;       4096 boot
                4096 boot.scr
USB ON
</code></pre>

<p>Same test without USB stick:</p>

<pre><code>&gt; if ext2ls usb 0; then echo "USB ON"; else echo "USB KO"; fi
** Bad device usb 0 **
USB KO
</code></pre>

<p>My wish would be to test the presence of the boot.scr file in fact. How could I do that please?</p>