]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
env: migrate static flags list to Kconfig
authorJames Hilliard <james.hilliard1@gmail.com>
Mon, 11 May 2026 18:20:25 +0000 (12:20 -0600)
committerTom Rini <trini@konsulko.com>
Mon, 25 May 2026 19:44:40 +0000 (13:44 -0600)
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 use it as the only board-provided
static environment flags list. Convert the remaining default-config users
from CFG_ENV_FLAGS_LIST_STATIC to defconfig settings and drop the legacy
header macro from ENV_FLAGS_LIST_STATIC.

Move the environment flags format documentation out of README and into
the developer environment documentation. Include the format in the
Kconfig help as well.

This lets boards configure writeable-list policy and type validation
from defconfig without adding a config header solely for env flags.

This preserves the behavior of default configs. Header-only cases that
were inactive in upstream defconfigs are not converted into defconfig
entries: iot2050 can add its list when enabling ENV_WRITEABLE_LIST, and
smegw01 can add mmcdev:dw support if the unlocked SYS_BOOT_LOCKED=n
configuration is needed.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Reviewed-by: Walter Schweizer <walter.schweizer@siemens.com>
18 files changed:
README
configs/aristainetos2c_defconfig
configs/aristainetos2ccslb_defconfig
configs/hmibsc_defconfig
configs/imx6q_bosch_acc_defconfig
configs/imx8qxp_capricorn.config
configs/smegw01_defconfig
configs/socrates_defconfig
doc/develop/environment.rst
env/Kconfig
include/configs/aristainetos2.h
include/configs/capricorn-common.h
include/configs/hmibsc.h
include/configs/imx6q-bosch-acc.h
include/configs/iot2050.h
include/configs/smegw01.h
include/configs/socrates.h
include/env_flags.h

diff --git a/README b/README
index 6836a917c790effb3280cc22a5a97e000ab08d8f..664d88a55053ee6c20b6d3f850e7ac5ba8d4a1f7 100644 (file)
--- a/README
+++ b/README
@@ -799,7 +799,7 @@ The following options need to be configured:
                The same can be accomplished in a more flexible way
                for any variable by configuring the type of access
                to allow for those variables in the ".flags" variable
-               or define CFG_ENV_FLAGS_LIST_STATIC.
+               or by setting CONFIG_ENV_FLAGS_LIST_STATIC.
 
 - Protected RAM:
                CFG_PRAM
@@ -1106,49 +1106,6 @@ Configuration Settings:
 - CONFIG_SYS_FLASH_USE_BUFFER_WRITE
                Use buffered writes to flash.
 
-- CONFIG_ENV_FLAGS_LIST_DEFAULT
-- 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,
-       hexadecimal, or boolean.  If CONFIG_CMD_NET is also defined,
-       the variables can also be restricted to IP address or MAC address.
-
-       The format of the list is:
-               type_attribute = [s|d|x|b|i|m]
-               access_attribute = [a|r|o|c]
-               attributes = type_attribute[access_attribute]
-               entry = variable_name[:attributes]
-               list = entry[,list]
-
-       The type attributes are:
-               s - String (default)
-               d - Decimal
-               x - Hexadecimal
-               b - Boolean ([1yYtT|0nNfF])
-               i - IP address
-               m - MAC address
-
-       The access attributes are:
-               a - Any (default)
-               r - Read-only
-               o - Write-once
-               c - Change-default
-
-       - CONFIG_ENV_FLAGS_LIST_DEFAULT
-               Define this to a list (string) to define the ".flags"
-               environment variable in the default or embedded environment.
-
-       - 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"
-               environment variable.  To override a setting in the static
-               list, simply add an entry for the same variable name to the
-               ".flags" variable.
-
-       If CONFIG_REGEX is defined, the variable_name above is evaluated as a
-       regular expression. This allows multiple variables to define the same
-       flags without explicitly listing them for each variable.
-
 The following definitions that deal with the placement and management
 of environment data (variable area); in general, we support the
 following configurations:
