Hi Mark, On 05/04/19 13:13, Jonas Mark (BT-FIR/ENG1) wrote: > Hi, > > Our board stores the U-Boot environment in an MTD partition. I would like to > ensure that there is always an U-Boot environment stored in MTD so that the > userspace tool fw_setenv does not need to fall back on its built in default > environment or a default environment stored in a file (see > https://github.com/sbabic/libubootenv). > > When U-Boot starts up it checks whether the specified MTD partition contains > a valid environment and loads it. In case there is no valid environment it > will use the compiled in default. Is there already a feature in U-Boot which > would then also write that default to the MTD partition? >
As far as I know, there is not (yet ?) a way to expose to the shell if the default environment is used, something like exporting gd->env_valid. > Alternatively a Hush script could help. Is there an easy way to detect that > U-Boot is using the compiled in environment? In that case I could simply do a > saveenv (?) which would then initialize the MTD environment partition. A trick (a hack ?) could be to have a variable in the default environment and you check and delete it if exists, maybe in your "preboot". if env_exists use_default;then setenv use_default;saveenv;fi I do not know if there is a better way to do this. Best regards, Stefano -- ===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected] ===================================================================== _______________________________________________ U-Boot mailing list [email protected] https://lists.denx.de/listinfo/u-boot

