[U-Boot-Users] improvement to setenv handling

Ranger, Jean-Marc jeanmarc.ranger at smisrd.com
Tue Sep 13 19:41:22 CEST 2005


Hi,

While setting-up an OMAP 5912 OSK, I experienced funny behavior with
U-Boot's setenv command.  The cause was that I was using an invalid syntax
with an equal sign, i.e.
  setenv variable=value
instead of
  setenv variable value

Apparently, nothing in U-Boot's code prevents from defining a variable with
an equal in its name, but this cause strange behavious - see the examples
below.  In particular, pay attention to the fact that defining variable
"a=b" cause existing variable "a" to be erased.  The opposite is true also.

Would it be a fair limitation to impose that variable names can't contain an
equal sign, and either accept my invalid syntax or report an error ?

Please note that this was tested with a binary image of U-Boot 1.1.1 as
supplied by TI/Spectrum.  I'd guess it also true on a stock 1.1.3, but I
didn't test. 

Any comments ?

Jean-Marc Ranger
Ingénieur logiciel / Software Engineer
SMIS R&D inc.
3100 Industriel
Sherbrooke, Québec
Canada  J1L 1V8
Tel (819) 829-5120 ext 4242
Fax (819) 829-1133 



U-Boot 1.1.1 (Jul 11 2005 - 15:47:28)

U-Boot code: 11080000 -> 11095D78  BSS: -> 1109A548
RAM Configuration:
Bank #0: 10000000 32 MB
Micron StrataFlash MT28F128J3 device initialized
Flash: 32 MB
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
OMAP5912 OSK # setenv a b
OMAP5912 OSK # printenv
baudrate=115200
ipaddr=156.117.97.156
serverip=156.117.97.139
netmask=255.255.254.0
bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4
mem=30M
bootcmd=bootm 0x100000
bootfile=uImage
bootdelay=10
stdin=serial
stdout=serial
stderr=serial
a=b

Environment size: 260/131068 bytes
OMAP5912 OSK # setenv a b=c
OMAP5912 OSK # printenv
baudrate=115200
ipaddr=156.117.97.156
serverip=156.117.97.139
netmask=255.255.254.0
bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4
mem=30M
bootcmd=bootm 0x100000
bootfile=uImage
bootdelay=10
stdin=serial
stdout=serial
stderr=serial
a=b=c

Environment size: 262/131068 bytes
OMAP5912 OSK # setenv a=b d
OMAP5912 OSK # printenv
baudrate=115200
ipaddr=156.117.97.156
serverip=156.117.97.139
netmask=255.255.254.0
bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4
mem=30M
bootcmd=bootm 0x100000
bootfile=uImage
bootdelay=10
stdin=serial
stdout=serial
stderr=serial
a=b=d

Environment size: 262/131068 bytes
OMAP5912 OSK # setenv a=b
OMAP5912 OSK # printenv
baudrate=115200
ipaddr=156.117.97.156
serverip=156.117.97.139
netmask=255.255.254.0
bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4
mem=30M
bootcmd=bootm 0x100000
bootfile=uImage
bootdelay=10
stdin=serial
stdout=serial
stderr=serial

Environment size: 256/131068 bytes
OMAP5912 OSK # setenv a=b e
OMAP5912 OSK # printenv
baudrate=115200
ipaddr=156.117.97.156
serverip=156.117.97.139
netmask=255.255.254.0
bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4
mem=30M
bootcmd=bootm 0x100000
bootfile=uImage
bootdelay=10
stdin=serial
stdout=serial
stderr=serial
a=b=e

Environment size: 262/131068 bytes
OMAP5912 OSK # setenv a b=f
OMAP5912 OSK # printenv
baudrate=115200
ipaddr=156.117.97.156
serverip=156.117.97.139
netmask=255.255.254.0
bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4
mem=30M
bootcmd=bootm 0x100000
bootfile=uImage
bootdelay=10
stdin=serial
stdout=serial
stderr=serial
a=b=f

Environment size: 262/131068 bytes
OMAP5912 OSK #




More information about the U-Boot mailing list