Issue with Variscite VAR-SOM-MX8M-NANO

Hello @drewmoseley,

I have tried to follow these instructions and hit problems. Are you able to help? Firstly the U-boot patch was rejected. The problem is very similar to https://hub.mender.io/t/is-there-a-support-for-meta-mender-imx-on-zeus/2669/10. I am using meta-imx version 5.4.4.7-2.2.0. I changed the patch to work on the newer version and everything compiled. However, there was an error when trying to create the image filesystem:

    ERROR: fsl-image-qt5-1.0-r0 do_image_ext4: Execution of '/home/yocto/nano/var-fsl-yocto/build_xwayland/tmp/work/imx8mn_var_som-poky-linux/fsl-image-qt5/1.0-r0/temp    /run.do_image_ext4.23158' failed with exit code 1:                                                                                                                                                                                                   
    0+0 records in                                                                                                                                                                                              
    0+0 records out                                                                                                                                                                                             
    0 bytes copied, 0.000132599 s, 0.0 kB/s                                                                                                                                                                     
    mke2fs 1.45.3 (14-Jul-2019)                                                                                                                                                                                 
    Discarding device blocks: done                                                                                                                                                                              
    Creating filesystem with 843273 4k blocks and 843648 inodes                                                                                                                                                 
    Filesystem UUID: 99d16d85-dd5d-46d1-a963-71175a1bed8c                                                                                                                                                       
    Superblock backups stored on blocks:                                                                                                                                                                        
            32768, 98304, 163840, 229376, 294912, 819200                                                                                                                                                        
                                                                                                                                                                                                            
    Allocating group tables: done                                                                                                                                                                               
    Writing inode tables: done                                                                                                                                                                                  
    Creating journal (16384 blocks): done                                                                                                                                                                       
    Copying files into the device: __populate_fs: Could not allocate block in ext2 filesystem while     writing file "sysc_setreuid.stp"                                                                            
    mkfs.ext4: Could not allocate block in ext2 filesystem while populating file system                                                                                                                         
    WARNING: exit code 1 from a shell command.                                                                                                                                                                  
                                                                                                                                                                                                            
    ERROR: Logfile of failure stored in: /home/yocto/nano/var-fsl-yocto/build_xwayland/tmp/work    /imx8mn_var_som-poky-linux/fsl-image-qt5/1.0-r0/temp/log.do_image_ext4.23158

Here is the modified patch:

diff --git a/configs/imx8mn_var_som_defconfig b/configs/imx8mn_var_som_defconfig
index ca354a4ed8..96ae23d6aa 100644
--- a/configs/imx8mn_var_som_defconfig
+++ b/configs/imx8mn_var_som_defconfig
@@ -84,3 +84,5 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_CI_UDC=y
 CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_EFI_LOADER=y
+CONFIG_DISTRO_DEFAULTS=y
diff --git a/include/configs/imx8mn_var_som.h b/include/configs/imx8mn_var_som.h
index c554a9da63..55cc3ad678 100644
--- a/include/configs/imx8mn_var_som.h
+++ b/include/configs/imx8mn_var_som.h
@@ -60,6 +60,7 @@
 
 #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 
+#define BOOTENV
 #endif /* CONFIG_SPL_BUILD */
 
 #define CONFIG_CMD_READ
@@ -109,21 +110,20 @@
 /* Initial environment variables */
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	CONFIG_MFG_ENV_SETTINGS \
+        BOOTENV \
 	"bootdir=/boot\0" \
 	"script=boot.scr\0" \
 	"image=Image.gz\0" \
 	"img_addr=0x42000000\0" \
 	"console=ttymxc3,115200 earlycon=ec_imx6q,0x30a60000,115200\0" \
-	"fdt_addr=0x43000000\0" \
+	"fdt_addr_r=0x43000000\0" \
 	"fdt_high=0xffffffffffffffff\0" \
 	"boot_fdt=try\0" \
 	"ip_dyn=yes\0" \
