Yocto imx8mmevk eMMC u-boot problem

u-boot=> ext4load mmc 0:2 ${loadaddr} ${image}
Card did not respond to voltage select!
** Bad device mmc 0 **
u-boot=> ext4load mmc 1:2 ${loadaddr} ${image}
23163392 bytes read in 451 ms (49 MiB/s)

I think because the partitions are in device 1 (eMMC) , and that’s what mmc part is showing :

u-boot=> mmc part

Partition Map for MMC device 1 – Partition Type: DOS

Part Start Sector Num Sectors UUID Type
1 49152 32768 d2e3c935-01 0c Boot
2 81920 425984 d2e3c935-02 83
3 507904 425984 d2e3c935-03 83
4 933888 262144 d2e3c935-04 83
u-boot=> mmc list
FSL_SDHC: 0
FSL_SDHC: 1 (eMMC)

because the second part in mmc 1:2 is the rootfs_partA I think.

[EDIT]

[EDIT2]
I rebuilt the image with adding back the file name:

MENDER_IMAGE_BOOTLOADER_FILE = " imx-boot-${MACHINE}-sd.bin "

and I found out that mmc 1:1 is type FAT:
u-boot=> fatls mmc 1:1
676901 u-boot-imx8mmevk.bin

1 file(s), 0 dir(s)

Any solutions ?

[EDIT]
I think the device part is okay, because when I try to load the boot.scr manually :
fatload mmc 1:1 {loadaddr} {image} it gives me : Unable to load boot.scr
But when I try with the part 0 it gives : unrecognized file system ,*

So the problem is with the u-boot generated with yocto itself i think .

It might be, but by default Mender will load the Linux kernel from mmc 1:2 which should be an ext4 filesystem. That file in the FAT partition is actually not used and is there to satisfy a Yocto build dependency.

Hi,
Please I need to inform you that I need to flash and boot from the eMMC
I’ve been testing this for more than a week now,
Please if there is a solution help me.

Same issue here, any success?
[Add:]
I think I created a workaround for booting from eMMC, this worked for me…

0] on my i.MX8M Mini board:

SD card is /dev/mmcblk1 in linux and mmc dev 0 in u-boot
eMMc is /dev/mmcblk2 in linux and mmc dev 1 in u-boot

1] update the conf/local.conf

MENDER_STORAGE_DEVICE_imx8mmevk = "/dev/mmcblk2"
\# Following is not essential
MENDER_STORAGE_DEVICE = "/dev/mmcblk2"
MENDER_BOOT_PART = "${MENDER_STORAGE_DEVICE_BASE}1"
MENDER_DATA_PART = "${MENDER_STORAGE_DEVICE_BASE}4"
MENDER_ROOTFS_PART_A = "${MENDER_STORAGE_DEVICE_BASE}2"
MENDER_ROOTFS_PART_B = "${MENDER_STORAGE_DEVICE_BASE}3"

2] rebuild the image:

bitbake core-image-base

3] setup board (via DIP switches) to “Download Mode”, and flash the board with:

uuu -v -b emmc_all imx-boot-imx8mmevk-sd.bin core-image-base-imx8mmevk.sdimg

4] setup board to “eMMC / SDHC3” mode and enter u-boot

note chapter 4. errata of UG

5] once in u-boot console, enter following:

setenv mender_uboot_boot "mmc 1:1"
setenv mender_uboot_dev 1
setenv mender_setup 'if test "${mender_saveenv_canary}" != "1"; then setenv mender_saveenv_canary 1; saveenv; fi; if test "${mender_pre_setup_commands}" != ""; then run mender_pre_setup_commands; fi; if test "${mender_systemd_machine_id}" != ""; then setenv bootargs systemd.machine_id=${mender_systemd_machine_id} ${bootargs}; fi; setenv mender_kernel_root /dev/mmcblk2p${mender_boot_part}; if test ${mender_boot_part} = 2; then setenv mender_boot_part_name /dev/mmcblk2p2; else setenv mender_boot_part_name /dev/mmcblk2p3; fi; setenv mender_kernel_root_name ${mender_boot_part_name}; setenv mender_uboot_root mmc 1:${mender_boot_part_hex}; setenv mender_uboot_root_name ${mender_boot_part_name}; setenv expand_bootargs "setenv bootargs \\"${bootargs}\\""; run expand_bootargs; setenv expand_bootargs; if test "${mender_post_setup_commands}" != ""; then run mender_post_setup_commands; fi'
boot

6] Linux should boot successfully

My speculation is, that the mmc dev number is set incorrectly in generated u-boot? I am trying to find a way to change it through some config. Is there such an option?

Managed to force the boot (without cumbersome setenvs) by adding following to conf/local.conf (step 1] in previous post)

MENDER_STORAGE_DEVICE = "/dev/mmcblk2"
MENDER_STORAGE_DEVICE_imx8mmevk = "/dev/mmcblk2"
MENDER_UBOOT_POST_SETUP_COMMANDS = "setenv mender_uboot_root mmc 1:2"

Steps 4] and 5] are not necessary anymore, but following error pops up during boot:


switch to partitions #0, OK
mmc1(part 0) is current device
** Unable to read file boot.scr **
Saving Environment to MMC… Env export buffer too small: 4091, but need 4117
Cannot export environment: errno = 12
Failed (1)
23163392 bytes read in 12620 ms (1.7 MiB/s)
Booting from mmc …

Is this an approved approach?
Will the failure to saveenv interfere with Mender working properly?

Thanks for reply

