env: CONFIG_DEFAULT_ENV_FILE and CFG_EXTRA_ENV_SETTINGS

Hi Tom,
I'm trying to move some envs from a board header file to the default env file. I recall that the envs in CONFIG_DEFAULT_ENV_FILE are appended to the envs in CFG_EXTRA_ENV_SETTINGS. As you mentioned here before:
https://lore.kernel.org/all/20220810170439.GJ1146598@bill-the-cat/
But it looks like envs in CFG_EXTRA_ENV_SETTINGS are completely erased, and then the envs are populated with what's in CONFIG_DEFAULT_ENV_FILE.
Did I understand the usage correctly?
Thanks, Tony

On Thu, Jul 11, 2024 at 01:31:34PM -0700, Tony Dinh wrote:
Hi Tom,
I'm trying to move some envs from a board header file to the default env file. I recall that the envs in CONFIG_DEFAULT_ENV_FILE are appended to the envs in CFG_EXTRA_ENV_SETTINGS. As you mentioned here before:
https://lore.kernel.org/all/20220810170439.GJ1146598@bill-the-cat/
But it looks like envs in CFG_EXTRA_ENV_SETTINGS are completely erased, and then the envs are populated with what's in CONFIG_DEFAULT_ENV_FILE.
Did I understand the usage correctly?
Can you please post your I assume non-functioning-correctly patch? For example, dragonboard410c has both board/qualcomm/dragonboard410c/dragonboard410c.env and sets "#define CFG_EXTRA_ENV_SETTINGS BOOTENV" in include/configs/dragonboard410c.h

Hi Tom,
On Thu, Jul 11, 2024 at 3:46 PM Tom Rini trini@konsulko.com wrote:
On Thu, Jul 11, 2024 at 01:31:34PM -0700, Tony Dinh wrote:
Hi Tom,
I'm trying to move some envs from a board header file to the default env file. I recall that the envs in CONFIG_DEFAULT_ENV_FILE are appended to the envs in CFG_EXTRA_ENV_SETTINGS. As you mentioned here before:
https://lore.kernel.org/all/20220810170439.GJ1146598@bill-the-cat/
But it looks like envs in CFG_EXTRA_ENV_SETTINGS are completely erased, and then the envs are populated with what's in CONFIG_DEFAULT_ENV_FILE.
Did I understand the usage correctly?
Can you please post your I assume non-functioning-correctly patch? For example, dragonboard410c has both board/qualcomm/dragonboard410c/dragonboard410c.env and sets "#define CFG_EXTRA_ENV_SETTINGS BOOTENV" in include/configs/dragonboard410c.h
Here is the patch. Note that this patch depends on a previous patch (irrelevant to this test): https://patchwork.ozlabs.org/project/uboot/patch/20240708043904.5100-1-mibod...
diff --git a/board/Synology/ds414/ds414.env b/board/Synology/ds414/ds414.env new file mode 100644 index 0000000000..03875e4e93 --- /dev/null +++ b/board/Synology/ds414/ds414.env @@ -0,0 +1,3 @@ +# Boot to original firmware if bootstd failed +# +bootcmd=bootflow scan -lb; run bootcmd_legacy diff --git a/configs/ds414_defconfig b/configs/ds414_defconfig index 6391c43474..9dd07f01c9 100644 --- a/configs/ds414_defconfig +++ b/configs/ds414_defconfig @@ -55,6 +55,8 @@ CONFIG_CMD_UBI=y CONFIG_ENV_OVERWRITE=y CONFIG_ENV_SPI_MAX_HZ=50000000 CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_USE_DEFAULT_ENV_FILE=y +CONFIG_DEFAULT_ENV_FILE="board/Synology/ds414/ds414.env" CONFIG_ARP_TIMEOUT=200 CONFIG_NET_RETRY_COUNT=50 CONFIG_NET_RANDOM_ETHADDR=y
Now, I kwboot the newly built u-boot. In the serial console, I set the envs to default expecting only the bootcmd is replaced. But all other envs that were in CFG_EXTRA_ENV_SETTINGS got erased.
DS414> ver U-Boot 2024.07-tld-1-g2b2b95c77b37-dirty (Jul 11 2024 - 17:10:09 -0700) Synology DS214+/DS414 2/4-Bay Diskstation
DS414> env def -a ## Resetting to default environment
DS414> printenv bootcmd=bootflow scan -lb; run bootcmd_legacy
Environment size: 47/65532 bytes DS414>
All the best, Tony
-- Tom

