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
    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

posted @   hkingsp  阅读(58)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示