Imx6ull NAND Flash

Hi ,

We are trying to integrate mender in our yocto project which involves imx6ull.
Please let us know what are Parameters need to be set in .conf file of the Yocto project to enable the build for NAND Flash.
We have checked the Document of the mender but we are not clear on how to integrate for NAND FLASH.

Thank you,
Deepanraj.A

Hello @deepanr welcome to Mender Hub. It’s likely going to require some experimentation on your part to enable Mender on the raw-flash system. The parameters needed are going to depend heavily on the specific hardware in use. The best place to start is here: https://docs.mender.io/2.2/devices/yocto-project/raw-flash.

You can also see Toradex Colibri iMX7 Dual 512MB / Colibri iMX7 Solo 256MB which is an existing i.MX7 port to a Toradex board using raw flash.

If you post specific issues and details of your hardware we may be able to guide you further.
Drew

Hi @drewmoseley

Actually i have not done any changes in Uboot. Please find my integration below

Partitions

MENDER_STORAGE_DEVICE = “/dev/mmcblk0”
MENDER_STORAGE_DEVICE_BASE = “/dev/mmcblk0p”
MENDER_STORAGE_TOTAL_SIZE_MB = “512”
MENDER_BOOT_PART_SIZE_MB = “0”
MENDER_DATA_PART_SIZE_MB = “10”
MENDER_ROOTFS_PART_A = “{MENDER_STORAGE_DEVICE_BASE}1" MENDER_ROOTFS_PART_B = "{MENDER_STORAGE_DEVICE_BASE}2”
MENDER_DATA_PART = “${MENDER_STORAGE_DEVICE_BASE}3”

For rootfs size

#IMAGE_ROOTFS_SIZE=“200000”

Environment

MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_1 = “0x2000”

Redundant environment

MENDER_UBOOT_ENV_STORAGE_DEVICE_OFFSET_2 = “0x4000”
BOOTENV_SIZE = “0x2000”

align to PEB size 128k

MENDER_PARTITION_ALIGNMENT ?= “128”

there is no partitioning overhead (no MBR and such)

MENDER_PARTITIONING_OVERHEAD ?= “0”

Account for UBI overhead, see

http://www.linux-mtd.infradead.org/doc/ubi.html#L_overhead for details,

MENDER_RESERVED_SPACE_BOOTLOADER_DATA ?= “20971520”
IMAGE_ROOTFS_MAXSIZE ?= “307200”

After which when bitbake command is given we get the below error

bb.data_smart.ExpansionError: Failure expanding variable MENDER_IS_ON_MTDID, expression was ${@mender_default_mender_mtdid(d)} which triggered exception BBHandledException:

So MENDER_IS_ON_MTDID is not set. with reference to https://docs.mender.io/2.2/devices/yocto-project/raw-flash

tried setting
MENDER_MTDIDS = “nand1=60000000.flash”
MENDER_IS_ON_MTDID = “60000000.flash”

After which we are getting the below error

ERROR: u-boot-imx-2018.03-r0 do_check_mender_defines: U-Boot configuration mx6ull_14x14_evk_optee_config has setting:
CONFIG_MTDIDS_DEFAULT=""
but Mender expects:
CONFIG_MTDIDS_DEFAULT=“nand0=60000000.flash”
Please fix U-Boot’s configuration file.

After adding these changes
MENDER_MTDIDS = “nand0=01806000.flash”
MENDER_IS_ON_MTDID = “01806000.flash”
MENDER_MTDPARTS = “gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0”

we are getting the below error

WARNING: Host distribution “ubuntu-18.04” has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |####################################################################################################################################################| Time: 0:00:00
Loaded 16 entries from dependency cache.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5-validation-imx.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5-validation-imx.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5-validation-imx.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5-validation-imx.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5-validation-imx.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
WARNING: /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5-validation-imx.bb: Could not find MENDER_IS_ON_MTDID (01806000.flash) in MENDER_MTDPARTS (gpmi-nand:10m(boot),8m(kernel),1m(dtb),-(rootfs)\0). Returning UBI size of zero.
ERROR: ExpansionError during parsing /home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/meta-fsl-bsp-release/imx/meta-sdk/dynamic-layers/qt5-layer/recipes-fsl/images/fsl-image-qt5-validation-imx.bb
Traceback (most recent call last):
File “/home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/poky/meta/classes/image.bbclass”, line 454, in _anon_519__home_keshavab_PROJECTS_OBD_Latest_Porting_mender_imx_yocto_bsp_sources_poky_meta_classes_image_bbclass(d=<bb.data_smart.DataSmart object at 0x7fa1c3f3f898>):
image_cmd = localdata.getVar(“IMAGE_CMD”)
> vardeps.add('IMAGE_CMD
’ + realt)
if image_cmd:
File “/home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/poky/bitbake/lib/bb/data_smart.py”, line 608, in DataSmart.getVar(var=‘IMAGE_CMD’, expand=True, noweakdefault=False, parsing=False):
def getVar(self, var, expand=True, noweakdefault=False, parsing=False):
> return self.getVarFlag(var, “_content”, expand, noweakdefault, parsing)

