[U-Boot] Adding new U-Boot Command.

Tuma chernigovskiy at spb.gs.ru
Wed Sep 23 09:44:25 CEST 2009


Hi, Detlev!

Okay, I want to add some not board specific command - just some new 
functional. So I should put it in "/common".

Yes, I've studied the structure of cmv_-file, and here is my code:

------------------------------------------------

/*
 *  (C) Copyright 2009
 */

#include <command.h>

int PrintSerialNo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
    // Do something here
    return 0;
}

U_BOOT_CMD(printsn, 1, 0, PrintSerialNo, "Print Serial Number", "Long Help");

------------------------------------------------

The file is named cmd_sn.c and have been put in /common.

Now I'm not very skilled in make system. So can you help me please in adding 
new .c file in final u-boot image?
For example I need to include my new file unconditionally.
I should edit Makefile in /common?
What should be changed in this file?


On Tuesday 22 September 2009 13:52:52 you wrote:
> Hi Tuma,
>
> > Help me please in writting new U-Boot commands.
> > What should I do? I should write new file in "/common", something like
> > cmd_****, am I right?
>
> This really depends if you want to implement a command which is useful
> for all boards, then it should be below common/ or if it is special to
> one board.  Then it should go into the board directory.
>
> > So where can I read about cmd_-file structure and how should new
> > commands be added?
>
> You have all the source to study.  Look into how other people do it.
> Search the history for commits adding new commands and study them.  For
> example this commit[1] adds new commands to an already existing file,
> but it is a start.
>
> > And how can I add my new file to U-Boot binary?
>
> Make sure it is mentioned in the relevant Makefile.
>
> Cheers
>   Detlev
>
> PS: Is the LCD display working now?

No, it still does not. Work in progress.

> [1]
> http://git.denx.de/?p=u-boot.git;a=commitdiff;h=02c9aa1d41f73fdcf8383a36cc0
>cbbfaf952855d



-- 
Software Developer
General Satellite Corp.


More information about the U-Boot mailing list