How to fine tune the U-boot env?

I’m facing a strange problem after I modify the U-boot env with additional variables (which are required for our use case).
Now, during the first boot after flashing the board, the U-boot env will not update to our new configuration (i.e. it will boot with the default). If I do the below steps:

env default -f -a
saveenv

Then the U-boot will show and take updated boot arguments and boot successfully!
Also, I have seen the below prints during saving the env manually:

saveenv
Saving Environment to MMC… Writing to redundant MMC(0)… OK
saveenv
Saving Environment to MMC… Writing to MMC(0)… OK

Why the env saving first to the redundant part and then to actual part?

May I know what went wrong here? Should I modify anything to correct this behavior?

During further debugging, I found that the variables are setting with below values:

#define CONFIG_ENV_SIZE 0x20000
#define CONFIG_ENV_OFFSET 0x800000
#define CONFIG_ENV_OFFSET_REDUND 0x1000000

But I have set the CONFIG_ENV_SIZE to 0x2000 and CONFIG_ENV_OFFSET to 64 x 64KB and not configuring the CONFIG_ENV_OFFSET_REDUND in the header file. These values are overwritten by Mender env settings but with wrong values.

May I know how to set the value correctly to our need ?

I think you need to take a look at this variable : MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET

For example, you can find an example here : https://github.com/mendersoftware/meta-mender-community/blob/thud/meta-mender-atmel/templates/local.conf.append#L11

# Environment
MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_1 = "0x2000"
# Redundant environment
MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_2 = "0x4000"
1 Like
saveenv
Saving Environment to MMC…  **Writing to redundant MMC(0)** … OK
saveenv
Saving Environment to MMC…  **Writing to MMC(0)** … OK

This is expected behavior. It is an A/B update strategy applied to U-boot environment. The naming “redundant” does add to the confusion, but they are equal and one is active and one is inactive for fallback.

1 Like

@texierp Thank you very much for the reply. I will modify these variables and try. I will update the progress :slight_smile:

1 Like

@mirzak I though first eMMC will come and once, it fails then redundant will come. Here, I think the eMMC some how got failed and redundant came at first place. Once, I save the redundant and then save it again, then, eMMC came :confused: