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.
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:
#include <common.h>
#include <command.h>
#include <linux/stddef.h>
int do_utils_load(cmd_tbl_t *cmdtp, int flag, int argc, char* const argv[])
{
int ret = 0;
int i = 0;
printf("[INFO] The input is %d\n", argc);
for (i = 0; i < argc; i ++) {
printf("[INFO] the argv[%d] is %s\n", i, argv[i]);
}
finish:
return ret;
}
U_BOOT_CMD(
utils_load,
5,
1,
do_utils_load,
"format : utils_load address",
"example: utils_load 0x80000000"
);
Then build the U-Boot by
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all -j16
description: Compiling a user uboot command
[IMX6] Defining A U-Boot 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 ininclude/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
toMakefile
incommon
directory.Create
utils_load.c
file incommon
directory.The content of
utils_load.c
file is:Then build the U-Boot by
in imx6 platform.
2.2 Judging Secure Boot
https://github.com/carloscn/imx-uboot/commit/916419376b988d1a16461810bf358f94ca990e0f#diff-d397fabf5af5abbfeebdcba5c3b68879fb33e5bd432ea70a75e26dbf850a848b
There are two versions of NXP S32G SoC:
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.
without HSE booting log
with HSE booting log
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