env: add Kconfig option for static flags list
PATCH 1/1 env: add Kconfig option for static flags list
Environment callbacks can already be configured from Kconfig with CONFIG_ENV_CALLBACK_LIST_STATIC, but static environment flags still require board headers to define CFG_ENV_FLAGS_LIST_STATIC.
Add CONFIG_ENV_FLAGS_LIST_STATIC and append it to ENV_FLAGS_LIST_STATIC after the legacy CFG_ENV_FLAGS_LIST_STATIC value. Normalize existing CFG_ENV_FLAGS_LIST_STATIC definitions to end with a comma so the Kconfig list can be concatenated directly.
This lets boards configure writeable-list policy and type validation from defconfig without adding a config header solely for env flags.
--- README | 6 ++++++ env/Kconfig | 13 +++++++++++++ include/configs/capricorn-common.h | 2 +- include/configs/hmibsc.h | 2 +- include/configs/imx6q-bosch-acc.h | 2 +- include/configs/iot2050.h | 2 +- include/configs/socrates.h | 2 +- include/env_flags.h | 3 ++- 8 files changed, 26 insertions(+), 6 deletions(-)
README +6 -0
@@ -1107,6 +1107,7 @@ Configuration Settings: Use buffered writes to flash. - CONFIG_ENV_FLAGS_LIST_DEFAULT +- CONFIG_ENV_FLAGS_LIST_STATIC - CFG_ENV_FLAGS_LIST_STATIC Enable validation of the values given to environment variables when calling env set. Variables can be restricted to only decimal,
@@ -1133,11 +1134,16 @@ Configuration Settings: r - Read-only o - Write-once c - Change-default + w - Writeable if CONFIG_ENV_WRITEABLE_LIST is enabled - CONFIG_ENV_FLAGS_LIST_DEFAULT Define this to a list (string) to define the ".flags" environment variable in the default or embedded environment. + - CONFIG_ENV_FLAGS_LIST_STATIC + Define this to a list (string) to add to the static flags + list. + - CFG_ENV_FLAGS_LIST_STATIC Define this to a list (string) to define validation that should be done if an entry is not found in the ".flags"
env/Kconfig +13 -0
@@ -34,6 +34,19 @@ config ENV_CALLBACK_LIST_STATIC If the callback name is not specified, then the callback is deleted. Spaces are also allowed anywhere in the list. +config ENV_FLAGS_LIST_STATIC + string "Static flags list" + default "" + help + The environment flags are associated with variables in a static + list. Define this list in the same format as + CFG_ENV_FLAGS_LIST_STATIC. + + When CONFIG_ENV_WRITEABLE_LIST is enabled, the 'w' access attribute + can be used to mark variables as writable. + + Spaces are also allowed anywhere in the list. + config SAVEENV def_bool y if CMD_SAVEENV
include/configs/capricorn-common.h +1 -1
@@ -48,7 +48,7 @@"sig_a:sw,sig_b:sw," \"target_env:sw," \"upgrade_available:dw," \ - "ustate:dw" + "ustate:dw,"#endif /* Default location for tftp and bootm */
include/configs/hmibsc.h +1 -1
@@ -10,6 +10,6 @@/* PHY needs a longer aneg time */ -#define CFG_ENV_FLAGS_LIST_STATIC "BOOT_A_LEFT:dw,BOOT_B_LEFT:dw,BOOT_ORDER:sw" +#define CFG_ENV_FLAGS_LIST_STATIC "BOOT_A_LEFT:dw,BOOT_B_LEFT:dw,BOOT_ORDER:sw,"#endif
include/configs/imx6q-bosch-acc.h +1 -1
@@ -54,7 +54,7 @@"fitpart:dw," \"mmcpart:dw," \"production:bw," \ -"ustate:dw" +"ustate:dw," #else/* SD Card boot */
include/configs/iot2050.h +1 -1
@@ -43,7 +43,7 @@"board_uuid:sw,board_name:sw,board_serial:sw,board_a5e:sw," \"mlfb:sw,fw_version:sw,seboot_version:sw," \"m2_manual_config:sw," \ - "eth1addr:mw,eth2addr:mw,watchdog_timeout_ms:dw,boot_targets:sw" + "eth1addr:mw,eth2addr:mw,watchdog_timeout_ms:dw,boot_targets:sw,"#endif #endif /* __CONFIG_IOT2050_H */
include/configs/socrates.h +1 -1
@@ -108,7 +108,7 @@*/ #define CFG_SYS_BOOTMAPSZ (8 << 20)/* Initial Memory map for Linux */ -#define CFG_ENV_FLAGS_LIST_STATIC "ethaddr:mw,eth1addr:mw,system1_addr:xw,serial#:sw,ethact:sw,ethprime:sw" +#define CFG_ENV_FLAGS_LIST_STATIC "ethaddr:mw,eth1addr:mw,system1_addr:xw,serial#:sw,ethact:sw,ethprime:sw,"/* pass open firmware flat tree */
include/env_flags.h +2 -1
@@ -89,7 +89,8 @@ enum env_flags_varaccess {NET_FLAGS \ NET6_FLAGS \ SERIAL_FLAGS \ - CFG_ENV_FLAGS_LIST_STATIC + CFG_ENV_FLAGS_LIST_STATIC \ + CONFIG_ENV_FLAGS_LIST_STATIC#ifdef CONFIG_CMD_ENV_FLAGS /*
Signature · 1 line
2.53.0
Hi James,
Quoted 82 lines · James Hilliard
Environment callbacks can already be configured from
KconfigwithCONFIG_ENV_CALLBACK_LIST_STATIC, but static environment flags still require board headers to defineCFG_ENV_FLAGS_LIST_STATIC.Add
CONFIG_ENV_FLAGS_LIST_STATICand append it toENV_FLAGS_LIST_STATICafter the legacyCFG_ENV_FLAGS_LIST_STATICvalue. Normalize existingCFG_ENV_FLAGS_LIST_STATICdefinitions to end with a comma so theKconfiglist can be concatenated directly.This lets boards configure writeable-list policy and type validation from defconfig without adding a config header solely for env flags.
Signed-off-by James Hilliard <[email protected]>---
README | 6 ++++++ env/Kconfig | 13 +++++++++++++include/configs/capricorn-common.h| 2 +- include/configs/hmibsc.h | 2 +- include/configs/imx6q-bosch-acc.h | 2 +- include/configs/iot2050.h | 2 +- include/configs/socrates.h | 2 +- include/env_flags.h | 3 ++-8 files changed, 26 insertions(+), 6 deletions(-)README +0
-0@@ -1107,6 +1107,7 @@ Configuration Settings:Use buffered writes to flash.
-CONFIG_ENV_FLAGS_LIST_DEFAULT
+-CONFIG_ENV_FLAGS_LIST_STATIC
-CFG_ENV_FLAGS_LIST_STATIC
Enable validation of the values given to environment variables when calling env set. Variables can be restricted to only decimal,README +0
-0@@ -1133,11 +1134,16 @@ Configuration Settings:r - Read-only
o - Write-once
c - Change-defaultREADME +1
-0+ w - Writeable if CONFIG_ENV_WRITEABLE_LIST is enabled
-CONFIG_ENV_FLAGS_LIST_DEFAULT
Define this to a list (string) to define the ".flags" environment variable in the default or embedded environment.README +4
-0+ - CONFIG_ENV_FLAGS_LIST_STATIC + Define this to a list (string) to add to the static flags + list. +-
CFG_ENV_FLAGS_LIST_STATIC
Define this to a list (string) to define validation that should be done if an entry is not found in the ".flags"env/Kconfig +0
-0@@ -34,6 +34,19 @@ config ENV_CALLBACK_LIST_STATICIf the callback name is not specified, then the callback is deleted. Spaces are also allowed anywhere in the list.
env/Kconfig +13
-0+config ENV_FLAGS_LIST_STATIC + string "Static flags list" + default "" + help + The environment flags are associated with variables in a static + list. Define this list in the same format as + CFG_ENV_FLAGS_LIST_STATIC. + + When CONFIG_ENV_WRITEABLE_LIST is enabled, the 'w' access attribute + can be used to mark variables as writable. + + Spaces are also allowed anywhere in the list. +config SAVEENV
def_booly ifCMD_SAVEENVinclude/configs/capricorn-common.h +0
-0
include/configs/capricorn-common.h line 51
Quoted 5 lines
include/configs/capricorn-common.h +1
-1@@ -48,7 +48,7 @@ "sig_a:sw,sig_b:sw," \ "target_env:sw," \ "upgrade_available:dw," \ -"ustate:dw" +"ustate:dw,"
the implicit requirement to have a coma at the end looks a bit fragile or error-prone to me, I'm not sure if there could be a better option...
Quoted 59 lines
include/configs/capricorn-common.h +0
-0#endif
/* Default location for tftp and bootm */include/configs/hmibsc.h +0
-0@@ -10,6 +10,6 @@
/* PHY needs a longer aneg time */include/configs/hmibsc.h +1
-1-#define CFG_ENV_FLAGS_LIST_STATIC "BOOT_A_LEFT:dw,BOOT_B_LEFT:dw,BOOT_ORDER:sw" +#define CFG_ENV_FLAGS_LIST_STATIC "BOOT_A_LEFT:dw,BOOT_B_LEFT:dw,BOOT_ORDER:sw,"
#endifinclude/configs/imx6q-bosch-acc.h +1
-1@@ -54,7 +54,7 @@ "fitpart:dw," \ "mmcpart:dw," \ "production:bw," \ -"ustate:dw" +"ustate:dw,"
#else
/* SD Card boot */include/configs/iot2050.h +1
-1@@ -43,7 +43,7 @@ "board_uuid:sw,board_name:sw,board_serial:sw,board_a5e:sw," \ "mlfb:sw,fw_version:sw,seboot_version:sw," \ "m2_manual_config:sw," \ -"eth1addr:mw,eth2addr:mw,watchdog_timeout_ms:dw,boot_targets:sw" +"eth1addr:mw,eth2addr:mw,watchdog_timeout_ms:dw,boot_targets:sw," #endif
#endif /*__CONFIG_IOT2050_H*/include/configs/socrates.h +0
-0@@ -108,7 +108,7 @@*/ #define CFG_SYS_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */include/configs/socrates.h +1
-1-#define CFG_ENV_FLAGS_LIST_STATIC "ethaddr:mw,eth1addr:mw,system1_addr:xw,serial#:sw,ethact:sw,ethprime:sw" +#define CFG_ENV_FLAGS_LIST_STATIC "ethaddr:mw,eth1addr:mw,system1_addr:xw,serial#:sw,ethact:sw,ethprime:sw,"
/* pass open firmware flat tree */include/env_flags.h +0
-0
include/env_flags.h enum env_flags_varaccess { · line 92
Quoted 5 lines
include/env_flags.h +1
-1@@ -89,7 +89,8 @@ enum env_flags_varaccess { NET_FLAGS \ NET6_FLAGS \ SERIAL_FLAGS \ -CFG_ENV_FLAGS_LIST_STATIC +CFG_ENV_FLAGS_LIST_STATIC \
While other macros are local to this header, CFG_ENV_FLAGS_LIST_STATIC is external to it and the requirement to have a trailing coma is not obvious... The patch itself looks good though, but maybe there is a way to make this more robust.
Quoted 4 lines
include/env_flags.h +1
-0+CONFIG_ENV_FLAGS_LIST_STATIC
#ifdefCONFIG_CMD_ENV_FLAGS
/*
Signature · 3 lines
Alexander Sverdlin Siemens AG www.siemens.com
Hi James,
Quoted 148 lines · Alexander Sverdlin
Quoted 82 lines · James Hilliard
Environment callbacks can already be configured from
KconfigwithCONFIG_ENV_CALLBACK_LIST_STATIC, but static environment flags still require board headers to defineCFG_ENV_FLAGS_LIST_STATIC.Add
CONFIG_ENV_FLAGS_LIST_STATICand append it toENV_FLAGS_LIST_STATICafter the legacyCFG_ENV_FLAGS_LIST_STATICvalue. Normalize existingCFG_ENV_FLAGS_LIST_STATICdefinitions to end with a comma so theKconfiglist can be concatenated directly.This lets boards configure writeable-list policy and type validation from defconfig without adding a config header solely for env flags.
Signed-off-by James Hilliard <[email protected]>---
README | 6 ++++++ env/Kconfig | 13 +++++++++++++include/configs/capricorn-common.h| 2 +- include/configs/hmibsc.h | 2 +- include/configs/imx6q-bosch-acc.h | 2 +- include/configs/iot2050.h | 2 +- include/configs/socrates.h | 2 +- include/env_flags.h | 3 ++-8 files changed, 26 insertions(+), 6 deletions(-)README +0
-0@@ -1107,6 +1107,7 @@ Configuration Settings:Use buffered writes to flash.
-CONFIG_ENV_FLAGS_LIST_DEFAULT
+-CONFIG_ENV_FLAGS_LIST_STATIC
-CFG_ENV_FLAGS_LIST_STATIC
Enable validation of the values given to environment variables when calling env set. Variables can be restricted to only decimal,README +0
-0@@ -1133,11 +1134,16 @@ Configuration Settings:r - Read-only
o - Write-once
c - Change-defaultREADME +1
-0+ w - Writeable if CONFIG_ENV_WRITEABLE_LIST is enabled
-CONFIG_ENV_FLAGS_LIST_DEFAULT
Define this to a list (string) to define the ".flags" environment variable in the default or embedded environment.README +4
-0+ - CONFIG_ENV_FLAGS_LIST_STATIC + Define this to a list (string) to add to the static flags + list. +-
CFG_ENV_FLAGS_LIST_STATIC
Define this to a list (string) to define validation that should be done if an entry is not found in the ".flags"env/Kconfig +0
-0@@ -34,6 +34,19 @@ config ENV_CALLBACK_LIST_STATICIf the callback name is not specified, then the callback is deleted. Spaces are also allowed anywhere in the list.
env/Kconfig +13
-0+config ENV_FLAGS_LIST_STATIC + string "Static flags list" + default "" + help + The environment flags are associated with variables in a static + list. Define this list in the same format as + CFG_ENV_FLAGS_LIST_STATIC. + + When CONFIG_ENV_WRITEABLE_LIST is enabled, the 'w' access attribute + can be used to mark variables as writable. + + Spaces are also allowed anywhere in the list. +config SAVEENV
def_booly ifCMD_SAVEENVinclude/configs/capricorn-common.h +0
-0include/configs/capricorn-common.h line 51
Quoted 5 lines
include/configs/capricorn-common.h +1
-1@@ -48,7 +48,7 @@ "sig_a:sw,sig_b:sw," \ "target_env:sw," \ "upgrade_available:dw," \ -"ustate:dw" +"ustate:dw," the implicit requirement to have a coma at the end looks a bit fragile or error-prone to me, I'm not sure if there could be a better option...
Quoted 56 lines
include/configs/capricorn-common.h +0
-0#endif
/* Default location for tftp and bootm */include/configs/hmibsc.h +0
-0@@ -10,6 +10,6 @@
/* PHY needs a longer aneg time */include/configs/hmibsc.h +1
-1-#define CFG_ENV_FLAGS_LIST_STATIC "BOOT_A_LEFT:dw,BOOT_B_LEFT:dw,BOOT_ORDER:sw" +#define CFG_ENV_FLAGS_LIST_STATIC "BOOT_A_LEFT:dw,BOOT_B_LEFT:dw,BOOT_ORDER:sw,"
#endifinclude/configs/imx6q-bosch-acc.h +1
-1@@ -54,7 +54,7 @@ "fitpart:dw," \ "mmcpart:dw," \ "production:bw," \ -"ustate:dw" +"ustate:dw,"
#else
/* SD Card boot */include/configs/iot2050.h +1
-1@@ -43,7 +43,7 @@ "board_uuid:sw,board_name:sw,board_serial:sw,board_a5e:sw," \ "mlfb:sw,fw_version:sw,seboot_version:sw," \ "m2_manual_config:sw," \ -"eth1addr:mw,eth2addr:mw,watchdog_timeout_ms:dw,boot_targets:sw" +"eth1addr:mw,eth2addr:mw,watchdog_timeout_ms:dw,boot_targets:sw," #endif
#endif /*__CONFIG_IOT2050_H*/include/configs/socrates.h +0
-0@@ -108,7 +108,7 @@*/ #define CFG_SYS_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */include/configs/socrates.h +1
-1-#define CFG_ENV_FLAGS_LIST_STATIC "ethaddr:mw,eth1addr:mw,system1_addr:xw,serial#:sw,ethact:sw,ethprime:sw" +#define CFG_ENV_FLAGS_LIST_STATIC "ethaddr:mw,eth1addr:mw,system1_addr:xw,serial#:sw,ethact:sw,ethprime:sw,"
/* pass open firmware flat tree */include/env_flags.h +0
-0
Quoted 8 lines
include/env_flags.h enum env_flags_varaccess { · line 92
Quoted 8 lines
include/env_flags.h +1
-1@@ -89,7 +89,8 @@ enum env_flags_varaccess { NET_FLAGS \ NET6_FLAGS \ SERIAL_FLAGS \ -CFG_ENV_FLAGS_LIST_STATIC +CFG_ENV_FLAGS_LIST_STATIC \
Wouldn't it be advantageous to just add "," here ^^^? Both keeping board config headers untouched and not imposing comma requirement on them?
Quoted 10 lines
While other macros are local to this header,
CFG_ENV_FLAGS_LIST_STATICis external to it and the requirement to have a trailing coma is not obvious... The patch itself looks good though, but maybe there is a way to make this more robust.Quoted 4 lines
include/env_flags.h +1
-0+CONFIG_ENV_FLAGS_LIST_STATIC
#ifdefCONFIG_CMD_ENV_FLAGS
/*
Signature · 3 lines
Alexander Sverdlin Siemens AG www.siemens.com
Hi James,
Quoted 29 lines · James Hilliard
Environment callbacks can already be configured from
KconfigwithCONFIG_ENV_CALLBACK_LIST_STATIC, but static environment flags still require board headers to defineCFG_ENV_FLAGS_LIST_STATIC.Add
CONFIG_ENV_FLAGS_LIST_STATICand append it toENV_FLAGS_LIST_STATICafter the legacyCFG_ENV_FLAGS_LIST_STATICvalue. Normalize existingCFG_ENV_FLAGS_LIST_STATICdefinitions to end with a comma so theKconfiglist can be concatenated directly.This lets boards configure writeable-list policy and type validation from defconfig without adding a config header solely for env flags.
Signed-off-by James Hilliard <[email protected]>--- README | 6 ++++++ env/Kconfig | 13 +++++++++++++ include/configs/capricorn-common.h | 2 +- include/configs/hmibsc.h | 2 +- include/configs/imx6q-bosch-acc.h | 2 +- include/configs/iot2050.h | 2 +- include/configs/socrates.h | 2 +- include/env_flags.h | 3 ++- 8 files changed, 26 insertions(+), 6 deletions(-)README +0
-0
README Configuration Settings: · line 1111
Quoted 5 lines
README +1
-0@@ -1107,6 +1107,7 @@ Configuration Settings: Use buffered writes to flash. - CONFIG_ENV_FLAGS_LIST_DEFAULT +- CONFIG_ENV_FLAGS_LIST_STATIC - CFG_ENV_FLAGS_LIST_STATIC
Do we *really* need both? What about migrating CFG_ENV_FLAGS_LIST_STATIC into a Kconfig symbol entirely? We've done this to a lot of CFG_ constants in the past so it's like there's no precedent.
Quoted 25 lines
README +5
-0Enable validation of the values given to environment variables when calling env set. Variables can be restricted to only decimal,@@ -1133,11 +1134,16 @@ Configuration Settings: r - Read-only o - Write-once c - Change-default + w - Writeable if CONFIG_ENV_WRITEABLE_LIST is enabled - CONFIG_ENV_FLAGS_LIST_DEFAULT Define this to a list (string) to define the ".flags" environment variable in the default or embedded environment. + - CONFIG_ENV_FLAGS_LIST_STATIC + Define this to a list (string) to add to the static flags + list. + - CFG_ENV_FLAGS_LIST_STATIC Define this to a list (string) to define validation that should be done if an entry is not found in the ".flags"env/Kconfig +0
-0@@ -34,6 +34,19 @@ config ENV_CALLBACK_LIST_STATIC If the callback name is not specified, then the callback is deleted.
env/Kconfig config ENV_CALLBACK_LIST_STATIC · line 44
Quoted 10 lines
env/Kconfig +8
-0Spaces are also allowed anywhere in the list. +config ENV_FLAGS_LIST_STATIC + string "Static flags list" + default "" + help + The environment flags are associated with variables in a static + list. Define this list in the same format as + CFG_ENV_FLAGS_LIST_STATIC. +
I don't want to be looking for where this is explained, can you at the very least point at where this information is available or even maybe integrate it here?
Cheers,
Quentin
Hi James,
Quoted 17 lines · James Hilliard
env: add
Kconfigoption for static flags listEnvironment callbacks can already be configured from
KconfigwithCONFIG_ENV_CALLBACK_LIST_STATIC, but static environment flags still require board headers to defineCFG_ENV_FLAGS_LIST_STATIC.Add
CONFIG_ENV_FLAGS_LIST_STATICand append it toENV_FLAGS_LIST_STATICafter the legacyCFG_ENV_FLAGS_LIST_STATICvalue. Normalize existingCFG_ENV_FLAGS_LIST_STATICdefinitions to end with a comma so theKconfiglist can be concatenated directly.This lets boards configure writeable-list policy and type validation from defconfig without adding a config header solely for env flags.
Signed-off-by James Hilliard <[email protected]>README | 6 ++++++
Quoted 8 lines
env/Kconfig | 13 +++++++++++++ include/configs/capricorn-common.h | 2 +- include/configs/hmibsc.h | 2 +- include/configs/imx6q-bosch-acc.h | 2 +- include/configs/iot2050.h | 2 +- include/configs/socrates.h | 2 +- include/env_flags.h | 3 ++- 8 files changed, 26 insertions(+), 6 deletions(-)
We are trying to migrate away from the README, so would it be possible to move the docs to one of these files instead:
doc/develop/environment.rstdoc/usage/environment.rst
include/env_flags.h enum env_flags_varaccess { · line 93
Quoted 8 lines
include/env_flags.h +2
-1@@ -89,7 +89,8 @@ enum env_flags_varaccess {NET_FLAGS \ NET6_FLAGS \SERIAL_FLAGS \ -CFG_ENV_FLAGS_LIST_STATIC + CFG_ENV_FLAGS_LIST_STATIC \ +CONFIG_ENV_FLAGS_LIST_STATIC
In include/configs/aristainetos2.h
#define CFG_ENV_FLAGS_LIST_STATIC 'ethaddr:mw,serial#:sw,board_type:sw,' \
'sysnum:dw,panel:sw,ipaddr:iw,serverip:iw'No trailing comma, so setting both will run serverip:iw into the first Kconfig entry. Please normalise this one too.
env/Kconfig config ENV_CALLBACK_LIST_STATIC · line 40
Quoted 9 lines
env/Kconfig +7
-0@@ -34,6 +34,19 @@ config ENV_CALLBACK_LIST_STATIC +config ENV_FLAGS_LIST_STATIC + string "Static flags list" + default "" + help + The environment flags are associated with variables in a static + list. Define this list in the same format as + CFG_ENV_FLAGS_LIST_STATIC.
I agree with Quentin, There are only five remaining users of CFG_ENV_FLAGS_LIST_STATIC, so you should consider converting each to a defconfig setting of CONFIG_ENV_FLAGS_LIST_STATIC and dropping CFG_ENV_FLAGS_LIST_STATIC entirely. Carrying two parallel mechanisms plus the trailing-comma rule seems more confusing than finishing the move.
env/Kconfig config ENV_CALLBACK_LIST_STATIC · line 35
Quoted 4 lines
env/Kconfig +2
-0@@ -34,6 +34,19 @@ config ENV_CALLBACK_LIST_STATIC + When CONFIG_ENV_WRITEABLE_LIST is enabled, the 'w' access attribute + can be used to mark variables as writable.
Regards,
Simon