14 spaces + a replacement makes u-boot's setenv angry

THE FOLLOWING WORKS:
setenv a A
setenv b 1${a} 2 3 4 5 6 7 8 9 10 11 12 13 14
setenv b 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

THE FOLLOWING DOESN'T WORK:
setenv b 1${a} 2 3 4 5 6 7 8 9 10 11 12 13 14 15
setenv b "1${a} 2 3 4 5 6 7 8 9 10 11 12 13 14 15"

Note that setenv b '1${a} 2 3 4 5 6 7 8 9 10 11 12 13 14 15' works but
there is no replacement.

So the rule is that setenv is limited to thirteen space if there is a
replacement. Any idea where the problem is in the u-boot code? I have
quickly parsed the tools directory but I haven't found anything
suspicious,

Grégoire

Hi Grégoire,

Let me do some reverse engineering for you. :slight_smile: Each command has its
maximal number of arguments which is the second parameter in macro
U_BOOT_CMD ("include/command.h"):

#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) ...

For "setenv" we can see in "common/cmd_nvedit.c" that second parameter
is CONFIG_SYS_MAXARGS:

U_BOOT_CMD(
  setenv, CONFIG_SYS_MAXARGS, 0, do_setenv,

Thus, in order to change default number of arguments for "setenv" you
have to redefine CONFIG_SYS_MAXARGS macro (for Beagleboard you can
find it in "configs/omap3_beagle.h" and it equals to 16):

#define CONFIG_SYS_MAXARGS 16 /* max number of command args */

Cheers,
Max.

Thanks!

--- git/includes/configs/omap3_beagle.h 2010-11-29 07:51:21.002446998
-0800
+++ git/includes/configs/omap3_beagle.h 2010-11-29 07:51:33.830446995
-0800
@@ -306,7 +306,7 @@
/* Print Buffer Size */
#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + \
           sizeof(CONFIG_SYS_PROMPT) + 16)
-#define CONFIG_SYS_MAXARGS 16 /* max number of command args */
+#define CONFIG_SYS_MAXARGS 32 /* max number of command args */
/* Boot Argument Buffer Size */
#define CONFIG_SYS_BARGSIZE (CONFIG_SYS_CBSIZE)

Grégoire