实施自定义u-boot命令 [英] Implement custom u-boot command
问题描述
我想向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
- 克隆了github中的
u-boot
源. - 在系统中安装了所有构建依赖项.
- 使用
make qemu_arm_config ARCH=arm CROSS_COMPILE=arm-none-eabi-
准备的u-boot配置文件
- 构建u-boot
make all ARCH=arm CROSS_COMPILE=arm-none-eabi-
- 使用u-boot映像
qemu-system-arm -M virt -nographic -kernel u-boot
启动qemu
- Cloned the
u-boot
source from github. - Installed all the build dependencies in the system.
- Prepared u-boot config files using
make qemu_arm_config ARCH=arm CROSS_COMPILE=arm-none-eabi-
- Build u-boot
make all ARCH=arm CROSS_COMPILE=arm-none-eabi-
- 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:
- repo: https://github.com/u-boot/u-boot .git
- 分支/标签:v2020.01
主机操作系统:
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屋!