-	"fdt_file=undefined\0" \
+	"fdtfile=undefined\0" \
 	"initrd_addr=0x43800000\0" \
 	"initrd_high=0xffffffffffffffff\0" \
 	"mmcdev="__stringify(CONFIG_SYS_MMC_ENV_DEV)"\0" \
-	"mmcblk=1\0" \
-	"mmcautodetect=yes\0" \
 	"mmcpart=1\0" \
 	"m7_addr=0x7e0000\0" \
 	"m7_bin=hello_world.bin\0" \
@@ -138,65 +138,14 @@
 			"dcache flush; " \
 		"fi; " \
 		"bootaux ${m7_addr};\0" \
-	"optargs=setenv bootargs ${bootargs} ${kernelargs};\0" \
-	"mmcargs=setenv bootargs console=${console} " \
-		"root=/dev/mmcblk${mmcblk}p${mmcpart} rootwait rw ${cma_size}\0 " \
-	"loadbootscript=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bootdir}/${script};\0" \
-	"bootscript=echo Running bootscript from mmc ...; " \
-		"source\0" \
-	"loadimage=load mmc ${mmcdev}:${mmcpart} ${img_addr} ${bootdir}/${image};" \
 		"unzip ${img_addr} ${loadaddr}\0" \
 	"findfdt=" \
-		"if test $fdt_file = undefined; then " \
+		"if test $fdtfile = undefined; then " \
 			"if test $som_rev = som_rev10; then " \
-				"setenv fdt_file imx8mn-var-som-rev10.dtb; " \
+				"setenv fdtfile imx8mn-var-som-rev10.dtb; " \
 			"else " \
-				"setenv fdt_file imx8mn-var-som.dtb; " \
+				"setenv fdtfile imx8mn-var-som.dtb; " \
 			"fi;" \
-		"fi; \0" \
-	"loadfdt=run findfdt; " \
-		"echo fdt_file=${fdt_file}; " \
-		"load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${bootdir}/${fdt_file}\0" \
-	"ramsize_check="\
-		"if test $sdram_size -le 512; then " \
-			"setenv cma_size cma=320M; " \
-		"else " \
-			"setenv cma_size cma=640M@1376M; " \
-		"fi;\0" \
-	"mmcboot=echo Booting from mmc ...; " \
-		"run mmcargs; " \
-		"run optargs; " \
-		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-			"if run loadfdt; then " \
-				"booti ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"echo WARN: Cannot load the DT; " \
-			"fi; " \
-		"else " \
-			"echo wait for boot; " \
-		"fi;\0" \
-	"netargs=setenv bootargs console=${console} " \
-		"root=/dev/nfs ${cma_size} " \
-		"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
-	"netboot=echo Booting from net ...; " \
-		"if test ${ip_dyn} = yes; then " \
-			"setenv get_cmd dhcp; " \
-		"else " \
-			"setenv get_cmd tftp; " \
-		"fi; " \
-		"${get_cmd} ${img_addr} ${image}; unzip ${img_addr} ${loadaddr};" \
-		"run netargs; " \
-		"run optargs; " \
-		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-			"run findfdt; " \
-			"echo fdt_file=${fdt_file}; " \
-			"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
-				"booti ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"echo WARN: Cannot load the DT; " \
-			"fi; " \
-		"else " \
-			"booti; " \
 		"fi;\0"
 
 #define CONFIG_BOOTCOMMAND \
@@ -206,18 +155,11 @@
 		"if test ${use_m7} = yes && run loadm7bin; then " \
 			"run runm7bin; " \
 		"fi; " \
