问题
I want to add custom command command to u-boot
be it a simple hello world command.
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.
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.
I am using qemu to test the u-boot
image in Ubuntu 18.04 using the following method
- 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-boot log
$ 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'
=>
Few more details
U-boot:
- repo : https://github.com/u-boot/u-boot.git
- branch / tag : v2020.01
Host OS:
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
回答1:
doc/README.commands describes how commands should be implemented.
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
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.
Run
make menuconfig
to enable your configuration option.
来源:https://stackoverflow.com/questions/60913034/implement-custom-u-boot-command