index 6923d27f79ae38c7f705014d1566ff438fe86dce..6c44e670cbc54d8250a5f5f03cf879005ef4b476 100644 (file)
@@ -56,6 +56,7 @@ CONFIG_CMD_UBI=y
 CONFIG_OF_CONTROL=y
 CONFIG_DTB_RESELECT=y
 CONFIG_MULTI_DTB_FIT=y
+CONFIG_ENV_FLAGS_LIST_STATIC="ethaddr:mw,serial#:sw,board_type:sw,sysnum:dw,panel:sw,ipaddr:iw,serverip:iw"
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_ENV_SPI_EARLY=y
index 3ffebb15375aff21df5e057e189df3d22076d921..5016646ef87910f235ccbf2bd309ea8f9402cc24 100644 (file)
@@ -56,6 +56,7 @@ CONFIG_CMD_UBI=y
 CONFIG_OF_CONTROL=y
 CONFIG_DTB_RESELECT=y
 CONFIG_MULTI_DTB_FIT=y
+CONFIG_ENV_FLAGS_LIST_STATIC="ethaddr:mw,serial#:sw,board_type:sw,sysnum:dw,panel:sw,ipaddr:iw,serverip:iw"
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_ENV_SPI_EARLY=y
index 1e3d744193d9e314561852324ab10a32bb1f4f30..c8fad154e315279b6dc40102931ef6856b6adc26 100644 (file)
@@ -41,6 +41,7 @@ CONFIG_CMD_EXT4=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 # CONFIG_OF_UPSTREAM is not set
+CONFIG_ENV_FLAGS_LIST_STATIC="BOOT_A_LEFT:dw,BOOT_B_LEFT:dw,BOOT_ORDER:sw"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_MMC_EMMC_HW_PARTITION=2
index 6f0ef2eaee3686825584b5037435babf5ea59318..87cf676ed4c94e6f4c67e66336e12c58bc00390f 100644 (file)
@@ -74,6 +74,7 @@ CONFIG_EFI_PARTITION=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_MULTI_DTB_FIT=y
 CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clocks clock-names interrupt-parent"
+CONFIG_ENV_FLAGS_LIST_STATIC="bootset:bw,clone_pending:bw,endurance_test:bw,env_persisted:bw,factory_reset:bw,fdtcontroladdr:xw,fitpart:dw,mmcpart:dw,production:bw,ustate:dw"
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_REDUNDANT=y
index 2bae5b1a862563a77a68aa1ce6f1483b941c7c37..91da5554db009698b4599602b708172a60bac12e 100644 (file)
@@ -92,6 +92,7 @@ CONFIG_CMD_EXT4=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_SPL_OF_CONTROL=y
+CONFIG_ENV_FLAGS_LIST_STATIC="bootcount:dw,bootdelay:sw,bootlimit:dw,partitionset_active:sw,rastate:dw,sig_a:sw,sig_b:sw,target_env:sw,upgrade_available:dw,ustate:dw"
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_MMC=y
 
index 529836e7bdd93f3e50b543460736214557d3da15..e5d4014d640868541df26eb060b056a5df17a0c1 100644 (file)
@@ -48,6 +48,7 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_SQUASHFS=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_CONTROL=y
+CONFIG_ENV_FLAGS_LIST_STATIC="mmcpart:dw,mmcpart_committed:dw,ustate:dw,bootcount:dw,bootlimit:dw,upgrade_available:dw"
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_REDUNDANT=y
 CONFIG_ENV_RELOC_GD_ENV_ADDR=y
index 217141cceda6bfe7b8b1b3575a755f019ab8e808..79e40268c6b0e5ade71bb92f98702c4a76af2444 100644 (file)
@@ -66,6 +66,7 @@ CONFIG_MTDIDS_DEFAULT="nor0=fe000000.nor_flash,nand0=socrates_nand"
 CONFIG_MTDPARTS_DEFAULT="mtdparts=fe000000.nor_flash:13312k(system1),13312k(system2),5120k(data),128k(env),128k(env-red),768k(u-boot);socrates_nand:256M(ubi-data1),-(ubi-data2)"
 # CONFIG_CMD_IRQ is not set
 CONFIG_OF_CONTROL=y
