# U-boot integration fails on custom i.MX35 board

**URL:** https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199
**Category:** General Discussions
**Tags:** nxp, thud, imx35
**Created:** [July 17, 2020, 11:38am UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199 "2020-07-17T11:38:41Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![lukip](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lukip](https://hub.mender.io/u/lukip)
#### Post date: [July 17, 2020, 11:38am UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/1 "2020-07-17T11:38:41Z")

</div>

Hi everyone!

I’m trying to integrate Mender to a custom board, but without success.  
This is the output of bitbake:

> | DEBUG: Executing shell function do\_provide\_mender\_defines  
> | + echo u-boot-imx  
> | + fgrep mender-auto-provided  
> | + true  
> | + expr 1048576 % ( 524288 \* 2 )  
> | + [0 -ne 0]  
> | + [1048576 -gt 1048576]  
> \< | + [-n]  
> | + false  
> | + get\_part\_number\_from\_device /dev/ubi0\_0  
> | + dev\_base=unknown  
> | + printf %d unknown  
> | + part=0  
> | + MENDER\_ROOTFS\_PART\_A\_NUMBER=  
> | + bb\_exit\_handler  
> | + ret=1  
> | + echo WARNING: exit code 1 from a shell command.  
> | WARNING: exit code 1 from a shell command.  
> | + exit 1

It seems some variables are missing or wrong, but I have no idea which one.  
These are the variables I defined. I’m not sure on whether I did all of these correctly as there is little information on the internet about raw flash support; I used this[colibri-imx7](https://github.com/mendersoftware/meta-mender/blob/rocko/meta-mender-toradex-nxp/conf/machine/colibri-imx7-mender.conf) as a template.

> ARTIFACTIMG\_FSTYPE = “ubi”  
> MENDER\_BOOT\_PART\_SIZE\_MB ?= “3”  
> MENDER\_DATA\_PART\_SIZE\_MB ?= “200”  
> MENDER\_IMAGE\_BOOTLOADER\_FILE = “uboot-atk-myimage.bin”  
> MENDER\_MTDIDS ?= “nand0=mxc\_nand”  
> MENDER\_MTDPARTS ?= “mxc\_nand:512k(SBL1),512k(SBL2),1m(u-boot),1m(u-boot-env),-(ubi),2m(bbt)”  
> MENDER\_NAND\_FLASH\_PAGE\_SIZE ?= “4096”  
> MENDER\_PARTITIONING\_OVERHEAD\_KB ?= “0”  
> MENDER\_PARTITION\_ALIGNMENT ?= “524288”  
> MENDER\_STORAGE\_DEVICE ?= “/dev/ubi0”  
> MENDER\_STORAGE\_TOTAL\_SIZE\_MB ?= “2048”  
> MENDER\_UBOOT\_ENV\_STORAGE\_DEVICE\_OFFSET ?= “0x200000”  
> MENDER\_UBOOT\_STORAGE\_DEVICE ?= “0”  
> MENDER\_UBOOT\_STORAGE\_INTERFACE ?= “ubi”  
> BOOTENV\_SIZE ?= “0x40000”  
> BOOTENV\_RANGE ?= “0x80000”  
> IMAGE\_FSTYPES += “ubi”

Some additional information:  
The Yocto version is thud, Mender version 2.2 (as I think this is the default for the thud branch)

It shoud also be noted that a fork of u-boot v15.10 with custom patches to support the processor is used. As the mender patches did not apply to this rather old version of u-boot, I manually applied them.

Maybe someone has a clue what I’m missing? I’d really appreciate some help!

---

<div class="post-metadata">

### Author: ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)
#### Post date: [July 20, 2020, 6:17am UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/2 "2020-07-20T06:17:55Z")

</div>

Did you also use this?

```auto
INHERIT += "mender-full-ubi"

```

---

<div class="post-metadata">

### Author: ![lukip](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lukip](https://hub.mender.io/u/lukip)
#### Post date: [July 20, 2020, 10:49am UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/3 "2020-07-20T10:49:58Z")

</div>

Yes, I included it in my local.conf. Sorry I forgot to mention this.

---

<div class="post-metadata">

### Author: ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)
#### Post date: [July 20, 2020, 6:36pm UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/4 "2020-07-20T18:36:21Z")

</div>

It’s hard to say. Does the bitbake log have any more details? What about the log.do\_provide\_mender\_defines file in your tmp/work/ folder?

Drew

---

<div class="post-metadata">

### Author: ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)
#### Post date: [July 21, 2020, 6:25am UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/5 "2020-07-21T06:25:20Z")

</div>

Can you try to set `MENDER_STORAGE_DEVICE` to `ubi0` instead of `/dev/ubi0`?

---

<div class="post-metadata">

### Author: ![lukip](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lukip](https://hub.mender.io/u/lukip)
#### Post date: [July 22, 2020, 7:35am UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/6 "2020-07-22T07:35:09Z")

</div>

That indeed omits the error I previously had, thank you very much!!🙂  
I’ll report if I encounter any other errors I can’t solve by myself.

---

<div class="post-metadata">

### Author: ![lukip](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lukip](https://hub.mender.io/u/lukip)
#### Post date: [August 6, 2020, 8:53am UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/7 "2020-08-06T08:53:46Z")

</div>

Hello again,

everything builds successfully, but I am still facing problems.

I flash the .ubimg file via nand erase.part and nand write.e, loading the .ubimg file from an SD-card.

However, I am not able to ubifsmount the rootfs afterwards, getting the following error:

> =\> ubi part ubi  
> UBI: attaching mtd1 to ubi0  
> UBI: scanning is finished  
> UBI: attached mtd1 (name “mtd=4”, size 2043 MiB) to ubi0  
> UBI: PEB size: 524288 bytes (512 KiB), LEB size: 520192 bytes  
> UBI: min./max. I/O unit sizes: 4096/4096, sub-page size 1024  
> UBI: VID header offset: 1024 (aligned 1024), data offset: 4096  
> UBI: good PEBs: 4084, bad PEBs: 2, corrupted PEBs: 0  
> UBI: user volume: 5, internal volumes: 1, max. volumes count: 128  
> UBI: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 364630146  
> UBI: available PEBs: 2340, total reserved PEBs: 1744, PEBs reserved for bad PEB handling: 78  
> =\> ubifsmount ubi0:rootfsa  
> Error reading superblock on volume ‘ubi0:rootfsa’ errno=-12!

Before integrating mender, this worked perfectly, and strangely enough, it also works when using an unpatched (meaning no mender stuff) version of u-boot with an .ubimg file generated including mender. So it seems the .ubimg file is ok, but u-boot got somehow broken after introducing mender.  
Has someone encountered the same problem or has an idea what the reason might be?

It should be also noted that I at first I got this warning when building u-boot including mender:

> o\_provide\_mender\_defines: Detected U-Boot without support for direct read/write to UBI volumes. Mender normally expects this unless you have a custom setup. Consider backporting the patch at [tools: env: Add support for direct read/write UBI volumes (34255b92) · Commits · U-Boot / U-Boot · GitLab](http://git.denx.de/?p=u-boot.git;a=commitdiff;h=34255b92e6e68941ab1134299faa86acc5a1abc8) to your U-Boot sources.

I applied the suggested patch (manually), the warning disappeared, but no change in behaviour of ubifsmount.

I’d again really appreciate some help!

---

<div class="post-metadata">

### Author: ![lukip](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lukip](https://hub.mender.io/u/lukip)
#### Post date: [August 6, 2020, 10:42am UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/8 "2020-08-06T10:42:45Z")

</div>

Never mind, I found out the problem myself. I accidentally reduced the size of CONFIG\_SYS\_MALLOC\_LEN; after changing it to the original size I am finally able to boot!

---

<div class="post-metadata">

### Author: ![lukip](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lukip](https://hub.mender.io/u/lukip)
#### Post date: [August 6, 2020, 12:11pm UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/9 "2020-08-06T12:11:55Z")

</div>

I still have one problem though regarding the u-boot environment:  
It is directly in NAND where the mtd device u-boot-env lays, see the layout:

> mxc\_nand:512k(SBL1),512k(SBL2),1m(u-boot),1m(u-boot-env),2043m(ubi),2m(bbt)

But Mender thinks it’s in a ubi volume and therefore creates two volumes `u-boot-env-1` and `u-boot-env-2` in the resulting .ubimg file which I don’t need. Even worse, it overrides the custom `fw_env.config` file that I deploy in my custom u-boot-fw-utils recipe. See here the recipe:

> SUMMARY = “U-Boot bootloader fw\_printenv/setenv utilities”  
> require u-boot-common-imx.inc  
> require recipes-bsp/u-boot/u-boot-fw-utils-mender.inc
> 
> SRC\_URI += " file://fw\_env.config   
> "
> 
> INSANE\_SKIP\_${PN} = “already-stripped”  
> EXTRA\_OEMAKE\_class-target = ‘CROSS\_COMPILE=${TARGET\_PREFIX} CC=“${CC} ${CFLAGS} ${LDFLAGS}” HOSTCC=“${BUILD\_CC} ${BUILD\_CFLAGS} ${BUILD\_LDFLAGS}” V=1’  
> EXTRA\_OEMAKE\_class-cross = ‘ARCH=${TARGET\_ARCH} CC=“${CC} ${CFLAGS} ${LDFLAGS} HOSTCC=”${BUILD\_CC} ${BUILD\_CFLAGS} ${BUILD\_LDFLAGS}" V=1’
> 
> inherit uboot-config
> 
> do\_compile () {  
> oe\_runmake ${UBOOT\_MACHINE}  
> oe\_runmake env  
> }
> 
> do\_install () {  
> install -d ${D}${base\_sbindir}  
> install -d ${D}${sysconfdir}  
> install -m 755 ${S}/tools/env/fw\_printenv ${D}${base\_sbindir}/fw\_printenv  
> install -m 755 ${S}/tools/env/fw\_printenv ${D}${base\_sbindir}/fw\_setenv  
> install -m 0644 ${WORKDIR}/fw\_env.config ${D}${sysconfdir}/fw\_env.config  
> }
> 
> do\_install\_class-cross () {  
> install -d ${D}${bindir\_cross}  
> install -m 755 ${S}/tools/env/fw\_printenv ${D}${bindir\_cross}/fw\_printenv  
> install -m 755 ${S}/tools/env/fw\_printenv ${D}${bindir\_cross}/fw\_setenv  
> install -m 0644 ${WORKDIR}/fw\_env.config ${D}${sysconfdir}/fw\_env.config  
> }
> 
> SYSROOT\_PREPROCESS\_FUNCS\_class-cross = “uboot\_fw\_utils\_cross”  
> uboot\_fw\_utils\_cross() {  
> sysroot\_stage\_dir ${D}${bindir\_cross} ${SYSROOT\_DESTDIR}${bindir\_cross}  
> }
> 
> PACKAGE\_ARCH = “${MACHINE\_ARCH}”  
> BBCLASSEXTEND = “cross”
> 
> PROVIDES\_${PN} = “u-boot-fw-utils”  
> RPROVIDES\_${PN} = “u-boot-fw-utils”

How can I tell Mender not to take care of where the u-boot environment is stored, since I do this myself?

---

<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: [August 6, 2020, 12:48pm UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/10 "2020-08-06T12:48:23Z")

</div>

Not sure, there is a way to override this. The UBI volumes are created here,

> <https://github.com/mendersoftware/meta-mender/blob/thud/meta-mender-core/classes/mender-ubimg.bbclass#L83-L101>

So the only way would be to disable `mender-uboot` DISTRO\_FEATURE, but then you have to manually do everything that implies.

You can also create a customer image derived from [https://github.com/mendersoftware/meta-mender/blob/thud/meta-mender-core/classes/mender-ubimg.bbclass#L83-L101](https://github.com/mendersoftware/meta-mender/blob/thud/meta-mender-core/classes/mender-ubimg.bbclass#L83-L101).

Regarding the `fw_env.config`, you need to make sure this is not included in your environment,

> <https://github.com/mendersoftware/meta-mender/blob/thud/meta-mender-core/recipes-bsp/u-boot/u-boot-fw-utils-mender.inc>

---

<div class="post-metadata">

### Author: ![lukip](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lukip](https://hub.mender.io/u/lukip)
#### Post date: [August 6, 2020, 1:04pm UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/11 "2020-08-06T13:04:22Z")

</div>

Thank you for the quick response!

Thanks to your hint I found out it is enough to just rename my custom `fw_env.config` to `fw_env.config.default`, so Mender won’t create its own config file.

I was afraid there may be no easy way to override the UBI env volumes, but since they don’t do any harm (I hope?) I will leave them as is for now.

---

<div class="post-metadata">

### Author: ![lukip](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lukip](https://hub.mender.io/u/lukip)
#### Post date: [August 6, 2020, 3:32pm UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/12 "2020-08-06T15:32:08Z")

</div>

Sorry for bothering again, my original problem seems not to have been resolved. If I set

> MENDER\_STORAGE\_DEVICE = “ubi0”

then everything compiles and bootes fine, but when I run `mender` from the command line, there is following error:

> WARN[0000] Could not resolve path link: ubi0\_0 Attempting to continue module=partitions  
> WARN[0000] Could not resolve path link: ubi0\_1 Attempting to continue module=partitions

This is no wonder, as I can see in the auto-generated `mender.conf` that the paths are wrong:

> {  
> “InventoryPollIntervalSeconds”: 1800,  
> “RetryPollIntervalSeconds”: 300,  
> “RootfsPartA”: “ubi0\_0”,  
> “RootfsPartB”: “ubi0\_1”,  
> “ServerURL”: “[https://docker.mender.io](https://docker.mender.io)”,  
> “TenantToken”: “dummy”,  
> “UpdatePollIntervalSeconds”: 1800  
> }

changing from `ubi0_0` to `/dev/ubi0_0` omits this error, but then `mender -rootfs` will not work.

If I otherwise set

> MENDER\_STORAGE\_DEVICE = “/dev/ubi0”

I get the error described in my first post.

How can I correctly set different paths to the UBI volume for Linux and U-boot respectively ?  
Searching through the docs made me think adding

> MENDER\_UBOOT\_STORAGE\_DEVICE = “0”  
> MENDER\_UBOOT\_STORAGE\_INTERFACE = “ubi”

would do the trick, but there is no difference.

Do you have any advice ?

---

<div class="post-metadata">

### Author: ![lukip](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lukip](https://hub.mender.io/u/lukip)
#### Post date: [August 7, 2020, 11:18am UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/13 "2020-08-07T11:18:16Z")

</div>

It turned out the warning can safely be ignored, as described here [[MEN-3412] - Mender and CFEngine (by Northern.tech) Jira](https://tracker.mender.io/browse/MEN-3412?page=com.apanasevich.jira-jigit-plugin%3Ajigit-tab-panel)

The reason `mender -rootfs` did not work was that I had set

> ARTIFACTIMG\_FSTYPE = “ubi”

instead of

> ARTIFACTIMG\_FSTYPE = “ubifs”

Now everyhing works fine, thanks for the kind support!

---

<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: [August 7, 2020, 11:51am UTC](https://hub.mender.io/t/u-boot-integration-fails-on-custom-i-mx35-board/2199/14 "2020-08-07T11:51:37Z")

</div>

Thanks for reporting back, and glad it worked out for you!