-		"if run loadbootscript; then " \
-			"run bootscript; " \
-		"else "\
-			"if run loadimage; then " \
-				"run mmcboot; " \
-			"else " \
-				"run netboot; " \
-			"fi; " \
-		"fi; " \
-	"else " \
-		"booti ${loadaddr} - ${fdt_addr}; " \
-	"fi;"
+	"fi;" \
+	"setenv bootargs console=${console} ${cma_size} ${kernelargs}; " \
+	"run findfdt; " \
+	"setenv kernel_addr_r ${loadaddr}; " \
+	"run distro_bootcmd;"
 
 /* Link Definitions */
 #define CONFIG_LOADADDR			0x40480000
@@ -234,6 +176,7 @@
 #define CONFIG_ENV_OVERWRITE
 
 /* Default ENV offset is 4MB for SD/EMMC/FSPI, but NAND uses 60MB offset, overridden by env_get_offset */
+#define CONFIG_ENV_SIZE			SZ_8K
 #define CONFIG_ENV_SECT_SIZE		(64 * 1024)
 #define CONFIG_SYS_MMC_ENV_DEV		1 /* USDHC2 */
 
@@ -301,6 +244,11 @@
 #define CONFIG_USB_GADGET_MASS_STORAGE
 #define CONFIG_USB_FUNCTION_MASS_STORAGE
 
+#define BOOT_TARGET_DEVICES(func) \
+        func(MMC, mmc, 2) \
+        func(MMC, mmc, 1)
+#include <config_distro_bootcmd.h>
+
 #endif
 
 #define CONFIG_USB_GADGET_VBUS_DRAW 2

Hi @gphillips-a2e can you submit this modified patch as a PR? That way I can see exactly what is changing.

As for the build error, the only time I have seen that specific message was when MENDER_STORAGE_TOTAL_SIZE_MB was too small.

Drew

@drewmoseley
Hi Drew,

I have created the pull request you asked for. My confidence in it is pretty low though.

I increased MENDER_STORAGE_TOTAL_SIZE_MB and it created the image successfully. Thanks for the suggestion.

When I ran the image it appeared to boot and showed the Mender logo. However, there were several problems:

  • It booted much more slowly than usual
  • After booting it showed the console, even though I was building fsl-image-qt5 (which normally boots to XFCE)
  • It hangs when I try to log into the console
  • It keeps printing memcg_kmem_cache_create_func

Do you have an idea what is causing these issues?

Thanks,
Gareth

Hi Gareth,

I don’t really know. Can you replicate this setup without the Mender integration and see the same issues?
Drew

@drewmoseley

Without the Mender integration it is just the off-the-shelf Variscite fsl-image-qt5 build. It was working for me.

@gphillips-a2e with the latest code from my PR, does it work if you add the following to local.conf?

MENDER_FEATURES_ENABLE_append = " mender-uboot"
MENDER_FEATURES_DISABLE_append = " mender-grub mender-image-uefi"

I was able to reproduce your kmem_cache_create issue when using Grub integration but when using U-Boot it didn’t happen. I really don’t know why.

@drewmoseley
I tried the suggested local.conf changes. I had an error building:

