NXP imx8mm evk don't boot

Hi All,

I am trying to integrate meta-mender into a imx8mm (sumo branch) Yocto project for the NXP IMX8MM EVK and I encounter some issues.

Here are my steps I made:

repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-sumo -m imx-4.9.123-2.3.0-8mm_ga.xml
DISTRO=fsl-imx-xwayland MACHINE=imx8mmevk source fsl-setup-release.sh -b build
bitbake fsl-image-machine-test

This generated a working sdcard image. Then I follow the Mender board integration documentation and include meta-mender into my Yocto project:

git clone -b sumo git://github.com/mendersoftware/meta-mender

IMX use u-boot-imx so I made the modification to support a fork of u-boot:
Modify u-boot-imx_2018.03.bb to include

  • require recipes-bsp/u-boot/u-boot-mender.inc
  • PROVIDES += “u-boot”
  • RPROVIDES_${PN} += “u-boot”
    I checked that u-boot-imx default config for imx8mm has;
  • CONFIG_BOOTCOUNT_LIMIT=y
  • CONFIG_BOOTCOUNT_ENV=y

Below my final local.conf:
MENDER_FEATURES_ENABLE_append = "mender-uboot mender-image-sd "
MENDER_FEATURES_DISABLE_append = "mender-grub mender-image-uefi "
MENDER_STORAGE_DEVICE = “/dev/mmcblk1”
MENDER_STORAGE_TOTAL_SIZE_MB = “15193” (value returned by the blockdev command for a 16Gb sdcard)
MENDER_UBOOT_STORAGE_DEVICE = “0”
MENDER_ARTIFACT_NAME = “release-1”
INHERIT += "mender-full "
ARTIFACTIMG_FSTYPE = “ext4”
PREFERRED_PROVIDER_u-boot = “u-boot-imx”
IMAGE_BOOT_FILES ?= “u-boot.bin”
IMAGE_FSTYPES_remove += “sdcard.bz2” (To disable sdcard image generation)

This configuration compile fine and generate a sdimg file. I “dd” the sdimg to sdcard, everything seems ok; 4 partitions, 2 rootfs with a boot directory containing the kernel, a boot partition with u-boot and a data partition. But the EVK doesn’t not boot. Nothing on the serial terminal.

I suspect the bootloader is not well generated because imx needs a two level bootloader with a SPL and u-boot + some binaries.
I found in https://groups.google.com/a/lists.mender.io/forum/#!msg/mender/hyHk9a6C4K8/Qb3JoB9NBgAJ that a solution can be to generate a blob with u-boot, the SPL and all necessary binaries and to integrate it into the sdimg with MENDER_IMAGE_BOOTLOADER_FILE = “${MENDER_BOOTLOADER_BLOB}”. But I don’t know how to do it.

Anyone can help me?

Thanks

Regards,

Jean

Hi @jean,

First of all welcome to Mender Hub.

Second, we recently publish a reference integration for the imx8mqevk board,

and there is also an demo manifest file in the i.MX BSP,

https://source.codeaurora.org/external/imx/imx-manifest/tree/README-mender?h=imx-linux-sumo

But to get to the bootloader configuration, for the imx8mqevk board we did the following,

And I suspect it would be something similar on the imx8mmevk

Hello Mirzak

Thank for your quick reply and useful information.

So I tried to use the demo manifest file in the IMX BSP but I still encounter some issues.

here are my steps:

Then I adapt 0001-Add-Mender-support.patch, 0002-Improve-boot-startup-time.patch and meta-mender-imx/templates/local.conf to support IMX8MM instead of MX8MQ.

Here is my final local.conf:

INHERIT += "rm_work"
MENDER_ARTIFACT_NAME = "release-1"
INHERIT += "mender-full"
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
VIRTUAL-RUNTIME_initscripts = ""
MENDER_FEATURES_DISABLE_append = " mender-grub mender-image-uefi"
MENDER_FEATURES_ENABLE_append = " mender-uboot mender-image-sd"
PREFERRED_PROVIDER_u-boot = "u-boot-imx"
IMAGE_FSTYPES_remove = "tar.bz2 ext4 sdcard.bz2"
IMAGE_BOOT_FILES_append = "u-boot-imx8mmevk.bin"
MENDER_IMAGE_BOOTLOADER_FILE = "imx-boot-imx8mmevk-sd.bin"
MENDER_IMAGE_BOOTLOADER_BOOTSECTOR_OFFSET = "66"
do_image_sdimg[depends] += "imx-boot:do_deploy"
IMAGE_INSTALL_append = " kernel-image kernel-devicetree"
MENDER_STORAGE_DEVICE_imx8mmevk = "/dev/mmcblk1"

