# Mender from scratch

**URL:** <https://hub.mender.io/t/mender-from-scratch/391>\
**Category:** Other\
**Created:** [March 21, 2019, 8:25am UTC](https://hub.mender.io/t/mender-from-scratch/391 "2019-03-21T08:25:01Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ruben](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/ruben/32/565_2.png) [@ruben](https://hub.mender.io/u/ruben)\
**Post date:** [April 28, 2021, 12:43pm UTC](https://hub.mender.io/t/mender-from-scratch/391/4 "2021-04-28T12:43:45Z")

</div>

Hi,

we have 2 different NXP imx7 based projects, both are using mender. And we have the same issue with both of them:  
When booting the devices initially, u-boot writes the environment to mmc. u-boot and uboot-env are outside a partition, directly in memory.  
But it looks like the offset of the first partition ( in our case /uboot which is not used) is overwritten by the uboot-env.  
This causes mount problems during linux boot as the partition is corrupted.

My workaround to patch this behaviour: adding parameter `--offset 32768` to line [meta-mender/mender-part-images.bbclass at dunfell · mendersoftware/meta-mender · GitHub](https://github.com/mendersoftware/meta-mender/blob/dunfell/meta-mender-core/classes/mender-part-images.bbclass#L122)

With this patch the partition layout changes from (output of fdisk -l)

```auto
Disk /dev/mmcblk0: 7.29 GiB, 7822376960 bytes, 15278080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x33c68b61

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 32768 65535 32768 16M c W95 FAT32 (LBA)
/dev/mmcblk0p2 65536 1064959 999424 488M 83 Linux
/dev/mmcblk0p3 1064960 2064383 999424 488M 83 Linux
/dev/mmcblk0p4 2064384 4161535 2097152 1G 83 Linux

```

to

```auto
Disk /dev/mmcblk0: 7.29 GiB, 7822376960 bytes, 15278080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc5ed08c5

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 65536 98303 32768 16M c W95 FAT32 (LBA)
/dev/mmcblk0p2 98304 1097727 999424 488M 83 Linux
/dev/mmcblk0p3 1097728 2097151 999424 488M 83 Linux
/dev/mmcblk0p4 2097152 4194303 2097152 1G 83 Linux

```

As you can see, the starting point of the first partition is moved back.

Do you have any idea whats going wrong here? How to avoid conflicts between uboot-env and first partition?

---

_[View the full topic](https://hub.mender.io/t/mender-from-scratch/391)._