File “/home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/poky/bitbake/lib/bb/data_smart.py”, line 794, in DataSmart.getVarFlag(var=‘IMAGE_CMD’, flag=’_content’, expand=True, noweakdefault=False, parsing=False):
cachename = var + “[” + flag + “]”
> value = self.expand(value, cachename)

File “/home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/poky/bitbake/lib/bb/data_smart.py”, line 436, in DataSmart.expand(s=’ set -ex\n\n # We don’t actually use the result from this one, it’s only to trigger a\n # warning or error if the variable is not correctly set.\n mender_get_mtdparts\n\n ${@mender_make_mtdparts_shell_array(d)}\n\n local remaining_encountered=0\n local i=0\n while [ $i -lt $mtd_count ]; do\n eval local name="\"\$mtd_names_$i\""\n eval local size="\"\$mtd_sizes_$i\""\n eval local kbsize="\"\$mtd_kbsizes_$i\""\n eval local kboffset="\"\$mtd_kboffsets_$i\""\n\n if [ “name" = "u-boot" ]; then\n if [ -n "{MENDER_IMAGE_BOOTLOADER_FILE}” ]; then\n mender_flash_mtdpart “{DEPLOY_DIR_IMAGE}/{MENDER_IMAGE_BOOTLOADER_FILE}” $size $kbsize $kboffset $name\n else\n bbwarn “There is a ‘u-boot’ mtdpart, but MENDER_IMAGE_BOOTLOADER_FILE is undefined. Filling with zeros.”\n mender_flash_mtdpart “/dev/zero” $size $kbsize $kboffset $name\n fi\n elif [ “name" = "u-boot-env" ]; then\n mender_flash_mtdpart "{DEPLOY_DIR_IMAGE}/uboot.env” $size $kbsize $kboffset $name\n elif [ “name" = "ubi" ]; then\n mender_flash_mtdpart "{IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.ubimg” $size $kbsize $kboffset $name\n else\n bbwarn “Don’t know how to flash mtdparts ‘$name’. Filling with zeros.”\n mender_flash_mtdpart “/dev/zero” $size $kbsize $kboffset name\n fi\n\n i=(expr i + 1)\n done\n\n ln -sfn "{IMAGE_NAME}.mtdimg" “{IMGDEPLOYDIR}/{IMAGE_LINK_NAME}.mtdimg”\n’, varname=‘IMAGE_CMD’):
def expand(self, s, varname = None):
> return self.expandWithRefs(s, varname).value

File “/home/keshavab/PROJECTS/OBD/Latest_Porting/mender/imx-yocto-bsp/sources/poky/bitbake/lib/bb/data_smart.py”, line 426, in DataSmart.expandWithRefs(s=’ set -ex\n\n # We don’t actually use the result from this one, it’s only to trigger a\n # warning or error if the variable is not correctly set.\n mender_get_mtdparts\n\n ${@mender_make_mtdparts_shell_array(d)}\n\n local remaining_encountered=0\n local i=0\n while [ $i -lt $mtd_count ]; do\n eval local name="\"\$mtd_names_$i\""\n eval local size="\"\$mtd_sizes_$i\""\n eval local kbsize="\"\$mtd_kbsizes_$i\""\n eval local kboffset="\"\$mtd_kboffsets_$i\""\n\n if [ “name" = "u-boot" ]; then\n if [ -n "u-boot.imx" ]; then\n mender_flash_mtdpart "{TMPDIR}/deploy/images/imx6ull14x14evk/u-boot.imx” $size $kbsize $kboffset $name\n else\n bbwarn “There is a ‘u-boot’ mtdpart, but MENDER_IMAGE_BOOTLOADER_FILE is undefined. Filling with zeros.”\n mender_flash_mtdpart “/dev/zero” $size $kbsize $kboffset $name\n fi\n elif [ “name" = "u-boot-env" ]; then\n mender_flash_mtdpart "{TMPDIR}/deploy/images/imx6ull14x14evk/uboot.env” $size $kbsize $kboffset $name\n elif [ “name" = "ubi" ]; then\n mender_flash_mtdpart "{TMPDIR}/work/imx6ull14x14evk-poky-linux-gnueabi/fsl-image-qt5-validation-imx/1.0-r0/deploy-fsl-image-qt5-validation-imx-image-complete/fsl-image-qt5-validation-imx-imx6ull14x14evk.ubimg” $size $kbsize $kboffset $name\n else\n bbwarn “Don’t know how to flash mtdparts ‘$name’. Filling with zeros.”\n mender_flash_mtdpart “/dev/zero” $size $kbsize $kboffset name\n fi\n\n i=(expr i + 1)\n done\n\n ln -sfn "fsl-image-qt5-validation-imx-imx6ull14x14evk-{DATETIME}.mtdimg" “${TMPDIR}/work/imx6ull14x14evk-poky-linux-gnueabi/fsl-image-qt5-validation-imx/1.0-r0/deploy-fsl-image-qt5-validation-imx-image-complete/fsl-image-qt5-validation-imx-imx6ull14x14evk.mtdimg”\n’, varname=‘IMAGE_CMD’):
except Exception as exc:
> raise ExpansionError(varname, s, exc) from exc

bb.data_smart.ExpansionError: Failure expanding variable IMAGE_CMD, expression was set -ex

# We don't actually use the result from this one, it's only to trigger a
# warning or error if the variable is not correctly set.
mender_get_mtdparts

${@mender_make_mtdparts_shell_array(d)}

local remaining_encountered=0
local i=0
while [ $i -lt $mtd_count ]; do
    eval local name="\"\$mtd_names_$i\""
    eval local size="\"\$mtd_sizes_$i\""
    eval local kbsize="\"\$mtd_kbsizes_$i\""
    eval local kboffset="\"\$mtd_kboffsets_$i\""

    if [ "$name" = "u-boot" ]; then
        if [ -n "u-boot.imx" ]; then
            mender_flash_mtdpart "${TMPDIR}/deploy/images/imx6ull14x14evk/u-boot.imx" $size $kbsize $kboffset $name
        else
            bbwarn "There is a 'u-boot' mtdpart, but MENDER_IMAGE_BOOTLOADER_FILE is undefined. Filling with zeros."
            mender_flash_mtdpart "/dev/zero" $size $kbsize $kboffset $name
        fi
    elif [ "$name" = "u-boot-env" ]; then
        mender_flash_mtdpart "${TMPDIR}/deploy/images/imx6ull14x14evk/uboot.env" $size $kbsize $kboffset $name
    elif [ "$name" = "ubi" ]; then
        mender_flash_mtdpart "${TMPDIR}/work/imx6ull14x14evk-poky-linux-gnueabi/fsl-image-qt5-validation-imx/1.0-r0/deploy-fsl-image-qt5-validation-imx-image-complete/fsl-image-qt5-validation-imx-imx6ull14x14evk.ubimg" $size $kbsize $kboffset $name
    else
        bbwarn "Don't know how to flash mtdparts '$name'. Filling with zeros."
        mender_flash_mtdpart "/dev/zero" $size $kbsize $kboffset $name
    fi

    i=$(expr $i + 1)
done

ln -sfn "fsl-image-qt5-validation-imx-imx6ull14x14evk-${DATETIME}.mtdimg" "${TMPDIR}/work/imx6ull14x14evk-poky-linux-gnueabi/fsl-image-qt5-validation-imx/1.0-r0/deploy-fsl-image-qt5-validation-imx-image-complete/fsl-image-qt5-validation-imx-imx6ull14x14evk.mtdimg"

which triggered exception TypeError: not all arguments converted during string formatting

Please help us resolve this as we are new to mender.

Thanks
Deepanraj

Well, it’s difficult to troubleshoot exactly but I did see a few things:

  1. MENDER_PARTITION_ALIGNMENT needs to be specified in bytes not kb so you likely need that set to 131072.
  2. MENDER_STORAGE_DEVICE should not be set to /dev/mmc* as that is for SD/MMC and not raw flash. For the Toradex colibri board it is set to “ubi0”.
  3. Similar for MENDER_STORAGE_DEVICE_BASE.
  4. I’m not sure about the UBoot offsets; that’s going to be hardware dependent but on Toradex it is 0x380000. You will need to figure out what your board expects for that.
  5. MENDER_MTDPARTS looks incorrect to me. For Toradex it is “gpmi-nand:512k(mx7-bcb),1536k(u-boot1)ro,1536k(u-boot2)ro,512k(u-boot-env),-(ubi)”. Note that the u-boot images and environment are specified as UBI volumes here. Also, there is no need to have a separate kernel and dtb volume as the Mender boot logic expects those as files in the root filesystem so they can be provided as part of the update.

@kacf do you have any other feedback?

Drew

The only variables that should be set is MENDER_MTDPARTS and MENDER_MTDIDS. Everything else should be automatically set, unless you have some unexpected page sizes or anything like that.

Try setting MENDER_MTDPARTS to:

01806000.flash:512k(mx7-bcb),1536k(u-boot1)ro,1536k(u-boot2)ro,512k(u-boot-env),-(ubi)

The Mender code currently does not handle non-address prefixes in the mtdparts string.

The Mender mtdimg generator unfortunately does not handle u-boot1 and u-boot2 entries, only u-boot entries (so one singular U-Boot bootloader entry, not redundant entries), but this could be fixed relatively easily by duplicating the logic of the existing flashing code, especially since this is a quite common pattern. Pull requests welcome!

Hi ,

Please let me know how we can flash the binary into NAND of our device. the image which i have got after compilation is .ubimg and .ubifs.

What are the commands to flash the device. Also please let us know do we need to flash U-boot in raw or just flashing the .ubimg is enough

Thank you,
Deepanraj.A

It’s likely going to be board dependent so you are better off checking with the board vendor. But the instructions for the Toradex board may be helpful as well if your U-Boot has a similar configuration.

Drew