Compilation of u-boot-imx-2018.03 fails with this error:

bitbake core-image-base

aarch64-poky-linux-gcc  --sysroot=/home/lserbetot/Developpement/imx-mender/build_imx8mm_mender/tmp/work/aarch64-poky-linux/u-boot-fw-utils-mender-auto-provided/1.0-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/lserbetot/Developpement/imx-mender/build_imx8mm_mender/tmp/work/aarch64-poky-linux/u-boot-fw-utils-mender-auto-provided/1.0-r0=/usr/src/debug/u-boot-fw-utils-mender-auto-provided/1.0-r0 -fdebug-prefix-map=/home/lserbetot/Developpement/imx-mender/build_imx8mm_mender/tmp/work/aarch64-poky-linux/u-boot-fw-utils-mender-auto-provided/1.0-r0/recipe-sysroot= -fdebug-prefix-map=/home/lserbetot/Developpement/imx-mender/build_imx8mm_mender/tmp/work/aarch64-poky-linux/u-boot-fw-utils-mender-auto-provided/1.0-r0/recipe-sysroot-native=  -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -E -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -fshort-wchar -O2 -fno-stack-protector -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral -Werror=date-time  -D__KERNEL__ -D__UBOOT__   -D__ARM__           -fno-pic  -mstrict-align  -ffunction-sections -fdata-sections -fno-common -ffixed-r9    -fno-common -ffixed-x18 -pipe -Iinclude  -I./arch/arm/include -include ./include/linux/kconfig.h  -nostdinc -isystem /home/lserbetot/Developpement/imx-mender/build_imx8mm_mender/tmp/work/aarch64-poky-linux/u-boot-fw-utils-mender-auto-provided/1.0-r0/recipe-sysroot-native/usr/bin/aarch64-poky-linux/../../lib/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/include -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM ./include/common.h > spl/u-boot.cfg.tmp && { grep 'define CONFIG_' spl/u-boot.cfg.tmp > spl/u-boot.cfg; rm spl/u-boot.cfg.tmp; } || { rm spl/u-boot.cfg.tmp; false; }
| In file included from include/config.h:11:0,
|                  from ./include/common.h:21:
| include/config_mender.h:73:5: error: #error CONFIG_SYS_MMC_ENV_DEV is not the same as MENDER_UBOOT_STORAGE_DEVICE. Either set it to the same value (check for example in the defconfig file), or make sure it is not defined at all. Make sure that: 1) All the instructions at docs.mender.io/devices/integrating-with-u-boot have been followed. 2) All required layers are included in bblayers.conf, including any board specific layers such as meta-mender-<board>
|  #   error CONFIG_SYS_MMC_ENV_DEV is not the same as MENDER_UBOOT_STORAGE_DEVICE. Either set it to the same value (check for example in the defconfig file), or make sure it is not defined at all. Make sure that: 1) All the instructions at docs.mender.io/devices/integrating-with-u-boot have been followed. 2) All required layers are included in bblayers.conf, including any board specific layers such as meta-mender-<board>
|      ^~~~~
| In file included from include/config.h:11:0,
|                  from ./include/common.h:21:
| include/config_mender.h:73:5: error: #error CONFIG_SYS_MMC_ENV_DEV is not the same as MENDER_UBOOT_STORAGE_DEVICE. Either set it to the same value (check for example in the defconfig file), or make sure it is not defined at all. Make sure that: 1) All the instructions at docs.mender.io/devices/integrating-with-u-boot have been followed. 2) All required layers are included in bblayers.conf, including any board specific layers such as meta-mender-<board>
|  #   error CONFIG_SYS_MMC_ENV_DEV is not the same as MENDER_UBOOT_STORAGE_DEVICE. Either set it to the same value (check for example in the defconfig file), or make sure it is not defined at all. Make sure that: 1) All the instructions at docs.mender.io/devices/integrating-with-u-boot have been followed. 2) All required layers are included in bblayers.conf, including any board specific layers such as meta-mender-<board>
|      ^~~~~
| In file included from include/config.h:11:0,
|                  from ./include/common.h:21:
| include/config_mender.h:73:5: error: #error CONFIG_SYS_MMC_ENV_DEV is not the same as MENDER_UBOOT_STORAGE_DEVICE. Either set it to the same value (check for example in the defconfig file), or make sure it is not defined at all. Make sure that: 1) All the instructions at docs.mender.io/devices/integrating-with-u-boot have been followed. 2) All required layers are included in bblayers.conf, including any board specific layers such as meta-mender-<board>
|  #   error CONFIG_SYS_MMC_ENV_DEV is not the same as MENDER_UBOOT_STORAGE_DEVICE. Either set it to the same value (check for example in the defconfig file), or make sure it is not defined at all. Make sure that: 1) All the instructions at docs.mender.io/devices/integrating-with-u-boot have been followed. 2) All required layers are included in bblayers.conf, including any board specific layers such as meta-mender-<board>
|      ^~~~~

