实施自定义u-boot命令 [英] Implement custom u-boot command

查看:112
本文介绍了实施自定义u-boot命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向u-boot添加自定义命令命令,因为它是一个简单的hello world命令.

I want to add custom command command to u-boot be it a simple hello world command.

搜索后,我发现此链接 Yocto u-boot自定义命令在其中显示以cmd/misc.c中的timer命令为起点.

After searching I found this link Yocto u-boot Custom Commands where it says to look at timer command in cmd/misc.c as starting point.

如何将此timer命令带到我的u-boot映像? 我假设我已经对makefile进行了更改,但是不确定我应该编辑哪个makefile.

How do I bring this timer command to my u-boot image? I assume I have make changes to the makefiles but not sure which makefile I should edit.

我正在使用qemu通过以下方法在Ubuntu 18.04中测试u-boot映像

I am using qemu to test the u-boot image in Ubuntu 18.04 using the following method

  1. 克隆了github中的u-boot源.
  2. 在系统中安装了所有构建依赖项.
  3. 使用make qemu_arm_config ARCH=arm CROSS_COMPILE=arm-none-eabi-
  4. 准备的u-boot配置文件
  5. 构建u-boot make all ARCH=arm CROSS_COMPILE=arm-none-eabi-
  6. 使用u-boot映像qemu-system-arm -M virt -nographic -kernel u-boot
  7. 启动qemu
  1. Cloned the u-boot source from github.
  2. Installed all the build dependencies in the system.
  3. Prepared u-boot config files using make qemu_arm_config ARCH=arm CROSS_COMPILE=arm-none-eabi-
  4. Build u-boot make all ARCH=arm CROSS_COMPILE=arm-none-eabi-
  5. Launch qemu with u-boot image qemu-system-arm -M virt -nographic -kernel u-boot

U引导日志

$ qemu-system-arm -M virt -nographic -kernel u-boot 


U-Boot 2020.01-dirty (Mar 29 2020 - 15:46:14 +0530)

DRAM:  128 MiB
WARNING: Caches not enabled
Flash: 128 MiB
*** Warning - bad CRC, using default environment

In:    pl011@9000000
Out:   pl011@9000000
Err:   pl011@9000000
Net:   No ethernet found.
Hit any key to stop autoboot:  0 
=> timer
Unknown command 'timer' - try 'help'
=> 

更多细节

U-boot:

Few more details

U-boot:

主机操作系统:

Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:    18.04
Codename:   bionic

推荐答案

doc/README.commands描述了应如何实现命令.

doc/README.commands describes how commands should be implemented.

您的新C文件应该在目录cmd/中.在cmd/Makefile中,您将必须添加目标文件,例如

Your new C file should be in directory cmd/. In cmd/Makefile you will have to add your object file, e.g.

obj-$(CONFIG_CMD_TIMER) += timer.o

在cmd/Kconfig中为您的命令添加一个新的配置选项. Kconfig语法在 https://www.kernel.org/中进行了描述doc/Documentation/kbuild/kconfig-language.txt .

In cmd/Kconfig add a new configuration option for your command. The Kconfig syntax is described in https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt.

运行

make menuconfig

启用您的配置选项.

这篇关于实施自定义u-boot命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