[PATCH 2/2] uboot-envtools: support alternate default config

Bjørn Mork bjorn at mork.no
Fri Dec 11 02:42:22 EST 2020


Luis Araneda <luaraneda at gmail.com> writes:

> I think this could be archived without patching the upstream
> fw_printenv tool, depending on what solution you find acceptable.
>
> My motivation is to reduce the amount of patches that I think are not
> going to be accepted upstream.

Thanks a lot for your valuable feedback. I was not sure which way to
prefer.  This helps a lot.

> Please let me know if I'm missing some details that make the patches
> required, so we can brainstorm alternative solutions.
>
> One solution could be to add an alias using the "-c" option of
> fw_printenv. This is its help text:
>>  -c, --config         configuration file, default:/etc/fw_env.config
>
> So, you could add the following alias:
> # alias fw_printsys='fw_printenv -c /etc/fw_env2.config'

Did not think of that.  Too obvious, probably, Thanks.  But is there any
standard way of configuring system aliases from a package?  I believe
that's a prerequisite.  I'd like these commands to Just Work, preferably
also in a sysupgrade context although that could be solved by the
scripts having knowledge about the underlying config file.

(there are two system partitions.  If OpenWrt ever is to support the
second one, then sysupgrade will have to know about the way U-Boot
selects the next boot.  This is a variable in the "sys" environment)

> A second solution (assuming an alias is not acceptable), would be to
> add a wrapper script, again using the "-c" option.
> The wrapper script could contain:
>> #!/bin/sh
>> fw_printenv -c /etc/fw_env2.config "$@"

Yes, this was actually my first implementation.  It is pretty simple. I
just made it a bit too magic for myself by dealing with an aribtrary
number of configurations.  And then I wanted to "fix" the misleading
help text.  None of that is required..  So two very simple wrappers will
do.

Will send a v2 with this solution unless there are other contradicting
feedback.  And I will try to update the package revision this time...

> Finally, another thing that I noticed from the first patch is that the
> MTD partitions seems to be named u-boot-env2:
>> find_mtd_index u-boot-env2
>
> If that is the case, IMHO it would be more consistent to call the
> command "fw_printenv2" instead of "fw_printsys".
> Sure, it would not be consistent with Realtek's u-boot shell, but the
> naming is more generic and could be used by other devices as well in
> the future where the second env partition has something different than
> system information.
> In this case, variables like "cfgtype" could be renamed to "cfgnum" or
> something else.

Sorry, I really want to be consistent with U-Boot shell here.  We must
expect users with console access, and naming this enviroment differently
from the stock U-Boot will be unnecessarily confusing.

If the mismatch with the Linux/OpenWrt partition names is going to be a
problem, then I'd rather we change those to match stock.  Both realtek
devices I have (a Netgear GS108Tv3 and a ZyXEL GS1900-10HP) use these
partition names:

RTL838x# flshow
=============== FLASH Partition Layout ===============
Index  Name       Size       Address
------------------------------------------------------
 0     LOADER     0xe0000    0xb4000000-0xb40dffff
 1     BDINFO     0x10000    0xb40e0000-0xb40effff
 2     SYSINFO    0x10000    0xb40f0000-0xb40fffff
 3     JFFS2_CFG  0x100000   0xb4100000-0xb41fffff
 4     JFFS2_LOG  0x100000   0xb4200000-0xb42fffff
 5     RUNTIME1   0xe80000   0xb4300000-0xb517ffff
 6     RUNTIME2   0xe80000   0xb5180000-0xb5ffffff
======================================================

So "u-boot-env" is "BDINFO" and "u-boot-env2" is "SYSINFO".  The stock
U-Boot shell refers to the variable sets as "environment" for "BDINFO",
and "system information" for "SYSINFO":

 RTL838x# help printenv
 printenv - print environment variables
 
 Usage:
 printenv 
     - print values of all environment variables
 printenv name ...
    - print value of environment variable 'name'

 RTL838x# help printsys
 printsys - printsys - print system information variables

 Usage:
 printsys 
     - print values of all system information variables
 printenv name ...
     - print value of system information variable 'name'



Huh?  Did not notice that before, but that command name typo is
real. Yes, this is vendor patched and it sucks as expected ;-)

Anyway, the printsys/setsys/savesys along with SYSINFO is consistently
pointing to this as "system information" and not "environment 2".



Bjørn




More information about the openwrt-devel mailing list