</>EmbeddedInterview

What are the common U-Boot commands?

EasyEmbedded Linux & Boot

Short answer: Environment commands (printenv, setenv, saveenv), loading commands (load/fatload/ext4load, tftp, mmc, sf), boot commands (bootm, bootz, booti, run bootcmd), and hardware debug commands (md, mw, i2c, gpio).

Environment

=> printenv bootcmd
=> setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait
=> saveenv                     # write the environment to its storage
=> run bootcmd                 # execute the variable as a script
=> env default -a              # restore defaults

Storage and loading

=> mmc list                    # list MMC/SD controllers
=> mmc dev 0                   # select device
=> mmc part                    # show partitions
=> ls mmc 0:1                  # list files on partition 1
=> load mmc 0:1 ${kernel_addr_r} Image
=> sf probe; sf read ${loadaddr} 0x100000 0x400000   # SPI NOR flash

Network (fast development loop)

=> setenv serverip 192.168.1.10; setenv ipaddr 192.168.1.50
=> tftp ${kernel_addr_r} Image
=> tftp ${fdt_addr_r} board.dtb
=> booti ${kernel_addr_r} - ${fdt_addr_r}

Loading over TFTP and using an NFS root filesystem means you can rebuild and test without re-flashing the board.

Booting

  • booti – ARM64 Image.
  • bootz – ARM32 zImage.
  • bootm – uImage or FIT (can verify signatures).
  • bootefi – boot an EFI application (GRUB or the kernel's EFI stub).

Hardware debugging

  • md.l 0x40000000 10 – dump 16 words of memory (or a peripheral register).
  • mw.l 0x40000000 0xdeadbeef – write memory.
  • i2c dev 0; i2c probe; i2c md 0x50 0 16 – scan the bus and read an EEPROM.
  • gpio status; gpio set 42 – check and drive pins.
  • mtest – simple DRAM test. bdinfo, coninfo, version – board information.

Follow-up: "How do you stop autoboot?" Press a key during bootdelay (set bootdelay=-2 to disable the prompt entirely in production, and consider disabling the console or protecting it with a password, since an open U-Boot prompt can boot anything).