Tony Dinh mibodhi@gmail.com writes:
Hi Tom,
I'm trying to move some envs from a board header file to the default env file. I recall that the envs in CONFIG_DEFAULT_ENV_FILE are appended to the envs in CFG_EXTRA_ENV_SETTINGS. As you mentioned here before:
https://lore.kernel.org/all/20220810170439.GJ1146598@bill-the-cat/
But it looks like envs in CFG_EXTRA_ENV_SETTINGS are completely erased, and then the envs are populated with what's in CONFIG_DEFAULT_ENV_FILE.
Author of CONFIG_DEFAULT_ENV_FILE here.
Yes, the point of that option is that you supply the entire and full intended default environment in that file. No U-Boot CONFIG_ options of CFG_* defines or anything else affects what goes into the default env when that option is used. [At run-time, U-Boot probably injects/sets a few env vars, but that's true regardless of how the default env came to be].
I think there may be some confusion with the much newer CONFIG_ENV_SOURCE_FILE, which is another mechanism entirely. In that case the pointed-to source file is sent through cpp, thus allowing some u-boot config stuff to be used/referenced, and I think some further bells-and-whistles also exist. I don't know if CFG_EXTRA_ENV_SETTINGS are taken into account in that case or not.
Rasmus

On Fri, Jul 12, 2024 at 10:14:27AM +0200, Rasmus Villemoes wrote:
Tony Dinh mibodhi@gmail.com writes:
Hi Tom,
I'm trying to move some envs from a board header file to the default env file. I recall that the envs in CONFIG_DEFAULT_ENV_FILE are appended to the envs in CFG_EXTRA_ENV_SETTINGS. As you mentioned here before:
https://lore.kernel.org/all/20220810170439.GJ1146598@bill-the-cat/
But it looks like envs in CFG_EXTRA_ENV_SETTINGS are completely erased, and then the envs are populated with what's in CONFIG_DEFAULT_ENV_FILE.
Author of CONFIG_DEFAULT_ENV_FILE here.
Yes, the point of that option is that you supply the entire and full intended default environment in that file. No U-Boot CONFIG_ options of CFG_* defines or anything else affects what goes into the default env when that option is used. [At run-time, U-Boot probably injects/sets a few env vars, but that's true regardless of how the default env came to be].
I think there may be some confusion with the much newer CONFIG_ENV_SOURCE_FILE, which is another mechanism entirely. In that case the pointed-to source file is sent through cpp, thus allowing some u-boot config stuff to be used/referenced, and I think some further bells-and-whistles also exist. I don't know if CFG_EXTRA_ENV_SETTINGS are taken into account in that case or not.
Yes, I think you're right about the confusion as I too missed that in my reply.

On Fri, Jul 12, 2024 at 9:50 AM Tom Rini trini@konsulko.com wrote:
On Fri, Jul 12, 2024 at 10:14:27AM +0200, Rasmus Villemoes wrote:
Tony Dinh mibodhi@gmail.com writes:
Hi Tom,
I'm trying to move some envs from a board header file to the default env file. I recall that the envs in CONFIG_DEFAULT_ENV_FILE are appended to the envs in CFG_EXTRA_ENV_SETTINGS. As you mentioned here before:
https://lore.kernel.org/all/20220810170439.GJ1146598@bill-the-cat/
But it looks like envs in CFG_EXTRA_ENV_SETTINGS are completely erased, and then the envs are populated with what's in CONFIG_DEFAULT_ENV_FILE.
Author of CONFIG_DEFAULT_ENV_FILE here.
Yes, the point of that option is that you supply the entire and full intended default environment in that file. No U-Boot CONFIG_ options of CFG_* defines or anything else affects what goes into the default env when that option is used. [At run-time, U-Boot probably injects/sets a few env vars, but that's true regardless of how the default env came to be].
I think there may be some confusion with the much newer CONFIG_ENV_SOURCE_FILE, which is another mechanism entirely. In that case the pointed-to source file is sent through cpp, thus allowing some u-boot config stuff to be used/referenced, and I think some further bells-and-whistles also exist. I don't know if CFG_EXTRA_ENV_SETTINGS are taken into account in that case or not.
Yes, I think you're right about the confusion as I too missed that in my reply.
OK, thank you all for your clarification!
All the best, Tony
-- Tom
participants (3)
-
Rasmus Villemoes
-
Tom Rini
-
Tony Dinh