Add CONFIG_CMDLINE to allow removal of all commands
Subsystems (2)
cover Add CONFIG_CMDLINE to allow removal of all commands
A large chunk of the U-Boot code is its wide variety of commands. For some applications this is not needed, since the boot can be controlled by a board-specific hard-coded boot procedure.
Any attempt to use commands, such as running script, will result in an error. U-Boot acts as if it supports commands in general, but there are no actual commands to run.
This saves a significant amount of space.
For example on snow this saves 300KB of code space, with the code size dropping from 505KB to 202KB. BSS drops from 238KB to 4KB. The size of u-boot.bin (which includes the device tree) drops from 541KB to 228KB.
If LCD and USB support is disabled on this platform, code size drops to 139KB.
This makes U-Boot proper look a little more like SPL in terms of size.
The CONFIG_CMDLINE setting is enabled by default, but can be disabled by boards as needed.
Simon Glass (9):
cbfs: Update a function to be static
Add an option to enable the command line
arm: x86: Drop command-line code when CONFIG_CMDLINE is disabled
sandbox: Avoid calling commands when not available Drop command-processing code when CONFIG_CMDLINE is disabled Hang when no command line processing can be performed Allow command code to compile to nothing
Allow command-line files to be dropped
Drop various features when the command line is not available
README | 8 ++++++++ arch/arm/cpu/u-boot.lds | 3 +++ arch/sandbox/cpu/start.c | 10 +++++++++- arch/x86/cpu/u-boot.lds | 4 ++++ cmd/Kconfig | 12 ++++++++++++ cmd/cbfs.c | 12 ++++++++---- cmd/help.c | 4 ++++ common/Makefile | 4 ++-- common/cli.c | 17 +++++++++++++++- common/command.c | 6 ++++++ common/main.c | 1 + include/command.h | 49 ++++++++++++++++++++++++++++++++++++++++++---- include/config_fallbacks.h | 10 ++++++++++ 13 files changed, 128 insertions(+), 12 deletions(-)
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 1/9 cbfs: Update a function to be static
All command functions should be static. Update the CBFS functions to follow this rule.
---
cmd/cbfs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
cmd/cbfs.c +8 -4
@@ -11,7 +11,8 @@#include <command.h> #include <cbfs.h> -int do_cbfs_init (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_cbfs_init (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) {uintptr_t end_of_rom =0xffffffff ;char *ep;
@@ -44,7 +45,8 @@ U_BOOT_CMD(" CBFS is in. It defaults to 0xFFFFFFFF\n" ); -int do_cbfs_fsload (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_cbfs_fsload (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) {const struct cbfs_cachenode *file;unsigned long offset;
@@ -90,7 +92,8 @@ U_BOOT_CMD(" - load binary file 'filename' from the cbfs to address 'addr'\n" ); -int do_cbfs_ls (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_cbfs_ls (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) {const struct cbfs_cachenode *file =file_cbfs_get_first ();int files =0 ;
@@ -167,7 +170,8 @@ U_BOOT_CMD(" - list the files in the cbfs\n" ); -int do_cbfs_fsinfo (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_cbfs_fsinfo (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) {const struct cbfs_header *header =file_cbfs_get_header ();
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 1/9 cbfs: Update a function to be static
Quoted 4 lines · Simon Glass
All command functions should be static. Update the CBFS functions to follow this rule.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/9db78ec8/attachment.sig>
PATCH 2/9 Add an option to enable the command line
In reply to Simon GlassAdd a new Kconfig option for the command line. This is enabled by default, but when disabled it will remove the command line.
---
README | 8 ++++++++ cmd/Kconfig | 12 ++++++++++++ 2 files changed, 20 insertions(+)
README +8 -0
@@ -1108,6 +1108,14 @@ The following options need to be configured: XXX - this list needs to get updated! +- Removal of commands + If no commands are needed to boot, you can disable + CONFIG_CMDLINE to remove them. In this case, the command line + will not be available, and when U-Boot wants to execute the + boot command (on start-up) it will call board_run_command() + instead. This can reduce image size significantly for very + simple boot procedures. + - Regular expression support: CONFIG_REGEX If this variable is defined, U-Boot is linked against
cmd/Kconfig +12 -0
@@ -1,8 +1,20 @@ menu "Command line interface" +config CMDLINE + bool "Support U-Boot commands" + default y + help + Enable U-Boot's command-line functions. This provides a means + to enter commands into U-Boot for a wide variety of purposes. It + also allows scripts (containing commands) to be executed. + Various commands and command categorys can be indivdually enabled. + Depending on the number of commands enabled, this can add + substantially to the size of U-Boot. + config HUSH_PARSER bool "Use hush shell" select SYS_HUSH_PARSER + depends on CMDLINE help This option enables the "hush" shell (from Busybox) as command line interpreter, thus enabling powerful command line syntax like
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 2/9 Add an option to enable the command line
Quoted 4 lines · Simon Glass
Add a new
Kconfigoption for the command line. This is enabled by default, but when disabled it will remove the command line.Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/e7436087/attachment.sig>
PATCH 3/9 arm: x86: Drop command-line code when CONFIG_CMDLINE is disabled
In reply to Simon GlassUpdate the link script to drop this code when not needed. This is only done for two architectures at present.
---
arch/arm/cpu/u-boot.lds | 3 +++ arch/x86/cpu/u-boot.lds | 4 ++++ 2 files changed, 7 insertions(+)
arch/arm/cpu/u-boot.lds +3 -0
@@ -14,6 +14,9 @@ OUTPUT_ARCH(arm) ENTRY(_start) SECTIONS { +#ifndef CONFIG_CMDLINE + /DISCARD/ : { *(.u_boot_list_2_cmd_*) } +#endif #if defined(CONFIG_ARMV7_SECURE_BASE) && defined(CONFIG_ARMV7_NONSEC) /* * If CONFIG_ARMV7_SECURE_BASE is true, secure code will not
arch/x86/cpu/u-boot.lds +4 -0
@@ -12,6 +12,10 @@ ENTRY(_start) SECTIONS { +#ifndef CONFIG_CMDLINE + /DISCARD/ : { *(.u_boot_list_2_cmd_*) } +#endif + . = CONFIG_SYS_TEXT_BASE; /* Location of bootcode in flash */ __text_start = .; .text : { *(.text*); }
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 3/9 arm: x86: Drop command-line code when CONFIG_CMDLINE is disabled
Quoted 4 lines · Simon Glass
Update the link script to drop this code when not needed. This is only done for two architectures at present.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/ac2637de/attachment.sig>
PATCH 4/9 sandbox: Avoid calling commands when not available
In reply to Simon GlassDon't try to run commands when not supported.
---
arch/sandbox/cpu/start.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/sandbox/cpu/start.c +9 -1
@@ -83,13 +83,14 @@ int sandbox_main_loop_init(void)cli_init (); +#ifdef CONFIG_CMDLINE if (state->cmd) retval =run_command_list (state->cmd,-1 ,0 );if (state->run_distro_boot) retval =cli_simple_run_command ("run distro_bootcmd" ,0 ); - +#endif if (!state->interactive)os_exit (retval); }
@@ -265,6 +266,13 @@ static int sandbox_cmdline_cb_verbose(struct sandbox_state *state, }SANDBOX_CMDLINE_OPT_SHORT (verbose,'v' ,0 ,"Show test output" ); +int board_run_command (const char *cmdline) +{ +printf ("## Commands are disabled. Please enable CONFIG_CMDLINE.\n" ); + +return 1 ; +} +int main (int argc,char *argv[]) {struct sandbox_state *state;
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 4/9 sandbox: Avoid calling commands when not available
Quoted 3 lines · Simon Glass
Don't try to run commands when not supported.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/85b910c7/attachment.sig>
PATCH 4/9 sandbox: Avoid calling commands when not available
In reply to Simon Glassarch/sandbox/cpu/start.c static int sandbox_cmdline_cb_verbose(struct sandbox_state *state, · line 275
Quoted 11 lines · Simon Glass
Don't try to run commands when not supported.
arch/sandbox/cpu/start.c +7
-0+int board_run_command (const char *cmdline) +{ +printf ("## Commands are disabled. Please enable CONFIG_CMDLINE.\n" ); + +return 1 ; +} +
Isn't this part of patch 5/9?
PATCH 4/9 sandbox: Avoid calling commands when not available
Hi Stephen,
Quoted 8 lines · Stephen Warren
Quoted 5 lines · Simon Glass
Don't try to run commands when not supported.
arch/sandbox/cpu/start.c +0
-0
Quoted 11 lines
arch/sandbox/cpu/start.c static int sandbox_cmdline_cb_verbose(struct sandbox_state *state, · line 275
Quoted 8 lines
arch/sandbox/cpu/start.c +3
-0+int board_run_command (const char *cmdline) +{ + printf("## Commands are disabled. Please enableCONFIG_CMDLINE.\n");
arch/sandbox/cpu/start.c +4
-0+ +return 1 ; +} +Isn't this part of patch 5/9?
No - this is the sandbox support. That patch merely declares the function in a header. Any board can implement it, and each would do so in a separate patch.
Regards,
Simon
PATCH 4/9 sandbox: Avoid calling commands when not available
Quoted 23 lines · Simon Glass
Hi Stephen,
Quoted 8 lines · Stephen Warren
Quoted 5 lines · Simon Glass
Don't try to run commands when not supported.
arch/sandbox/cpu/start.c +0
-0Quoted 11 lines
arch/sandbox/cpu/start.c static int sandbox_cmdline_cb_verbose(struct sandbox_state *state, · line 275
Quoted 8 lines
arch/sandbox/cpu/start.c +3
-0+int board_run_command (const char *cmdline) +{ + printf("## Commands are disabled. Please enableCONFIG_CMDLINE.\n");
arch/sandbox/cpu/start.c +4
-0+ +return 1 ; +} +Isn't this part of patch 5/9?
Quoted 3 lines
No - this is the sandbox support. That patch merely declares the function in a header. Any board can implement it, and each would do so in a separate patch.
OK, but this patch implements the function before there's a prototype for it in the header. That doesn't seem like the correct order.
PATCH 5/9 Drop command-processing code when CONFIG_CMDLINE is disabled
In reply to Simon GlassCommand parsing and processing code is not needed when the command line is disabled. Remove this code in that case.
---
cmd/help.c | 4 ++++ common/cli.c | 17 ++++++++++++++++- common/command.c | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-)
cmd/help.c +4 -0
@@ -10,9 +10,13 @@static int do_help (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { +#ifdef CONFIG_CMDLINE cmd_tbl_t *start =ll_entry_start (cmd_tbl_t, cmd);const int len =ll_entry_count (cmd_tbl_t, cmd);return _do_help (start, len, cmdtp, flag, argc, argv); +#else +return 0 ; +#endif } U_BOOT_CMD(
common/cli.c +16 -1
@@ -18,6 +18,7 @@DECLARE_GLOBAL_DATA_PTR ; +#ifdef CONFIG_CMDLINE /* * Run a command using the selected parser. *
@@ -68,6 +69,7 @@ int run_command_repeatable(const char *cmd, int flag)return 0 ; #endif } +#endif /* CONFIG_CMDLINE */ int run_command_list (const char *cmd,int len,int flag) {
@@ -102,7 +104,11 @@ int run_command_list(const char *cmd, int len, int flag)* doing a malloc() which is actually required only in a case that * is pretty rare. */ +# ifdef CONFIG_CMDLINE rcode =cli_simple_run_command_list (buff, flag); +# else + rcode =board_run_command (buff); +# endif #endif if (need_buff)free (buff);
@@ -166,7 +172,9 @@ bool cli_process_fdt(const char **cmdp)*/ void cli_secure_boot_cmd (const char *cmd) { +#ifdef CONFIG_CMDLINE cmd_tbl_t *cmdtp; +#endif int rc;if (!cmd) {
@@ -178,6 +186,7 @@ void cli_secure_boot_cmd(const char *cmd)disable_ctrlc (1 );/* Find the command directly. */ +#ifdef CONFIG_CMDLINE cmdtp =find_cmd (cmd);if (!cmdtp) {printf ("## Error: \"%s\" not defined\n" , cmd);
@@ -187,6 +196,10 @@ void cli_secure_boot_cmd(const char *cmd)/* Run the command, forcing no flags and faking argc and argv. */ rc = (cmdtp->cmd)(cmdtp,0 ,1 , (char **)&cmd); +#else + rc =board_run_command (cmd); +#endif +/* Shouldn't ever return from boot command. */ printf ("## Error: \"%s\" returned (code %d)\n" , cmd, rc);
@@ -205,8 +218,10 @@ void cli_loop(void)parse_file_outer ();/* This point is never reached */ for (;;); -#else +#elif defined(CONFIG_CMDINE )cli_simple_loop (); +#else +printf ("## U-Boot command line is disabled. Please enable CONFIG_CMDLINE\n" );#endif /*CONFIG_SYS_HUSH_PARSER*/ }
common/command.c +6 -0
@@ -85,6 +85,7 @@ int _do_help(cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t *cmdtp, int flag,/* find command table entry for a command */ cmd_tbl_t *find_cmd_tbl (const char *cmd,cmd_tbl_t *table,int table_len) { +#ifdef CONFIG_CMDLINE cmd_tbl_t *cmdtp;cmd_tbl_t *cmdtp_temp = table;/* Init value */ const char *p;
@@ -111,6 +112,7 @@ cmd_tbl_t *find_cmd_tbl(const char *cmd, cmd_tbl_t *table, int table_len)if (n_found ==1 ) {/* exactly one match */ return cmdtp_temp; } +#endif /* CONFIG_CMDLINE */ return NULL ;/* not found or ambiguous command */ }
@@ -162,6 +164,7 @@ int var_complete(int argc, char * const argv[], char last_char, int maxv, char *static int complete_cmdv (int argc,char *const argv[],char last_char,int maxv,char *cmdv[]) { +#ifdef CONFIG_CMDLINE cmd_tbl_t *cmdtp =ll_entry_start (cmd_tbl_t, cmd);const int count =ll_entry_count (cmd_tbl_t, cmd);const cmd_tbl_t *cmdend = cmdtp + count;
@@ -231,6 +234,9 @@ static int complete_cmdv(int argc, char * const argv[], char last_char, int maxv cmdv[n_found] =NULL ;return n_found; +#else +return 0 ; +#endif }static int make_argv (char *s,int argvsz,char *argv[])
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 5/9 Drop command-processing code when CONFIG_CMDLINE is disabled
Quoted 4 lines · Simon Glass
Command parsing and processing code is not needed when the command line is disabled. Remove this code in that case.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/6f24eef9/attachment.sig>
PATCH 6/9 Hang when no command line processing can be performed
In reply to Simon GlassNormally board_run_command() will handle command processed. But if for some reason it returns then we should hang to avoid further processing.
---
common/main.c | 1 + 1 file changed, 1 insertion(+)
common/main.c +1 -0
@@ -72,4 +72,5 @@ void main_loop(void)autoboot_command (s);cli_loop (); +hang (); }
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 6/9 Hang when no command line processing can be performed
Quoted 4 lines · Simon Glass
Normally
board_run_command()will handle command processed. But if for some reason it returns then we should hang to avoid further processing.Signed-off-by Simon Glass <[email protected]>
... but can we maybe try and force this to happen as an experiment and see if panic here?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/0b137b0e/attachment.sig>
PATCH 6/9 Hang when no command line processing can be performed
Hi Tom,
Quoted 11 lines · Tom Rini
Quoted 4 lines · Simon Glass
Normally
board_run_command()will handle command processed. But if for some reason it returns then we should hang to avoid further processing.Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>... but can we maybe try and force this to happen as an experiment and see if panic here?
Yes this comes up with sandbox when the option is enabled.
Regards,
Simon
PATCH 6/9 Hang when no command line processing can be performed
Quoted 8 lines · Simon Glass
Hi Tom,
Quoted 5 lines · Tom Rini
Quoted 3 lines · Simon Glass
Normally
board_run_command()will handle command processed. But if for some reason it returns then we should hang to avoid further processing.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>... but can we maybe try and force this to happen as an experiment and see if panic here?
Yes this comes up with sandbox when the option is enabled.
Sorry, I mean that instead of hang() we call panic("..something") ?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/5afd343b/attachment.sig>
PATCH 7/9 Allow command code to compile to nothing
In reply to Simon GlassWhen CONFIG_CMDLINE is disabled we need to remove all the command-line code. Most can be removed by dropping the appropriate linker lists from the images, but sub-commands must be dealt with specially.
A simple mechanism is used to avoid 'unused static function' errors.
---
include/command.h | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-)
include/command.h +45 -4
@@ -144,6 +144,24 @@ int cmd_process(int flag, int argc, char * const argv[], int *repeatable, unsigned long *ticks);void fixup_cmdtable (cmd_tbl_t *cmdtp,int size); + +/** +* board_run_command() - Fallback function to execute a command +* +* When no command line features are enabled in U-Boot, this function is +* called to execute a command. Typically the function can look at the +* command and perform a few very specific tasks, such as booting the +* system in a particular way. +* +* This function is only used when CONFIG_CMDLINE is not enabled. +* +* In normal situations this function should not return, since U-Boot will +* simply hang. +* +* @cmdline: Command line string to execute +* @return 0 if OK, 1 for error +*/ +int board_run_command (const char *cmdline);#endif /* __ASSEMBLY__ */ /*
@@ -164,21 +182,44 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);# define _CMD_HELP (x)#endif +#ifdef CONFIG_CMDLINE #define U_BOOT_CMD_MKENT_COMPLETE (_name, _maxargs, _rep, _cmd, \ _usage, _help, _comp) \ { #_name, _maxargs, _rep, _cmd, _usage, \ _CMD_HELP(_help) _CMD_COMPLETE(_comp) } -#define U_BOOT_CMD_MKENT (_name, _maxargs, _rep, _cmd, _usage, _help) \ - U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ - _usage, _help, NULL) -#define U_BOOT_CMD_COMPLETE (_name, _maxargs, _rep, _cmd, _usage, _help, _comp) \ ll_entry_declare(cmd_tbl_t, _name, cmd) = \ U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ _usage, _help, _comp); +#else +#define U_BOOT_SUBCMD_START (name) static cmd_tbl_t name[] = {}; +#define U_BOOT_SUBCMD_END + +#define _CMD_REMOVE (_name, _cmd) \ + int __remove_ ## _name(void) \ + { \ + if (0) \ + _cmd(NULL, 0, 0, NULL); \ + return 0; \ + } +#define U_BOOT_CMD_MKENT_COMPLETE (_name, _maxargs, _rep, _cmd, _usage, \ + _help, _comp) \ + { #_name, _maxargs, _rep, 0 ? _cmd : NULL, _usage, \ + _CMD_HELP(_help) _CMD_COMPLETE(_comp) } + +#define U_BOOT_CMD_COMPLETE (_name, _maxargs, _rep, _cmd, _usage, _help, \ + _comp) \ + _CMD_REMOVE(sub_ ## _name, _cmd) + +#endif /* CONFIG_CMDLINE */ +#define U_BOOT_CMD (_name, _maxargs, _rep, _cmd, _usage, _help) \ U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, NULL) +#define U_BOOT_CMD_MKENT (_name, _maxargs, _rep, _cmd, _usage, _help) \ + U_BOOT_CMD_MKENT_COMPLETE(_name, _maxargs, _rep, _cmd, \ + _usage, _help, NULL) +#endif /* __COMMAND_H */
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 7/9 Allow command code to compile to nothing
Quoted 7 lines · Simon Glass
When
CONFIG_CMDLINEis disabled we need to remove all the command-line code. Most can be removed by dropping the appropriate linker lists from the images, but sub-commands must be dealt with specially.A simple mechanism is used to avoid 'unused static function' errors.
Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/a2515f7f/attachment.sig>
PATCH 7/9 Allow command code to compile to nothing
In reply to Simon GlassQuoted 15 lines · Simon Glass
When
CONFIG_CMDLINEis disabled we need to remove all the command-line code. Most can be removed by dropping the appropriate linker lists from the images, but sub-commands must be dealt with specially.A simple mechanism is used to avoid 'unused static function' errors.
include/command.h +7
-0+/** +* board_run_command() - Fallback function to execute a command +* +* When no command line features are enabled in U-Boot, this function is +* called to execute a command. Typically the function can look at the +* command and perform a few very specific tasks, such as booting the +* system in a particular way.
include/command.h int cmd_process(int flag, int argc, char * const argv[], · line 164
Quoted 10 lines
include/command.h +10
-0+* +* This function is only used when CONFIG_CMDLINE is not enabled. +* +* In normal situations this function should not return, since U-Boot will +* simply hang. +* +* @cmdline: Command line string to execute +* @return 0 if OK, 1 for error +*/ +int board_run_command (const char *cmdline);
Doesn't this need to be part of patch 5/9 too, since the function is first called there?
PATCH 7/9 Allow command code to compile to nothing
Hi Stephen,
Quoted 27 lines · Stephen Warren
Quoted 26 lines · Simon Glass
When
CONFIG_CMDLINEis disabled we need to remove all the command-line code. Most can be removed by dropping the appropriate linker lists from the
images, but sub-commands must be dealt with specially.A simple mechanism is used to avoid 'unused static function' errors.
include/command.h +11
-0+/** +* board_run_command() - Fallback function to execute a command +* +* When no command line features are enabled in U-Boot, this function is +* called to execute a command. Typically the function can look at the +* command and perform a few very specific tasks, such as booting the +* system in a particular way. +* +* This function is only used when CONFIG_CMDLINE is not enabled. +* +* In normal situations this function should not return, since U-Boot will
+ * simply hang.
+ *
Quoted 8 lines
Quoted 4 lines
+ * @cmdline: Command line string to execute
+ * @return 0 if OK, 1 for error
+ */
+intboard_run_command(const char *cmdline);Doesn't this need to be part of patch 5/9 too, since the function is first called there?
See my comment elsewhere. This is just the function declaration - it is not necessarily called by any board. But if CONFIG_CMDLINE is disabled, this function will need to be supplied.
Regards,
Simon
PATCH 8/9 Allow command-line files to be dropped
In reply to Simon GlassThese files do not need to be compiled when CONFIG_CMDLINE is disabled. Update the Makefile to reflect this.
---
common/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
common/Makefile +2 -2
@@ -148,10 +148,10 @@ endif endif # We always have this since drivers/ddr/fs/interactive.c needs it -obj-y += cli_simple.o +obj-$(CONFIG_CMDLINE) += cli_simple.o obj-y += cli.o -obj-y += cli_readline.o +obj-$(CONFIG_CMDLINE) += cli_readline.o obj-y += command.o obj-y += s_record.o obj-y += xyzModem.o
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 8/9 Allow command-line files to be dropped
Quoted 4 lines · Simon Glass
These files do not need to be compiled when
CONFIG_CMDLINEis disabled. Update theMakefileto reflect this.Signed-off-by Simon Glass <[email protected]>
... but did you buildman the world here? iirc, we have some cases that fake running a command to make something important happen here.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/cfc650ac/attachment.sig>
PATCH 8/9 Allow command-line files to be dropped
Hi Tom,
Quoted 11 lines · Tom Rini
Quoted 4 lines · Simon Glass
These files do not need to be compiled when
CONFIG_CMDLINEis disabled. Update theMakefileto reflect this.Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>... but did you buildman the world here? iirc, we have some cases that fake running a command to make something important happen here.
Not on this commit, but for the series. I will though.
It is definitely possible that enabling the option will create build errors. For one, you need a board_run_command() function to be present. I've tested it for sandbox and am actually thinking of adding a sandbox board without commands.
Regards,
Simon
PATCH 9/9 Drop various features when the command line is not available
In reply to Simon GlassSome features are only useful or meaningful when the command line is present. Ensure that these features are not compiled in when CONFIG_CMDLINE is not enabled.
---
include/config_fallbacks.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/config_fallbacks.h +10 -0
@@ -97,4 +97,14 @@# endif #endif +#ifndef CONFIG_CMDLINE +#undef CONFIG_CMDLINE_EDITING +#undef CONFIG_SYS_LONGHELP +#undef CONFIG_CMD_BOOTD +#undef CONFIG_CMD_RUN +#undef CONFIG_SYS_HUSH_PARSER +#undef CONFIG_CMD_ASKENV +#undef CONFIG_MENU +#endif +#endif /* __CONFIG_FALLBACKS_H */
Signature · 1 line
2.7.0.rc3.207.g0ac5344
PATCH 9/9 Drop various features when the command line is not available
Quoted 5 lines · Simon Glass
Some features are only useful or meaningful when the command line is present. Ensure that these features are not compiled in when
CONFIG_CMDLINEis not enabled.Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160226/28c28044/attachment.sig>
PATCH 9/9 Drop various features when the command line is not available
In reply to Simon GlassQuoted 3 lines · Simon Glass
Some features are only useful or meaningful when the command line is present. Ensure that these features are not compiled in when
CONFIG_CMDLINEis not enabled.
How does this series affect the various code that executes other U-Boot functionality by executing commands rather than calling functions? For instance, drivers/dfu/dfu_mmc.c:mmc_file_op() calls run_command() to perform the actual disk I/O. I assume that is incompatible with enabling this new feature? If so, can Kconfig enforce that?
PATCH 9/9 Drop various features when the command line is not available
Quoted 11 lines · Stephen Warren
Quoted 3 lines · Simon Glass
Some features are only useful or meaningful when the command line is present. Ensure that these features are not compiled in when
CONFIG_CMDLINEis not enabled.How does this series affect the various code that executes other U-Boot functionality by executing commands rather than calling functions? For instance, drivers/dfu/dfu_mmc.c:mmc_file_op() calls
run_command()to perform the actual disk I/O. I assume that is incompatible with enabling this new feature? If so, canKconfigenforce that?
This is what I was trying to get at as well. We may have to initially say that some stuff is dependent on CMDLINE || BROKEN or something as we have some even funkier cases for some FSL DDR things.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160229/2e98ea6f/attachment.sig>
PATCH 9/9 Drop various features when the command line is not available
Hi,
Quoted 13 lines · Tom Rini
Quoted 11 lines · Stephen Warren
Quoted 3 lines · Simon Glass
Some features are only useful or meaningful when the command line is present. Ensure that these features are not compiled in when
CONFIG_CMDLINEis not enabled.How does this series affect the various code that executes other U-Boot functionality by executing commands rather than calling functions? For instance, drivers/dfu/dfu_mmc.c:mmc_file_op() calls
run_command()to perform the actual disk I/O. I assume that is incompatible with enabling this new feature? If so, canKconfigenforce that?
Quoted 3 lines
This is what I was trying to get at as well. We may have to initially say that some stuff is dependent on CMDLINE || BROKEN or something as we have some even funkier cases for some FSL DDR things.
Yes, it will break it. I'd like to think we can move to cleaning this stuff up though.
IMO mmc_file_op() is wrong. It should work using function calls, not through the command-line interface. Perhaps that is hard today, and will get easier with driver model?
Regards,
Simon
PATCH 9/9 Drop various features when the command line is not available
Quoted 20 lines · Simon Glass
Hi,
Quoted 13 lines · Tom Rini
Quoted 11 lines · Stephen Warren
Quoted 3 lines · Simon Glass
Some features are only useful or meaningful when the command line is present. Ensure that these features are not compiled in when
CONFIG_CMDLINEis not enabled.How does this series affect the various code that executes other U-Boot functionality by executing commands rather than calling functions? For instance, drivers/dfu/dfu_mmc.c:mmc_file_op() calls
run_command()to perform the actual disk I/O. I assume that is incompatible with enabling this new feature? If so, canKconfigenforce that?Quoted 3 lines
This is what I was trying to get at as well. We may have to initially say that some stuff is dependent on CMDLINE || BROKEN or something as we have some even funkier cases for some FSL DDR things.
Quoted 6 lines
Yes, it will break it. I'd like to think we can move to cleaning this stuff up though.
IMO
mmc_file_op()is wrong. It should work using function calls, not through the command-line interface. Perhaps that is hard today, and will get easier with driver model?
The DFU case at least was certainly more ugly at the time when doing function calls, yes. And to start with it's not a big deal to mark some things (even whole SoCs) as requiring CMDLINE.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160302/f2cc3420/attachment.sig>