[U-Boot] Add a new command to U-Boot

Deepak Gopalakrishnan Deepak.Gopalakrishnan at Lntemsys.com
Fri May 8 15:21:47 CEST 2009


thanks to everyone first.
im able to write a new command for the u-boot and load it on to the board 
and it works like a charm.
Im explaining the steps here so that it would be helpful in the future:
im using a MPC8313e RDB and u-boot-1.3.0.
1) First of all the commands are defined in files present in u-boot/common 
folder and are the files that start with cmd_*.c
2) now to add a new command create a file in the same format
3) include the necessary header file (depends on what the command would 
do)
4) "do_<command>" function. This is the function where you have to do what 
your command intends to do.
5) U_BOOT_CMD( ) function will include your command to the list of 
commands of u-boot
6) compile it and get the u-boot.bin file
7) load this on to the board.
8) TADAAAAA....ur function is up and running....

this is the content of firrst u-boot command i wrote:

cmd_dgprint.c
<code>
/*
 * (C) Copyright 2005
 * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */
 #include <common.h>
 #include <command.h>


int do_dgprint(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
        printf("Hi this is a test\n");
        return 0;
}

U_BOOT_CMD(
        dgprint,        1,      1,      do_dgprint,
        "dgprint takes no arguments",
        "this is just to test a function"
);

</code>
hope this is useful to atleast one person

Regards,
Deepak Gopalakrishnan


More information about the U-Boot mailing list