I checked my bblayers.conf and meta-mender-imx is well included. bitbake -e core-image-base | grep “^MENDER_UBOOT_STORAGE_DEVICE” returns MENDER_UBOOT_STORAGE_DEVICE="". So I tried to add MENDER_UBOOT_STORAGE_DEVICE = “0” to local.conf but the compilation error remains.

Any idea about how to fix this compilation error?

Thanks.

Regards.

Edit: @mirzak: add formatting of logs and code

Just for reference this is what it looks like in my environment for imx8mqevk,

bitbake u-boot -e | grep ^MENDER_UBOOT_STORAGE_DEVICE
MENDER_UBOOT_STORAGE_DEVICE="1"
MENDER_UBOOT_STORAGE_DEVICE_DEFAULT=""
MENDER_UBOOT_STORAGE_DEVICE_DEFAULT_mender-ubi="dummy"
MENDER_UBOOT_STORAGE_DEVICE_imx8mqevk="1"

And this is normally deducted from the MENDER_STORAGE_DEVICE variable and you rarely need to change this.

There are two solutions,

  • make sure to remove any occurrences of CONFIG_SYS_MMC_ENV_DEV in you U-boot source for you board, this way MENDER_UBOOT_STORAGE_DEVICE will be used to define CONFIG_SYS_MMC_ENV_DEV during a Yocto build

  • make sure to set MENDER_UBOOT_STORAGE_DEVICE to the value that CONFIG_SYS_MMC_ENV_DEV has in your U-boot source for your board

I checked my bblayers.conf and meta-mender-imx is well included. bitbake -e core-image-base | grep “^MENDER_UBOOT_STORAGE_DEVICE” returns MENDER_UBOOT_STORAGE_DEVICE=“”. So I tried to add MENDER_UBOOT_STORAGE_DEVICE = “0” to local.conf but the compilation error remains.

I find it odd that it would be empty though.

Also the error seems to be on the u-boot-fw-utils-mender-auto-provided recipe, do you get the same error if you run bitbake u-boot?

I find it odd that it would be empty though.

