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

Luis Araneda luaraneda at gmail.com
Thu Dec 10 22:58:41 EST 2020


Hi Bjørn,

On Thu, Dec 10, 2020 at 9:42 AM Bjørn Mork <bjorn at mork.no> wrote:
>
> Now that we can create an alternate configuration file, add support
> for selecting it by using the alternate application names
> `fw_printsys' or `fw_setsys'.
>
> Signed-off-by: Bjørn Mork <bjorn at mork.no>
> ---
>  package/boot/uboot-envtools/Makefile          |   2 +
>  .../002-support-alternate-config.patch        |  91 ++++++++++
>  .../patches/003-fix-usage-text.patch          | 167 ++++++++++++++++++
>  3 files changed, 260 insertions(+)
>  create mode 100644 package/boot/uboot-envtools/patches/002-support-alternate-config.patch
>  create mode 100644 package/boot/uboot-envtools/patches/003-fix-usage-text.patch

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.
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'

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 "$@"

If you still want to modify the fw_printenv, I would suggest patching
it so it accepts a new argument with the function requested (print,
set) that it can be used to override the automatic detection based on
the cmd name.
I see you already have something similar to this on the second patch.
To me, this sounds like a modification that could be upstreamed.


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.

Regards,
Luis Araneda.



More information about the openwrt-devel mailing list