u-boot增加新命令
00. u-boot默认配置为:
UBOOT_DEFCONFIG=rk3399_defconfig
01. 新增文件夹:
mkdir -p /u-boot/test/hello
02. 编译该文件夹
obj-$(CONFIG_TEST_HELLO) += hello/
03. 定义CONFIG_TEST_HELLO变量
CONFIG_TEST_HELLO=y
05. 新增cmd文件
touch /u-boot/test/hello/helloworld.c
06. 新增Makefile
touch /u-boot/test/hello/Makefile
编译为:
obj-y += helloworld.o
UBOOT_DEFCONFIG=rk3399_defconfig
01. 新增文件夹:
mkdir -p /u-boot/test/hello
02. 编译该文件夹
obj-$(CONFIG_TEST_HELLO) += hello/
03. 定义CONFIG_TEST_HELLO变量
config TEST_HELLO bool "test my modules" depends on ARCH_ROCKCHIP help This enables the test function for me.
04. 在/u-boot/configs/rk3399_defconfig 新增配置
CONFIG_TEST_HELLO=y
05. 新增cmd文件
touch /u-boot/test/hello/helloworld.c
/*
* Copyright 2000-2009
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <command.h>
#include <version.h>
#include <linux/compiler.h>
#ifdef CONFIG_SYS_COREBOOT
#include <asm/arch/sysinfo.h>
#endif
const char __weak version_string[] = U_BOOT_VERSION_STRING;
static int do_helloworld(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
printf("hello printf.\n");
puts("hello puts.\n");
return 0;
}
U_BOOT_CMD(
helloworld, 1, 1, do_helloworld,
"print hello ifno, to verify the hello function",
""
);
06. 新增Makefile
touch /u-boot/test/hello/Makefile
编译为:
obj-y += helloworld.o