Skip to main content.

Group environment Variables:

Rationale:

In many cases the environment settings become so big that they are difficult to navigate and to change. It has been suggested that it would be nice if variables could be ordered into "groups" or "blocks", but it seems difficult to get an agreement what exactly these groupos should be.

Suggested Implementation:

The following idea attempts to be as little introsive to existing code as possible, while allowing maximum flexibility at the same time.

Only a single new environment variable, "env_groups" has to be reserved for the implementation of this feature. It is suggested, that the "env_" variable prefix gets reserved for this, even though this is not necessary from the technical point of view.

"env_groups" is intended to hold a list of variable names.

The implementation of the "printenv" command needs to be changed such that it groups the output according to the names stored in this list.

Example:

=> setenv env_groups env_net env_boot env_flash
=> setenv env_net ethaddr ipaddr serverip gatewayip netmask hostname
=> setenv env_boot bootfile fdt_file rd_file kernel_addr_r fdt_addr_r rd_addr_r
=> setenv env_flash kernel_addr fdt_addr rd_addr

"printenv" would then first print the variables listed in these groups, like that (stripping off the "env_" prefix from the group name (if present):

net:
====
ethaddr=00:D0:93:17:EB:68
## Error: "gatewayip" not defined
hostname=tqm5200s
ipaddr=192.168.160.4
netmask=255.255.0.0
serverip=192.168.1.1

boot:
=====
bootfile=tqm5200/uImage
fdt_addr_r=b00000
fdt_file=tqm5200/tqm5200.dtb
kernel_addr_r=900000
## Error: "rd_addr_r" not defined
## Error: "rd_file" not defined

flash:
======
fdt_addr=400000
kernel_addr=500000
rd_addr=800000

Other:
======
...

Note 1: I think it makes sense to raise errors as shown above for variables, that are undefined but listed as members of some group.

Note 2: It is trivial to print just a the variables of a specific group by running for example:

=> printenv ${env_net}

Note 3: If the "Set Environment to Default Values" feature gets implemented as suggested, it is also trivial to delete or reset all variables of a group to their built-in default values by running for example:

=> environment default ${env_net}
=> environment clear ${env_flash}

Additional feature:

It would be nice if variables in each group could be sorted alphabetically when they are printed using the "printev" command.

-- WolfgangDenk - 12 Oct 2008