+CONFIG_ENV_FLAGS_LIST_STATIC="ethaddr:mw,eth1addr:mw,system1_addr:xw,serial#:sw,ethact:sw,ethprime:sw"
 CONFIG_ENV_IS_IN_FLASH=y
 CONFIG_ENV_REDUNDANT=y
 CONFIG_ENV_ADDR_REDUND=0xFFF00000
index e46cd39d6015fcac15eaf8e28e8d18388531b0c3..a7ed4aab0a5fb68fa08f7f35c55dabb225234705 100644 (file)
@@ -49,3 +49,43 @@ The signature of the callback functions is::
   include/search.h
 
 The return value is 0 if the variable change is accepted and 1 otherwise.
+
+Flags for environment variables
+-------------------------------
+
+Environment flags validate the values given to environment variables and
+restrict how environment variables can be changed.
+
+The static list is configured with CONFIG_ENV_FLAGS_LIST_STATIC. The list
+must be in the following format::
+
+    type_attribute = [s|d|x|b|i|m]
+    access_attribute = [a|r|o|c|w]
+    attributes = type_attribute[access_attribute]
+    entry = variable_name[:attributes]
+    list = entry[,list]
+
+The type attributes are:
+
+* s - String (default)
+* d - Decimal
+* x - Hexadecimal
+* b - Boolean ([1yYtT|0nNfF])
+* i - IP address, if networking is enabled
+* m - MAC address, if networking is enabled
+
+The access attributes are:
+
+* a - Any (default)
+* r - Read-only
+* o - Write-once
+* c - Change-default
+* w - Writeable, if CONFIG_ENV_WRITEABLE_LIST is enabled
+
+CONFIG_ENV_FLAGS_LIST_DEFAULT defines the ``.flags`` variable in the
+default or embedded environment. Any association in ``.flags`` overrides
+an association in the static list.
+
+If CONFIG_REGEX is defined, the variable name is evaluated as a regular
+expression. This allows multiple variables to define the same flags without
+explicitly listing them all.
index 7abd82ab6f386862806f3d887bde6f5a150f8f6f..3c9aaeb1f1666b6d312e9e555ffceb5efad007e2 100644 (file)
@@ -34,6 +34,29 @@ 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 following format:
+
+         type_attribute = [s|d|x|b|i|m]
+         access_attribute = [a|r|o|c|w]
+         attributes = type_attribute[access_attribute]
+         entry = variable_name[:attributes]
+         list = entry[,list]
+
+         The type attributes are s for string, d for decimal, x for
+         hexadecimal and b for boolean. If networking is enabled, i can
+         be used for IP addresses and m for MAC addresses.
+
+         The access attributes are a for any, r for read-only, o for
+         write-once and c for change-default. When CONFIG_ENV_WRITEABLE_LIST
+         is enabled, w can be used to mark variables as writable.
+
+         Spaces are also allowed anywhere in the list.
+
 config SAVEENV
        def_bool y if CMD_SAVEENV
 
index 8a66b1275dfee0495798a42e50d022ee14640805..c0e5c72764efd27b6ee8f3d77d5e3a83561e7a18 100644 (file)
 
 /* UBI support */
 
-#define CFG_ENV_FLAGS_LIST_STATIC "ethaddr:mw,serial#:sw,board_type:sw," \
-               "sysnum:dw,panel:sw,ipaddr:iw,serverip:iw"
-
 #endif                         /* __ARISTAINETOS2_CONFIG_H */
index ee13d2ab950a5787ca73f89e5348109439aaf6b1..7120a44d1865a11e4a186b407897981a05c317d0 100644 (file)
 #define CFG_EXTRA_ENV_SETTINGS \
        AHAB_ENV
 
-#ifdef CONFIG_ENV_WRITEABLE_LIST
-#define CFG_ENV_FLAGS_LIST_STATIC \
-       "bootcount:dw," \
-       "bootdelay:sw," \
-       "bootlimit:dw," \
-       "partitionset_active:sw," \
-       "rastate:dw," \
-       "sig_a:sw,sig_b:sw," \
-       "target_env:sw," \
-       "upgrade_available:dw," \
-       "ustate:dw"
-#endif
-
 /* Default location for tftp and bootm */
 
 /* On CCP board, USDHC1 is for eMMC */
