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

Hi, All!
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?
So where can I read about cmd_-file structure and how should new commands be added? And how can I add my new file to U-Boot binary?

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?
[1] http://git.denx.de/?p=u-boot.git;a=commitdiff;h=02c9aa1d41f73fdcf8383a36cc0c...

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

Thank you, Detlev! I've successfully added new command to U-Boot. All fine.
On Wednesday 23 September 2009 11:44:25 you wrote:
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=02c9aa1d41f73fdcf8383a36c c0 cbbfaf952855d

Dear Tuma,
In message 200909231144.25176.chernigovskiy@spb.gs.ru you wrote:
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[]) {
Why do you think such new command is needed?
Is anything wrong with just running "printenv serial#" ?
Best regards,
Wolfgang Denk

On Wednesday 23 September 2009 16:44:50 you wrote:
Dear Tuma,
In message 200909231144.25176.chernigovskiy@spb.gs.ru you wrote:
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[]) {
Why do you think such new command is needed?
Is anything wrong with just running "printenv serial#" ?
Uhm... Sorry, we did'nt know about 'printenv serial#'. My project manager said me to study U-Boot. This command was just for testing purposes. In real new comman maybe ANY functional. Serial Number is just for test. =)
Thank a lot. Everythink about command works.
Best regards,
Wolfgang Denk
participants (3)
-
Detlev Zundel
-
Tuma
-
Wolfgang Denk