# How to fine tune the U-boot env?

**URL:** <https://hub.mender.io/t/how-to-fine-tune-the-u-boot-env/368>\
**Category:** General Discussions\
**Tags:** yocto, sumo, rocko, nxp\
**Created:** [March 13, 2019, 3:02pm UTC](https://hub.mender.io/t/how-to-fine-tune-the-u-boot-env/368 "2019-03-13T15:02:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajithpv](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/ajithpv/32/728_2.png) [@ajithpv](https://hub.mender.io/u/ajithpv)\
**Post date:** [March 13, 2019, 3:02pm UTC](https://hub.mender.io/t/how-to-fine-tune-the-u-boot-env/368/1 "2019-03-13T15:02:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ajithpv](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/ajithpv/32/728_2.png) [@ajithpv](https://hub.mender.io/u/ajithpv)\
**Post date:** [March 13, 2019, 3:08pm UTC](https://hub.mender.io/t/how-to-fine-tune-the-u-boot-env/368/2 "2019-03-13T15:08:37Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![texierp](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/texierp/32/45_2.png) [@texierp](https://hub.mender.io/u/texierp)\
**Post date:** [March 13, 2019, 3:30pm UTC](https://hub.mender.io/t/how-to-fine-tune-the-u-boot-env/368/3 "2019-03-13T15:30:23Z")

</div>

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](https://github.com/mendersoftware/meta-mender-community/blob/thud/meta-mender-atmel/templates/local.conf.append#L11)

```auto
# Environment
MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_1 = "0x2000"
# Redundant environment
MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_2 = "0x4000"

```

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [March 13, 2019, 3:40pm UTC](https://hub.mender.io/t/how-to-fine-tune-the-u-boot-env/368/4 "2019-03-13T15:40:53Z")

</div>

```auto
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.

---

<div class="post-metadata">

**Author:** ![ajithpv](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/ajithpv/32/728_2.png) [@ajithpv](https://hub.mender.io/u/ajithpv)\
**Post date:** [March 14, 2019, 7:33am UTC](https://hub.mender.io/t/how-to-fine-tune-the-u-boot-env/368/5 "2019-03-14T07:33:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ajithpv](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/ajithpv/32/728_2.png) [@ajithpv](https://hub.mender.io/u/ajithpv)\
**Post date:** [March 14, 2019, 7:36am UTC](https://hub.mender.io/t/how-to-fine-tune-the-u-boot-env/368/6 "2019-03-14T07:36:52Z")

</div>

@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 😕
