# Colibri IMX6ULL

**URL:** <https://hub.mender.io/t/colibri-imx6ull/2911>\
**Category:** General Discussions\
**Tags:** nxp, dunfell, colibri-imx6ull, toradex\
**Created:** [November 30, 2020, 10:48pm UTC](https://hub.mender.io/t/colibri-imx6ull/2911 "2020-11-30T22:48:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsanchez](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rsanchez](https://hub.mender.io/u/rsanchez)\
**Post date:** [November 30, 2020, 10:48pm UTC](https://hub.mender.io/t/colibri-imx6ull/2911/1 "2020-11-30T22:48:14Z")

</div>

Hi,  
Im trying to integrate mender on a Toradex Colibri-imx6ull module. I’m using the repos for yocto 3.1 (dunfell) provided by toradex and the dunfell mender branch.

I based slightly based my port on the existing colibri imx7 module (meta-mender-community) but instead of keeping the environment on raw NAND I opted for the option to save it on UBI volumes.

Toradex provides a fork of u-boot (u-boot-toradex) so I followed the manual integration steps described in mender’s docs.

**TLDR; The problem**  
After building everything and flashing it, my system boots only the first time. Once the kernel mounts the rootfs from the ubi volume it spits lots of UBI ECC errors and it kind of corrupts the volume.  
After this, rebooting the board causes u-boot to not be capable of mounting the ubi partition anymore.

Any idea about what I could be doing wrong??

My configuration is as follows:

**Local.conf:**

```auto
MENDER_MTDIDS = "nand0=gpmi-nand"
MENDER_MTDPARTS = "gpmi-nand:512k(mx6ull-bcb),1536k(u-boot1)ro,1536k(u-boot2)ro,512k(u-boot-env),-(ubi)"
MENDER_IMAGE_BOOTLOADER_FILE = "u-boot-nand.imx"
MENDER_ARTIFACT_NAME = "xpac-mender"
MENDER_STORAGE_TOTAL_SIZE_MB = "512"
MENDER_DATA_PART_SIZE_MB = "16"
MENDER_STORAGE_PEB_SIZE="131072"
MENDER_RESERVED_SPACE_BOOTLOADER_DATA="0x40000"

```

**u-boot-toradex\_2020.07.bbappend**

```auto
RPROVIDES_${PN}_mender-uboot += "u-boot"
MENDER_UBOOT_AUTO_CONFIGURE = "0"
FILESEXTRAPATHS_prepend_mender-uboot := "${THISDIR}/files:"
MENDER_UBOOT_PRE_SETUP_COMMANDS_mender-uboot_colibri-imx6ull = "setenv fdtfile ${KERNEL_DEVICETREE}"
require recipes-bsp/u-boot/u-boot-mender.inc
SRC_URI_remove_mender-uboot = " \
    file://0003-Integration-of-Mender-boot-code-into-U-Boot.patch \
"
SRC_URI_append_mender-uboot = " \
    file://0001-integrate-mender-into-toradex-uboot.patch \
"
SRC_URI_append_mender-uboot_colibri-imx6ull = " \
	file://0001-colibri-imx6ull-mender-manual-U-boot-integration.patch \
"
BOOTENV_SIZE = "0x20000"

```

**U-boot patch: 0001-colibri-imx6ull-mender-manual-U-boot-integration.patch**  
Relevant parts of the patch:

```auto
--- git.orig/configs/colibri-imx6ull_defconfig
+++ git/configs/colibri-imx6ull_defconfig
-CONFIG_ENV_IS_IN_NAND=y
+CONFIG_ENV_IS_IN_UBI=y
+#CONFIG_MTD_UBI=y
+#CONFIG_MTD_PARTITIONS=y
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+CONFIG_ENV_UBI_PART="ubi"
+CONFIG_ENV_UBI_VOLUME="u-boot-env-1"
+CONFIG_ENV_UBI_VOLUME_REDUND="u-boot-env-2"
+CONFIG_CMD_UBIFS=y

```

**mender\_Kconfig\_fragment: Generated by mender on the u-boot build dir**

```auto
CONFIG_ENV_SIZE=0x20000
CONFIG_MTDIDS_DEFAULT="nand0=gpmi-nand"
CONFIG_MTDPARTS_DEFAULT="mtdparts=gpmi-nand:512k(mx6ull-bcb),1536k(u-boot1)ro,1536k(u-boot2)ro,512k(u-boot-env),-(ubi)"
CONFIG_ENV_UBI_PART="ubi"
CONFIG_ENV_UBI_VOLUME="u-boot-env-1"
CONFIG_ENV_UBI_VOLUME_REDUND="u-boot-env-2"
CONFIG_ENV_OFFSET=0x0
CONFIG_ENV_OFFSET_REDUND=0x0

```

**Flashing procedure**  
The command **bitbake tdx-reference-minimal-image** just works: builds and installs mender client in the rootfs, applies patches to uboot, generates the ubimg file, etc

I flash the genrated files using the following commands from already working u-boot on the board:

```auto
nand erase.part u-boot1
nand erase.part u-boot2
load mmc 0:1 ${loadaddr} u-boot-nand.imx
nand write ${loadaddr} u-boot1 ${filesize}
nand write ${loadaddr} u-boot2 ${filesize}
nand erase.part u-boot-env
nand erase.part ubi
load mmc 0:1 ${loadaddr} Colibri-iMX6ULL_Reference-Minimal-Image.ubimg
nand write ${loadaddr} ubi ${filesize}
reset

```

**The problem**  
After flashing, once I reset the board, the following things happen:

1. U-boot detects the empty env. and saves the default one on the ubi volume (i added some printfs and 100% sure is saving on u-boot-env-1 and u-boot-env-2)
2. U-boot loads the kernel + dtb file from the rootfsA partition and boots it
3. Linux boots, rootfs is mounted
4. Once linux mounts the rootfs It starts printing UBI ECC errors like this:

```auto
[6.991319] ubi0 error: ubi_io_read: error -74 (ECC error) while reading 69 bytes from PEB 546:91120, read 69 bytes
[7.079145] ubi0 error: ubi_io_read: error -74 (ECC error) while reading 67 bytes from PEB 546:92624, read 67 bytes
<omitted systemd messages here....>
[15.013194] ubi0 error: ubi_io_read: error -74 (ECC error) while reading 72 bytes from PEB 546:100816, read 72 bytes
[15.360800] ubi0 error: ubi_io_read: error -74 (ECC error) while reading 74 bytes from PEB 546:104048, read 74 bytes
<omitted systemd messages here....>
[16.153057] ubi0 error: ubi_io_read: error -74 (ECC error) while reading 32 bytes from PEB 546:108512, read 32 byte

```

1. It finally boots, I get a loging prompt, I can use some commands , etc, but it still keeps printing ECC errors periodically.
2. After rebooting, u-boot is no longer capable of recognizing the ubi partition anymore:

```auto
Booting from NAND...
ubi0 error: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096, read 126976 bytes
ubi0 error: ubi_attach_fastmap: PEB 3 is in EBA but not in used list
ubi0 error: ubi_scan_fastmap: Attach by fastmap failed, doing a full scan!
ubi0 error: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096, read 126976 bytes
UBIFS error (ubi0:0 pid 0): ubifs_scan: bad node
ubi0 error: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096, read 126976 bytes
ubi0 error: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 4:4096, read 126976 bytes
ubi0 error: ubi_io_read: error -74 (ECC error) while reading 11 bytes from PEB 10:8192, read 11 bytes
UBIFS error (ubi0:0 pid 0): ubifs_leb_read: reading 11 bytes from LEB 8:4096 failed, error -74
Error reading superblock on volume 'ubi0:rootfsa' errno=-74!
ubifsmount - mount UBIFS volume

```

---

<div class="post-metadata">

**Author:** ![thofu](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/thofu/32/914_2.png) [@thofu](https://hub.mender.io/u/thofu)\
**Post date:** [December 1, 2020, 5:13am UTC](https://hub.mender.io/t/colibri-imx6ull/2911/2 "2020-12-01T05:13:51Z")

</div>

Hi.  
I had the same problem and answered in the following thread: [Ubifs ECC errors after adding Mender to Toradex iMX6ULL Image](https://hub.mender.io/t/ubifs-ecc-errors-after-adding-mender-to-toradex-imx6ull-image/1767/5).

In short: Try `nand write.trimffs` instead of `nand write` to flash the device.

---

<div class="post-metadata">

**Author:** ![rsanchez](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rsanchez](https://hub.mender.io/u/rsanchez)\
**Post date:** [December 1, 2020, 8:12am UTC](https://hub.mender.io/t/colibri-imx6ull/2911/3 "2020-12-01T08:12:39Z")

</div>

YES! It worked! That was the issue. Thanks!

My plan is now to commit my changes to meta-mender-community so I will somehow add this very useful info to the Readme.

---

<div class="post-metadata">

**Author:** ![mrpelotazo](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mrpelotazo](https://hub.mender.io/u/mrpelotazo)\
**Post date:** [December 4, 2020, 1:00pm UTC](https://hub.mender.io/t/colibri-imx6ull/2911/4 "2020-12-04T13:00:42Z")

</div>

### If using Toradex Easy Installer

I had the same issue when installing the generated (tezi) image with the Toradex Easy Installer.  
Based on what is explained [here](http://linux-mtd.infradead.org/faq/ubifs.html#L_why_ubiformat) I appended **–space-fixup** to **MKUBIFS\_ARGS** in **local.conf** which solves the problem.

```auto
# Enable free --space-fixup (-F)
MKUBIFS_ARGS_colibri-imx6ull = "-m ${MENDER_FLASH_MINIMUM_IO_UNIT} -e ${MENDER_UBI_LEB_SIZE} -c ${MENDER_MAXIMUM_LEB_COUNT} --space-fixup"

```

This is done in `meta-freescale-3rdparty/conf/machine/colibri-imx7-nand.conf` as well.

I guess it would also work for `nand write` (without trimffs) in u-boot, I didn’t test it though.

---

<div class="post-metadata">

**Author:** ![rsanchez](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rsanchez](https://hub.mender.io/u/rsanchez)\
**Post date:** [December 6, 2020, 6:30pm UTC](https://hub.mender.io/t/colibri-imx6ull/2911/5 "2020-12-06T18:30:28Z")

</div>

Will test this approach as well. Would be great to be capable of using teezi out of the box.

Im going to prepare a pull request for the meta-mender-comunity repo, so might be we all benefit of a common solution 🙂

---

<div class="post-metadata">

**Author:** ![rsanchez](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rsanchez](https://hub.mender.io/u/rsanchez)\
**Post date:** [December 7, 2020, 1:31pm UTC](https://hub.mender.io/t/colibri-imx6ull/2911/6 "2020-12-07T13:31:31Z")

</div>

I can confirm adding --space-fixup to the MKUBIFS variable works fine when using “nand write”

---

<div class="post-metadata">

**Author:** ![rsanchez](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@rsanchez](https://hub.mender.io/u/rsanchez)\
**Post date:** [December 7, 2020, 3:20pm UTC](https://hub.mender.io/t/colibri-imx6ull/2911/7 "2020-12-07T15:20:41Z")

</div>

I’ve submitted a PR: [https://github.com/mendersoftware/meta-mender-community/pull/205](https://github.com/mendersoftware/meta-mender-community/pull/205)  
Probably would require some clean-up but I think is enough as a start point 🙂
