Uboot Tips

Here are useful tips and tricks about the U-Boot bootloader

Cascading commands
With U-Boot, you can execute multiple commands in a row by putting them in an environment variable. For example:

setenv mmc-boot 'mmcinit 0; fatload mmc 0:1 0x80000000 uImage; fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 0x81600000'

You can execute this script with the  command:

run mmc-boot

Conditional statements
U-Boot can have conditional statements. Here is an example, sourcing a  script, or booting is a regular way otherwise:

setenv mmc-boot 'mmc init 0; if fatload mmc 0 80000000 boot.src; then source; else if fatload mmc 0 80000000 uImage; then run mmc-bootargs; bootm; fi; fi'