Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

u-boot custom commands

In response to:

http://forum.niosforum.com/forum/index.php...indpost&p=15096 (http://forum.niosforum.com/forum/index.php?showtopic=3837&view=findpost&p=15096)

> How to add your cumstom commands into the u-boot?

First read: doc/README.commands -- the file has many interesting details. But

to summarize:<div class='quotetop'>QUOTE </div>

--- Quote Start ---

Commands are added to U-Boot by creating a new command structure.

This is done by first including command.h

Then using the U_BOOT_CMD() macro to fill in a cmd_tbl_t struct.

U_BOOT_CMD(name,maxargs,repeatable,command,"usage","help")

name: is the name of the commad. THIS IS NOT a string.

maxargs: the maximumn numbers of arguments this function takes

command: Function pointer (*cmd)(struct cmd_tbl_s *, int, int, char *[]);

usage: Short description. This is a string

help: long description. This is a string

[/b]

--- Quote End ---

A good example of a custom command is the &#39;epcs&#39; command

(cpu/nios2/epcs.c). This is a Nios II custom command. However, you can create

board-specific custom commands by following the same process in your board&#39;s

source tree.

> where is the source code for the command "cp" ? and so on...

Most generic u-boot commands are found in the &#39;common&#39; tree. You can grep

for "U_BOOT_CMD" to find where all of the commands are implemented. The

&#39;cp&#39; command is implemented, for example, in common/cmd_mem.c.

Regards,

--Scott
No RepliesBe the first to reply