Implement custom u-boot command

百般思念 提交于 2020-07-03 13:18:10

问题


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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!