eMMc is /dev/mmcblk2 in linux and mmc dev 1 in u-boot

In this case, it should be enough to set the following in local.conf:

MENDER_UBOOT_STORAGE_DEVICE = "1"
MENDER_STORAGE_DEVICE_imx8mmevk = "/dev/mmcblk2"

So the MENDER_UBOOT_POST_SETUP_COMMANDS should not be necessary.

Additional documentation can be found here,

This error can show to be problematic as your environment is to big to fit in what is currently allocated by U-Boot.

You will need to update the CONFIG_ENV_SIZE variable in your U-Boot source to allow it to fit. Note that you also need to update the BOOTENV_SIZE variable in Yocto to match what is set by CONFIG_ENV_SIZE

This does not work for me… boot fails with:

switch to partitions #0, OK
mmc1(part 0) is current device
flash target is MMC:1
Net: eth0: ethernet@30be0000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc1(part 0) is current device
** Unable to read file boot.scr **
Card did not respond to voltage select!
** Bad device mmc 0 **
Booting from net …

u-boot still does: setenv mender_uboot_root mmc 0:${mender_boot_part_hex};, as per printenv:


mender_setup=if test “${mender_saveenv_canary}” != “1”; then setenv mender_saveenv_canary 1; saveenv; fi; if test “${mender_pre_setup_commands}” != “”; then run mender_pre_setup_commands; fi; if test “${mender_systemd_machine_id}” != “”; then setenv bootargs systemd.machine_id=${mender_systemd_machine_id} ${bootargs}; fi; setenv mender_kernel_root /dev/mmcblk2p${mender_boot_part}; if test ${mender_boot_part} = 2; then setenv mender_boot_part_name /dev/mmcblk2p2; else setenv mender_boot_part_name /dev/mmcblk2p3; fi; setenv mender_kernel_root_name ${mender_boot_part_name}; setenv mender_uboot_root mmc 0:${mender_boot_part_hex}; setenv mender_uboot_root_name ${mender_boot_part_name}; setenv expand_bootargs “setenv bootargs \”${bootargs}\“”; run expand_bootargs; setenv expand_bootargs; if test “${mender_post_setup_commands}” != “”; then run mender_post_setup_commands; fi

would this be a bug?

u-boot still does: setenv mender_uboot_root mmc 0:${mender_boot_part_hex}; , as per printenv :

Hmm, are you sure that you get MENDER_UBOOT_STORAGE_DEVICE = “1” during you build, because mender_uboot_root is defined as such:

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

Can you run the following in your environment:

bitbake <image> -e | grep ^MENDER_UBOOT_STORAGE_DEVICE

It is defined here, https://github.com/mendersoftware/meta-mender/blob/master/meta-mender-core/recipes-bsp/u-boot/patches/0002-Generic-boot-code-for-Mender.patch#L217

MENDER_UBOOT_STORAGE_DEVICE=“1”
MENDER_UBOOT_STORAGE_DEVICE_DEFAULT=“”
MENDER_UBOOT_STORAGE_DEVICE_DEFAULT_mender-ubi=“dummy”

I found the 0002-Generic-boot-code-for-Mender.patch and it seems to be applied (e.g. changing MENDER_UBOOT_STORAGE_INTERFACE does manifest according to what the patch suggests), but how do I make sure?

Make sure to clear the U-Boot environment when you flash the updated U-Boot binary, so you are not using an “old” environment.

How would I go about clearing the “old” environment?

You can run in U-Boot prompt:

env default -a
saveenv

Clearing the U-Boot environment did not help.

How do I make sure the patch is applied? The include/env_mender.h file is nowhere to be found in the build/tmp folder.

[Add:]
Changing MENDER_UBOOT_STORAGE_DEVICE_imx8mmevk to = "1" in sources/meta-mender-community/meta-mender-imx/recipes-bsp/u-boot/u-boot-imx_\%.bbappend yields an error:

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-

[Add 2:]
OK, after disabling INHERIT += "rm_work", I can find the patch applied in:

build/tmp/work/imx8mmevk-poky-linux/u-boot-imx/2018.03-r0/git/include/env_mender.h
and
build/tmp/work/aarch64-poky-linux/u-boot-fw-utils-mender-auto-provided/1.0-r0/git/include/env_mender.h

As the message says, it it is important that the CONFIG_SYS_MMC_ENV_DEV is not defined in your U-Boot sources, so remove that if possible.

Hi

I think I managed to do exactly that. It seems to be a bug in meta-mender-community project. Doing:

diff --git a/include/configs/imx8mm_evk.h b/include/configs/imx8mm_evk.h
index 68d0643..c053ed3 100644
--- a/include/configs/imx8mm_evk.h
+++ b/include/configs/imx8mm_evk.h
@@ -249,7 +249,6 @@
 #define CONFIG_ENV_OFFSET       (60 << 20)
 #endif
 #define CONFIG_ENV_SIZE			0x1000
-#define CONFIG_SYS_MMC_ENV_DEV		0   /* USDHC2 */
 #define CONFIG_MMCROOT			"/dev/mmcblk1p2"  /* USDHC2 */

in build/tmp/work/imx8mmevk-poky-linux/u-boot-imx/2018.03-r0/git/ solved the issue.

PR with the fixes: https://github.com/mendersoftware/meta-mender-community/pull/122

Thanks @Tom

Hi,

just to clarify…

it is not tested with the imx8mqevk board, right? Wouldn’t it be cleaner to split it into two distinct patches, making an eventual revert more straight forward?

Of course if you tested the board, there will be no issue.