/home/yocto/nano/var-fsl-yocto/build_xwayland/tmp/work/imx8mn_var_som-poky-linux/fsl-image-qt5/1.0-r0/bootfs.image_sdimg/*: No such file or directory      

Based on https://hub.mender.io/t/yocto-warrior-build-failing-on-do-image-sdimg-for-beaglebone/1706, I tried adding this to the end of local.conf:

IMAGE_BOOT_FILES = "u-boot.bin"                                                                                              

This solved the build problem, but when I booted the image I got “Bad Linux ARM64 Image Magic!”.

Dang. I had another setting locally that I missed telling you about. Remove your IMAGE_BOOT_FILES setting and add the following in addition to the MENDER_FEATURES settings from above:

MENDER_BOOT_PART_SIZE_MB_mender-uboot = "0"
KERNEL_IMAGETYPE_mender-uboot = "Image"

@drewmoseley
I tried the MENDER_BOOT_PART_SIZE_MB and KERNEL_IMAGETYPE changes with IMAGE_BOOT_FILES removed. It compiles, but I still get the bad image magic message.

Hmm. What does the following show?

bitbake -e fsl-image-qt 2>&1 | grep ^KERNEL_IMAGETYPE=

Drew

The output is KERNEL_IMAGETYPE="Image".

OK. That means that the variable change is correct. Do you see an Image.gz file in the root filesystem partition of the resultant build image? The only thing I can think of is that somehow it didn’t repackage everything. Maybe due to a sstate-cache issue.

If you try the following it should make sure it all gets rebuilt.

$ bitbake -c cleansstate fsl-image-qt virtual/kernel
$ bitbake fsl-image-qt

Drew

@drewmoseley
That solved the problem - it now boots successfully. The problems I have mentioned previously have gone. Thanks for your excellent support with this issue. There may however still be an issue with WiFi.

Hello all. I am having the exact same issue as described. I attempted to follow these steps to rectify the issue with no luck. I am trying to build the fsl-image-qt5. When adding the MENDER_FEATURES_ENABLE_append = " mender-uboot" to my local.conf, I get the following:
ERROR: Task do_patch in /home/blurpd/var-fsl-yocto/sources/meta-mender/meta-mender-core/recipes-bsp/u-boot/u-boot-fw-utils-mender-auto-provided_1.0.bb depends upon non-existent task do_mender_tar_src in /home/blurpd/var-fsl-yocto/sources/meta-variscite-imx/recipes-bsp/u-boot/u-boot-variscite.bb
I tried commenting out the line:
MACHINE_EXTRA_RDEPENDS_remove = "u-boot-fw-utils"
but this did not help.

If have not been able to find a way around this. Could one of you help me out? Is there a patch or something I need to apply? I am a high functioning noob when it comes to Yocto.

Hi @nateblurpd my PR was just merged that would get this to work with the 5.4.24 BSP on the NANO. Can you refresh your sources and try again?
If you still have the issue, can you post the git commit hashes you are using for meta-mender and meta-mender-community?

Drew

I have been working on an urgent project with imx8mnano Variscite board and needed some help with integration of Mender.
What I have tried is the steps that are mentioned in the integration for imx8mn Variscite VAR-SOM-MX8M-NANO : NXP i.MX 8M Nano

I am using Yocto dunfell version and have the following local.conf.
However I have not been able to boot from the sdimg file(please see below). I have been trying for more than two weeks now but haven’t been able to boot my board.

My local.conf:

# This will make sure that our SPL + u-boot.img is embedded in the sdimg at
# a 1kb offset.
MENDER_IMAGE_BOOTLOADER_FILE = "u-boot-spl.bin"
MENDER_IMAGE_BOOTLOADER_BOOTSECTOR_OFFSET = "2"

# Remove the unneeded VFAT boot partition
IMAGE_BOOT_FILES = ""
MENDER_BOOT_PART_SIZE_MB = "0"

# Cleanup image types generated
IMAGE_FSTYPES_remove = "tar.gz ext4 wic.gz wic.bmap multiubi mender.bmap"

# Artifact name
MENDER_ARTIFACT_NAME = "enphase-mender-release-1"

# disable uefi
MENDER_FEATURES_ENABLE_append = " mender-uboot mender-image"
MENDER_FEATURES_DISABLE_append = " mender-grub mender-image-uefi"

# Appended fragment from meta-mender-community/meta-mender-variscite/templates
# SDCard Settings
MENDER_STORAGE_DEVICE_imx8mn-var-som = "/dev/mmcblk1"
MENDER_UBOOT_STORAGE_DEVICE_imx8mn-var-som = "1"
UBOOT_CONFIG_imx8mn-var-som = "sd"
MENDER_FEATURES_ENABLE_append = " mender-image-sd "
MENDER_STORAGE_TOTAL_SIZE_MB = "8192"

I have mounted the two roofs partition and can see Linux image is there. Besides from the sdimg file I was also able to dump the bootloader yet it doesn’t boot the board.