When I bring up my fresh out of the press system, u-boot comes with default environment (that I fine-crafted when compiling u-boot. That is expected.
Loading Environment from MMC... *** Warning - bad CRC, using default environment
However, to automate deployment I would like to do saveenv to initialize the environment in MMC but would like to do it only when there is no valid environment in the storage.
I am looking for a way to determine whether the environment has a bad CRC (such as uninitialized) and initialize it with the default using savenev.
Once I initialize the environment I can further automate settings (such as ethaddr) from my deployment shell script using fw_setenv.
I didn't find a way how to do it programmatically within the u-boot script.