[IMX6] Defining A U-Boot Command
Compiling a user uboot command
1. Function Overview
I wish to boot a partition that can be decided in the U-Boot stage. The process is highlighted below:

I have to compose the U-Boot independent application to implement the logic marked red.
2. U-Boot independent APP
The U-Boot provides a console we can interact with. This section will introduce how to add an independent command to the U-Boot source code project. In the U-Boot project, each U-Boot provided command is defined by U_BOOT_CMD macro in include/command.h.
Attributes:
name: The command name;maxargs: The maximum of the inputted arguments;command: The C function is mapped to the command;usage: Usage message;...
2.1 Code Base
Assuming the command name is utils_load
Add obj-y += utils_load.o to Makefile in common directory.

Create utils_load.c file in common directory.

The content of utils_load.c file is:
Then build the U-Boot by
in imx6 platform.
2.2 Judging Secure Boot
There are two versions of NXP S32G SoC:
Rev 1.0
Rev 2.0 (The HSE is enabled)
The Rev 1.0 hasn't HSE, while the Rev 2.0 has enabled the HSE.

We can use the version information to distinguish if the SoC has been enabled HSE.


The Secure Boot can be distinguished by DDR storage:

3. Examples
Here are some examples of common U-Boot independent applications at https://cloud.tencent.com/developer/article/1974907
3.1 BEE
3.2 Control LEDs
3.3 movi
3.4 uboot env copying
最后更新于