index 950ec8b190d2475ac5aeb72e7e882c3b3e22ccc0..ea9762ee4485048f10e51b0698f674f0cdc03752 100644 (file)
@@ -8,8 +8,4 @@
 #ifndef __CONFIGS_HMIBSC_H
 #define __CONFIGS_HMIBSC_H
 
-/* PHY needs a longer aneg time */
-
-#define CFG_ENV_FLAGS_LIST_STATIC "BOOT_A_LEFT:dw,BOOT_B_LEFT:dw,BOOT_ORDER:sw"
-
 #endif
index 84da8250684a1e4a3ef2bfa4d092101607b8d514..e00cddfdac0c2bf3ccb050c8d681997e0f5f1d9c 100644 (file)
                "then env set env_persisted 1; run save_env; fi;\0" \
        "save_env=env save; env save\0"
 
-#define CFG_ENV_FLAGS_LIST_STATIC \
-       "bootset:bw," \
-       "clone_pending:bw," \
-       "endurance_test:bw," \
-       "env_persisted:bw," \
-       "factory_reset:bw," \
-       "fdtcontroladdr:xw," \
-       "fitpart:dw," \
-       "mmcpart:dw," \
-       "production:bw," \
-       "ustate:dw"
-
 #else
 /* SD Card boot */
 #define ENV_EXTRA \
index 5c58c7bbaab45e20616ad4b670dfb97120c08c9a..fac4bbcd4eda37253a23cda2675e3c2dabcfe07d 100644 (file)
        func(MMC, mmc, 0) \
        BOOT_TARGET_USB(func)
 
-#ifdef CONFIG_ENV_WRITEABLE_LIST
-#define CFG_ENV_FLAGS_LIST_STATIC                                      \
-       "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"
-#endif
-
 #endif /* __CONFIG_IOT2050_H */
index 0aa25f9e2eaa6cd2f8b1521a768038f2bafa2d12..c0ca5a7db2f99d632a90e2f3aeb5cef1e29c10ee 100644 (file)
 #define EXTRA_BOOTPARAMS
 #endif
 
-#ifdef CONFIG_SYS_BOOT_LOCKED
-#define EXTRA_ENV_FLAGS
-#else
-#define EXTRA_ENV_FLAGS "mmcdev:dw,"
-#endif
-
-#define CFG_ENV_FLAGS_LIST_STATIC \
-       "mmcpart:dw," \
-       "mmcpart_committed:dw," \
-       "ustate:dw," \
-       "bootcount:dw," \
-       "bootlimit:dw," \
-       "upgrade_available:dw," \
-       EXTRA_ENV_FLAGS
-
 /* Physical Memory Map */
 #define PHYS_SDRAM                     MMDC0_ARB_BASE_ADDR
 
index 006d649f6ed654cc3b6afc51c661f353408e0167..68d177d4ca353104e726f5f54e818206410a658a 100644 (file)
  */
 #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"
-
 /* pass open firmware flat tree */
 
 #endif /* __CONFIG_H */
index 123fdbcb0ba71aed56208ef2660e95aaaad1be8f..245dfdbd564fcd4827f843ae8b6fd250177db78e 100644 (file)
@@ -37,10 +37,6 @@ enum env_flags_varaccess {
 #define ENV_FLAGS_VARTYPE_LOC 0
 #define ENV_FLAGS_VARACCESS_LOC 1
 
-#ifndef CFG_ENV_FLAGS_LIST_STATIC
-#define CFG_ENV_FLAGS_LIST_STATIC ""
-#endif
-
 #if CONFIG_IS_ENABLED(NET)
 #ifdef CONFIG_REGEX
 #define ETHADDR_WILDCARD "\\d*"
@@ -89,7 +85,7 @@ enum env_flags_varaccess {
        NET_FLAGS \
        NET6_FLAGS \
        SERIAL_FLAGS \
-       CFG_ENV_FLAGS_LIST_STATIC
+       CONFIG_ENV_FLAGS_LIST_STATIC
 
 #ifdef CONFIG_CMD_ENV_FLAGS
 /*