Ah, it is empty if you run

 bitbake core-image-base -e | grep ^MENDER_UBOOT_STORAGE_DEVICE` 

but you should run:

bitbake u-boot -e | grep ^MENDER_UBOOT_STORAGE_DEVICE

Now my environment looks like the same as you:

bitbake -e u-boot-imx | grep ^MENDER_UBOOT_STORAGE_DEVICE
MENDER_UBOOT_STORAGE_DEVICE="1"
MENDER_UBOOT_STORAGE_DEVICE_DEFAULT=""
MENDER_UBOOT_STORAGE_DEVICE_DEFAULT_mender-ubi="dummy"
MENDER_UBOOT_STORAGE_DEVICE_imx8mmevk="1"

I tried to run bitbake u-boot-imx and the compilation error is the same. CONFIG_SYS_MMC_ENV_DEV seems to be initialized with 0 and MENDER_UBOOT_STORAGE_DEVICE equal to 1.

I will try your first solution, removing all occurrences of CONFIG_SYS_MMC_ENV_DEV for the source code of u-boot.

Thanks.

Regards.

You do not need to remove it all occurrences, just the ones present for you board, e.g in your defconfig and board header.

Also if it is initialized in U-boot as 0 this might mean that your SD card interface is 0 in U-boot, which means that you might need to adjust this,

MENDER_STORAGE_DEVICE_imx8mmevk = "/dev/mmcblk1"

to

MENDER_STORAGE_DEVICE_imx8mmevk = "/dev/mmcblk0"

Because this is what this variable is supposed to do, to make sure that the U-boot environment ends up on the correct device.

I found CONFIG_SYS_MMC_ENV_DEV only in my board header. I change it to match with MENDER_UBOOT_STORAGE_DEVICE i.e. 1. Now u-boot-imx compiles well.

But I get a Warning about the KERNEL_DEVICETREE in the u-boot-imx-2018.03-r0 do_provide_mender_defines:

WARNING: u-boot-imx-2018.03-r0 do_provide_mender_defines: Found more than one dtb specified in KERNEL_DEVICETREE. Only one should be specified. Choosing the last one.

I thinked this issue comes from the cross compilation of u-boot-fw-utils and needs to add https://github.com/mendersoftware/meta-mender-community/blob/sumo/meta-mender-renesas/recipes-bsp/u-boot/patches/default-gcc.patch but my tools/Makefile and tools/env/Makefile seems to be already with the right command:

override HOSTCC = $(CC)

Any idea to fix this issue?

Thanks.

Note: When I run a sdcard image without mender, I can see that SDCard is referenced as /dev/mmblck1 and eMMC as /dev/mmcblck2. So from my point of view, /dev/mmcblk1 seems to be the right value for mender.

This is safe to ignore for now.[MEN-2494] - Mender and CFEngine (by Northern.tech) Jira

But do you get any additional build errors or was it just the warning?

The compilation succeed without errors or warning and the board now boot. So much thanks for your help Mirzak.

But there is still an error on Linux kernel boot:

u-boot=> run bootcmd
switch to partitions #0, OK
mmc0 is current device
** Unable to read file boot.scr **
** Unrecognized filesystem type **
Booting from net ...

The above issue comes from the mender_uboot_root variable in u-boot. It is set to “mmc 1:2” which is the second partition of the eMMC instead of “mmc 0:2” which is the SDcard partition with the rootfs and the kernel. When I modified mender_uboot_root variable, Linux Kernel starts and everything works well.

I found that mender_uboot_root variable is construct like this in the code;

setenv mender_uboot_root " MENDER_UBOOT_STORAGE_INTERFACE " " __stringify(MENDER_UBOOT_STORAGE_DEVICE) ":${mender_boot_part};

So I modified MENDER_UBOOT_STORAGE_DEVICE and MENDER_UBOOT_STORAGE_DEVICE_imx8mmevk values to 0 but mender_uboot_root variable define by mender-setup command doesn’t reflect UBOOT_STORAGE_DEVICE value. It is still “mmc 1:2” instead of “mmc 0:2”.

Any idea why mender_uboot_root is not well set?

Thanks.

hi @jean, there is now an integration for this board,

Though it has not yet been run-time tested

Hi Mirzak,

Thanks for the pointer. I will test it and send you some feedback.

Regards.

hello @mirzak
The image generated above assumes it is running from the eMMC ??
it’s work on SD card but not on eMMC
i have core-image-base-imx8mmevk.sdimg and core-image-base-imx8mmevk.mender
i flash the image with the commande uuu -b emmc_all imx-boot-imx8mmevk-sd.bin-flash_evk core-image-base-imx8mmevk.sdimg successfully but it start only u-boot
What i have to do please

I believe the defaults will only work on SD.

You need to adjust the following variables for it to work for eMMC,

Additional reading:

https://docs.mender.io/2.2/devices/yocto-project/partition-configuration

Hello

i set this config:
MENDER_STORAGE_DEVICE_imx8mmevk = “/dev/mmcblk0”
and i have this problem when i boot from emmc
mmc1(part 0) is current device
** Unable to read file boot.scr **
Card did not respond to voltage select!
** Bad device mmc 0 **
i thnik it’s the same problem as @jean ,what i have to do please?i have to modify mender_uboot_root variable??where can i find it?

This appears to be using the standard bootcmd and not the one modified for use with Mender as it is trying to load a boot script. Do you have the Mender integration patches applied?

Also, the “Bad device mmc 0” message indicates that you don’t have anything enumerated as device 1 on the MMC bus. What does “mmc list” show when manually run from the U-Boot prompt?

Drew

i just follow this link without any changes(imx8mmevk):NXP® i.MX 8MQuad Evaluation Kit
Compilation done succefuly,Boot with SDcard done also,i flash the image on emmc but i have boot error:mmc1(part 0) is current device
** Unable to read file boot.scr **
mmc_list

Can someone help me
u-boot=> fatload mmc 1:1
** No boot file defined **
u-boot=> fatls mmc 1:1
677053 u-boot-imx8mmevk.bin
1 file(s), 0 dir(s)

what i have to do please