Run u-boot command at startup

James Howard picture James Howard · May 14, 2016 · Viewed 7.9k times · Source

I have a custom board running Yocto (Jethro) and would like to run a single u-boot command, preboot. Obviously, breaking the boot sequence with space and running it manually works. How do I get it to run automatically? More specifically, where is the startup command sequence, by default?

Edit: Also, I am aware I can edit the environment at runtime. However, I am trying to build this change into the image so I can distribute it.

Answer

Charles C. picture Charles C. · May 15, 2016

When you are in the uboot environment. Enter printenv, it will list the environment variables that uboot uses.

There is a variable name bootcmd. Currently, mine contain a bunch of if else command. Similarly, add your prefer function there for boot.

And after it is finished and tested. Use saveenv to store the edit

Here is a syntax for uboot.

Edit:

U-Boot allows to store commands or command sequences in a plain text file. Using the mkimage tool you can then convert this file into a script image which can be executed using U-Boot's autoscr command. U-boot Scripting Capabilities