Variscite VAR-SOM-MX8M-MINI : NXP i.MX 8M Mini

Board description

The VAR-SOM-MX8M-MINI is a highly scalable, low power System on Module (SoM), offering a mainstream solution to fit a wide range of applications and cost requirements.

Based on NXP’s i.MX 8M Mini with up to 1.8GHz Quad-core ARM Cortex-A53™ plus 400MHz Cortex-M4™ real-time processor and up to 4 GB DDR4, the VAR-SOM-MX8M-MINI supports advanced features and a variety of connectivity options, including integrated HW engines supporting 1080p video encoding and decoding, 2D and 3D graphics, HQ audio, integrated certified single band 802.11 b/g/n or dual-band 802.11 ac/a/b/g/n, integrated CAN bus, LVDS, and a variety of additional interfaces.

The VAR-SOM-MX8M-MINI is a pin2pin platform compatible with the ‘VAR-SOM Pin2Pin’ products family, providing a maximum scalability range; from the entry-level i.MX6UL/6ULL platform, through the i.MX 6 platforms, i.MX 8X, and up to the i.MX 8QuadMax.

The VAR-SOM-MX8M-MINI Development Kit and Starter Kit can serve as a complete development platform for both evaluation and application development purposes. The kits provide a great showcase of the VAR-SOM-MX8M-MINI connectivity features and performance.

VAR-SOM-MXM-MINI

Test results

The Yocto Project releases in the table below have been tested by the Mender community. Please update it if you have tested this integration on other Yocto Project releases:

SD Card Root Filesystem

Yocto Project Build Runtime
warrior (2.7) :test_works: :test_works:
zeus (3.0) :test_works: :test_works:

eMMC Root Filesystem

Yocto Project Build Runtime
warrior (2.7) :test_works: :test_works:
zeus (3.0) :test_works: :test_works:

Build Means that the Yocto Project build using this Mender integration completes without errors and outputs images.
Runtime Means that Mender has been verified to work on the board. For U-Boot-based boards, the integration checklist has been verified.

Getting started

Prerequisites

  • A supported Linux distribution and dependencies installed on your workstation/laptop as described in the Yocto Mega Manual
    • NOTE. Instructions depend on which Yocto version you intend to use.
  • Google repo tool installed and in your PATH.

Configuring the build

Setup Yocto environment

Set the Yocto Project branch you are building for:

# set to your branch, make sure it is supported (see table above)
export BRANCH="warrior"

Create a directory for your mender-variscite setup to live in and clone the
meta information.

mkdir mender-variscite && cd mender-variscite

Initialize repo manifest:

if [ ${BRANCH} == "zeus" ]; then
  REPO_BRANCH="fsl-${BRANCH}"
else
  REPO_BRANCH="${BRANCH}"
fi
repo init -u https://github.com/varigit/variscite-bsp-platform.git -b ${REPO_BRANCH}                                                                                       
mkdir .repo/local_manifests
cd .repo/local_manifests/
wget https://raw.githubusercontent.com/mendersoftware/meta-mender-community/$BRANCH/scripts/mender-no-setup.xml
cd -

Fetch layers in manifest:

repo sync
cd .repo/local_manifests/
ln -sf ../../sources/meta-mender-community/scripts/mender-no-setup.xml .
cd -

Determine root filesystem media

The Variscite VAR-SOM-MX8M-MINI platform supports running U-Boot directly from the following media:

  • SD-Card
  • eMMC

The root filesystem can be stored on any of the following media:

  • SD-Card
  • eMMC

Set the shell variable for your desired root filesystem media:

export MEDIA="sdcard"
export MEDIA="emmc"

Setup build environment

Initialize the build environment:

MACHINE=imx8mm-var-dart DISTRO=fsl-imx-xwayland . var-setup-release.sh -b build
cat ../sources/meta-mender-community/meta-mender-variscite/templates/bblayers.conf.append >> conf/bblayers.conf
cat ../sources/meta-mender-community/templates/local.conf.append >> conf/local.conf
cat ../sources/meta-mender-community/meta-mender-variscite/templates/local.conf.append >> conf/local.conf
cat ../sources/meta-mender-community/meta-mender-variscite/templates/local-${MEDIA}.conf.append >> conf/local.conf

Building the image

You can now proceed with building an image:

bitbake core-image-base

Replace core-image-base with your desired image target.

Using the build output

SD Card

Provision an SD Card with the built above. WARNING, make sure you use the correct device node as the of= parameter to avoid overwriting the wrong device:

sudo dd if=tmp/deploy/images/imx8mm-var-dart/core-image-base-imx8mm-var-dart.sdimg of=<SDCARD-DEVICE-NODE> conv=fdatasync bs=8M

Remove the SD Card from your build host and insert it into the target. Configure your board to boot from SD Card by moving the Boot Select switch (also labeled as SW3 ) to the SD position. Now turn on power to the board and it will boot from the SDCard and Mender will connect to the server configured in your local.conf file.

eMMC

Using either the above built SDCard Yocto image or the Variscite Yocto Recovery SD card, boot your system off of SD. Transfer the following file from your build PC to the target board with a USB drive:

  • tmp/deploy/images/imx8mm-var-dart/core-image-base-imx8mm-var-dart.sdimg

Assuming the USB drive is mounted on the target at /mnt, run the following commands:

sudo dd if=/mnt/core-image-base-imx8mm-var-dart.sdimg of=/dev/mmcblk0 conv=fdatasync bs=8M
halt

Then change the Boot Select switch (also labeled as SW3 ) to the Internal position and power cycle your board.

eMMC - USB Mass Storage Installation

An alternative mechanism exists if you already have a working UBoot running from either SD-Card or eMMC running on the target board. This mechanism will present the eMMC device to your development PC as a mass storage device and you can flash the image directly from there.

  1. Boot the system and press any key to interrupt the boot process, leaving you at the U-Boot> prompt.
  2. Connect a USB cable from USB3/J26 port on the target board to your PC.
  3. Enable USB mass storage mode from the U-Boot> prompt:
U-Boot> ums 0 mmc 1
  1. Determine what device node was added on your PC. This can be done using the Disk Utility or viewing system logs. Consult your PC OS documentation for more details
  2. Write the flash directly to the eMMC. This assumes the new device was enumerated as /dev/sdd. WARNING: this will destroy any contents on the device listed under the of= parameter below.
sudo dd if=tmp/deploy/images/imx8mm-var-dart/core-image-base-imx8mm-var-dart.sdimg of=<EMMC-DEVICE-NODE> conv=fdatasync bs=8M

On the other hand, if you already have Mender running on your device and want to deploy a rootfs update using this build, you should use the Mender Artifact files, which have .mender suffix. You can either deploy this Artifact in managed mode with the Mender server (upload it under Releases in the server UI) or by using the Mender client only in Standalone deployments.

References

  • The Variscite imx8m-var-dart template files can be found in meta-mender-community.
  • The official Mender documentation explains how Mender works. This is simply a board-specific complement to the official documentation.

If this post was useful to you, please press like, or leave a thank you note to the contributor who put valuable time into this and made it available to you. It will be much appreciated!

3 Likes

Dear drewmoseley,
thank you very much for this guide. I’m using this module in a project and the mender integration went very well so far, thanks to your effort.
(Just on thing to add maybe: I needed to ‘bitbake -c populate_sdk …’ before building the image itself. Without this step there was some mender compilation error regarding ‘pseudo-native’, which could not be found.)

Now I would like to use OP-TEE for some security features. There are examples by NXP for their EVKs, but none really for the Variscite modules (see the NXP community board). I tried a few approaches and the best one resulted in appending ‘optee’ to the MACHINE_FEATURES and inserting a node into the devicetree - so far, so good.

Then there’s the problem: OP-TEE needs to add a file called ‘tee.bin’ to u-boot, i. e. to the boot partition via IMAGE_BOOT_FILES variable, but following your guide it is manually set to empty by the ‘meta-mender-variscite/templates/local.conf.append’ and the boot partition size is set to ‘0’.

Do you have an idea how to solve this? I tried commenting the overrides in ‘local.conf’, but the board won’t boot then, since it seems to be unable to find the bootloader.
Would it be possible to add the file to ‘/boot’, where kernel and devicetrees are located?

/edit:
I just looked at the u-boot env and there seems to be a new bootcmd with optee content:
bootcmd_mfg=run mfgtool_args;if iminfo ${initrd_addr}; then if test ${tee} = yes; then bootm ${tee_addr} ${initrd_addr} ${fdt_addr}; else booti ${loadaddr} ${initrd_addr} ${fdt_addr}; fi; else echo "Run fastboot ..."; fastboot 0; fi;

u-boot=> printenv

altbootcmd=run mender_altbootcmd; run bootcmd
baudrate=115200
board_name=VAR-SOM-MX8M-MINI
boot_fdt=try
bootcmd=run mender_setup; setenv bootargs root={mender_kernel_root} {bootargs}; if test “{fdt_addr_r}" != ""; then load {mender_uboot_root} {fdt_addr_r} /boot/{mender_dtb_name}; fi; load {mender_uboot_root} {img_addr} /boot/{mender_kernel_name};unzip {img_addr} {loadaddr}; {mender_boot_kernel_type} {kernel_addr_r} - {fdt_addr_r}; run mender_try_to_recover
bootcmd_mfg=run mfgtool_args;if iminfo {initrd_addr}; then if test {tee} = yes; then bootm {tee_addr} {initrd_addr} {fdt_addr}; else booti {loadaddr} {initrd_addr} {fdt_addr}; fi; else echo “Run fastboot …”; fastboot 0; fi;
bootcount=1
bootdelay=1
bootdir=/boot
bootlimit=1
bootscript=echo Running bootscript from mmc …; source
console=ttymxc3,115200 earlycon=ec_imx6q,0x30a60000,115200
emmc_dev=1
ethaddr=xx:xx:xx:xx:xx:xx
ethprime=FEC
fastboot_dev=mmc0
fdt_addr_r=0x43000000
fdt_file=undefined
fdt_high=0xffffffffffffffff
fdtcontroladdr=b6d43ad8
findfdt=if test $fdt_file = undefined; then if test $board_name = VAR-SOM-MX8M-MINI; then if test som_rev = som_rev10; then setenv fdt_file fsl-imx8mm-var-som-rev10.dtb; else setenv fdt_file fsl-imx8mm-var-som.dtb; fi;else setenv fdt_file fsl-imx8mm-var-dart.dtb;fi; fi; image=Image.gz img_addr=0x42000000 initrd_addr=0x43800000 initrd_high=0xffffffffffffffff ip_dyn=yes kboot=booti loadaddr=0x40480000 loadbootscript=load mmc {mmcdev}:{mmcpart} {loadaddr} {bootdir}/{script};
loadfdt=run findfdt; echo fdt_file={fdt_file}; load mmc {mmcdev}:{mmcpart} {fdt_addr} {bootdir}/{fdt_file}
loadimage=load mmc {mmcdev}:{mmcpart} {img_addr} {bootdir}/{image};unzip {img_addr} {loadaddr} loadm4bin=load mmc {mmcdev}:{mmcpart} {m4_addr} {bootdir}/{m4_bin}
m4_addr=0x7e0000
m4_bin=hello_world.bin
mender_altbootcmd=if test {mender_boot_part} = 1; then setenv mender_boot_part 2; setenv mender_boot_part_hex 2; else setenv mender_boot_part 1; setenv mender_boot_part_hex 1; fi; setenv upgrade_available 0; saveenv; run mender_setup mender_boot_kernel_type=booti mender_boot_part=1 mender_boot_part_hex=1 mender_check_saveenv_canary=1 mender_dtb_name=fsl-imx8mm-var-som-rev10-m4.dtb mender_kernel_name=Image.gz mender_pre_setup_commands= setenv bootargs console={console},{baudrate}; if test "{mmcargs}” != “”; then run mmcargs; fi; if test “{videoargs}" != ""; then run videoargs; fi; if test "{optargs}” != “”; then run optargs; fi; if test “{ramsize_check}" != ""; then run ramsize_check; fi; run findfdt; setenv mender_dtb_name {fdt_file}; setenv kernel_addr_r {loadaddr}; mender_saveenv_canary=1 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/mmcblk1p${mender_boot_part}; if test {mender_boot_part} = 1; then setenv mender_boot_part_name /dev/mmcblk1p1; else setenv mender_boot_part_name /dev/mmcblk1p2; 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
mender_try_to_recover=if test {upgrade_available} = 1; then reset; fi mender_uboot_boot=mmc 0:1 mender_uboot_dev=0 mender_uboot_if=mmc mfgtool_args=setenv bootargs console={console},{baudrate} rdinit=/linuxrc clk_ignore_unused mmcargs=setenv bootargs console={console} rootwait rw {cma_size} mmcautodetect=yes mmcblk=1 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; mmcdev=0 mmcpart=1 netargs=setenv bootargs console={console} {cma_size} ip=dhcp nfsroot={serverip}:{nfsroot},v3,tcp 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 ramsize_check; 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; optargs=setenv bootargs {bootargs} ${kernelargs};
ramsize_check=if test sdram_size -le 512; then setenv cma_size cma=320M; else setenv cma_size cma=640M@1376M; fi; runm4bin=if test {m4_addr} = 0x7e0000; then echo Booting M4 from TCM; else echo Booting M4 from DRAM; dcache flush; fi; bootaux ${m4_addr};
script=boot.scr
sd_dev=0
sdram_size=2048
serial#=0d111209dab4b749
soc_type=imx8mm
som_rev=som_rev11
splashdisable=setenv splashfile; setenv splashimage
splashenable=setenv splashfile /boot/splash.bmp; setenv splashimage 0x43100000
splashfile=/boot/splash.bmp
splashimage=0x43100000
splashsourceauto=yes
stderr=serial
stdin=serial
stdout=serial
upgrade_available=0
use_m4=no

However, it is not called by the default bootcmd and if I try ‘run bootcmd_mfg’ it says ## Checking Image at 43800000 ... Unknown image format! because the ‘iminfo’ command cannot find a valid image at ‘initrd_addr’.

I would appreciate your help very much.
djoh

Hello @KTCdjoh welcome to Mender Hub. I’m glad that you are finding it useful.

As for the OP-TEE integration we have not investigated that. As you noticed with Mender, there is no need for a separate boot partition. U-Boot and it’s environment are stored in inter-partition space and no other files are needed. The kernel and DTB are instead loaded from the root filesystem partition making it easy to upgrade them with an OTA deployment.

My guess is the simplest solution would be to simply set MENDER_BOOT_PARTITION_SIZE_MB to something non-zero and then ensure tee.bin is in IMAGE_BOOT_FILES. I don’t know exactly how that file is loaded and processed so you may need to modify the bootcmd some as well.

The downside of that approach is that there is no way to upgrade tee.bin should it be needed.

The proper approach would be to ensure that tee.bin is in the root filesystem somewhere and that the logic in the U-Boot environment that processes it is updated to find the file there.

Drew

2 Likes

Hello @drewmoseley, thanks for your reply.

Just in case you’re interested, here’s the guide by NXP I followed:
https://source.codeaurora.org/external/imx/imx-optee-os/tree/README.md (chapter ‘4.6 Freescale MX6UL EVK’, especially the part ‘Run using U-Boot’ - imx6, I know, just for guidance) and also the link specified therein http://mrvan.github.io/optee-imx6ul

In my understanding, tee.bin is simply loaded and executed before the kernel. It initializes its separate secure environment and then continues to start the kernel in the non-secure world.

I guess I’ll try both approaches and report status, when I’m back from holiday :wink:
But you’re right, the rootfs approach would be better for maintainability.
So far, I completely switched to the boot partition layout without u-boot in the bootsector, which logically didn’t work.

Best regards
djoh

Hello,

I was able to identify and solve the problem:
As I stated above, I added " optee" by a MACHINE_FEATURES_append statement.
I inserted this into my custom image recipe, which seems to be evaluated too late during the build process.
As a result, “imx-atf” and “imx-boot” are built without “optee support”, because it is not part of COMBINED_FEATURES at this point.
Later, COMBINED_FEATURES contains “optee” and so the “packagegroup-optee-imx” is built.

By moving the MACHINE_FEATURES_append statement to “local.conf” everything works fine.
So it was not related to the “tee.bin” file or the mender settings for the boot partition, which I suspected before.

Thanks again and best regards
djoh

1 Like

Hi Drew,

Thank you for this guide. I have been trying to integrate Mender with a Variscite VAR-SOM-MX8M-MINI running B2Qt-Zeus based on :
Yocto: Poky 3.0, BSP: NXP L5.4.3-1.0.0, Linux: lf-5.4.y

Before trying to integrate Mender, I was able to produce a bootable B2Qt image. Then, I added meta-mender-community and meta-mender layers both from the Zeus branches and followed the regular integration approach (updating local.conf and bblayers.conf for sdcard image). However, when i try to compile the image i get this error:

ERROR: Task do_patch in /media/tracoven/Storage/VAR-SOM-MX8-MINI-ZEUS-VAR01/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 /media/tracoven/Storage/VAR-SOM-MX8-MINI-ZEUS-VAR01/sources/meta-variscite-imx/recipes-bsp/u-boot/u-boot-variscite.bb

ERROR: Command execution failed: 1

Any idea why I get this message and how to fix it?

local.conf: (mender section only)

INHERIT += “rm_work”

MENDER_ARTIFACT_NAME = “release-2”
INHERIT += “mender-full”
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = “systemd”
DISTRO_FEATURES_BACKFILL_CONSIDERED = “sysvinit”
VIRTUAL-RUNTIME_initscripts = “”

MENDER_STORAGE_TOTAL_SIZE_MB_imx8mm-var-dart = “13312”
MENDER_IMAGE_BOOTLOADER_FILE_imx8mm-var-dart = “imx-boot-imx8mm-var-dart-sd.bin”
MENDER_IMAGE_BOOTLOADER_BOOTSECTOR_OFFSET_imx8mm-var-dart = “66”

IMAGE_BOOT_FILES_imx8mm-var-dart = “”
MENDER_BOOT_PART_SIZE_MB_imx8mm-var-dart = “0”

IMAGE_FSTYPES_remove = “tar.gz wic.gz wic.bmap mender.bmap sdimg.bmap sdcard.gz wic ext4”

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

MENDER_STORAGE_DEVICE_imx8mm-var-dart = “/dev/mmcblk1”
MENDER_UBOOT_STORAGE_DEVICE_imx8mm-var-dart= “0”
UBOOT_CONFIG_imx8mm-var-dart = “sd”

MACHINE_ESSENTIAL_EXTRA_RDEPENDS = “kernel-image kernel-devicetree”
KERNEL_IMAGETYPE_mender-uboot = “Image”
IMAGE_POSTPROCESS_COMMAND_remove = “do_qbsp_image;”

#MACHINE_EXTRA_RDEPENDS = “u-boot-fw-utils”
#MENDER_BOOT_PART_SIZE_MB_mender-uboot = “16”
#PREFERRED_PROVIDER_u-boot-fw-util= “u-boot-fw-utils-mender-auto-provided”

Thak you :slight_smile:

The integrations we have for Variscite boards use the u-boot-variscite recipe and not the u-boot-imx recipe. Something is changing the configuration in your case; I suspect it is the b2qt layers. You can see the existing recipes here and you will probably need to make a u-boot-imx.bbappend modeled after the existing u-boot-variscite.bbappend.

Drew

Hi Drew

Thank you for the quick reply. Its really appreciated :slight_smile:

I manged to build the image, though I didn’t have to make any changes to u-boot-imx.bbappend nor to u-boot-variscite.bbappend. I just enabled “mender-uboot” feature in the local.conf file (MENDER_FEATURES_ENABLE_append = " mender-image-sd mender-uboot" ). For other Linux distributions (Sumo) I did not have to add this, and the integration was successful, so its a bit strange I had to do it this time.

Nevertheless, even though the image was built successfully, it is not booting. Serial boot messages show this error message: “Bad Linux ARM64 Image magic!”

Here are the full boot messages:

U-Boot SPL 2019.04-lf-5.4.y_v2019.04_var01+gbcdb05a53e (Apr 28 2021 - 08:00:24 +0000)
Normal Boot
Trying to boot from MMC1

U-Boot 2019.04-lf-5.4.y_v2019.04_var01+gbcdb05a53e (Apr 28 2021 - 08:00:24 +0000)

CPU: Freescale i.MX8MMQ rev1.0 1800 MHz (running at 1200 MHz)
CPU: Commercial temperature grade (0C to 95C) at 45C
Reset cause: POR
Model: Variscite VAR-SOM-MX8M-MINI
DRAM: 2 GiB
MMC: FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC… OK
In: serial
Out: serial
Err: serial

BuildInfo:

  • ATF 7b3389d
  • U-Boot 2019.04-lf-5.4.y_v2019.04_var01+gbcdb05a53e

Part number: VSM-MX8MM-101
Assembly: AS2002150192
Production date: 2020 Apr 06
Serial Number: f8:dc:7a:3e:81:ba
flash target is MMC:1
Net: eth0: ethernet@30be0000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot: 0
Bad Linux ARM64 Image magic!

This is the boot environment:

u-boot=> printenv
altbootcmd=run mender_altbootcmd; run bootcmd
arch=arm
baudrate=115200
board=imx8mm_var_dart
board_name=VAR-SOM-MX8M-MINI
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr ${fdtcontroladdr};fi;load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootaa64.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc2 mmc1
bootargs=root=/dev/mmcblk1p1
bootcmd=run mender_setup; setenv bootargs root=${mender_kernel_root} ${bootargs}; if test “${fdt_addr_r}” != “”; then load ${mender_uboot_root} ${fdt_addr_r} /boot/${mender_dtb_name}; fi; load ${mender_uboot_root} ${kernel_addr_r} /boot/${mender_kernel_name}; ${mender_boot_kernel_type} ${kernel_addr_r} - ${fdt_addr_r}; run mender_try_to_recover
bootcmd_mfg=run mfgtool_args;if iminfo ${initrd_addr}; then if test ${tee} = yes; then bootm ${tee_addr} ${initrd_addr} ${fdt_addr}; else booti ${loadaddr} ${initrd_addr} ${fdt_addr}; fi; else echo “Run fastboot …”; fastboot 0; fi;
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_mmc2=devnum=2; run mmc_boot
bootcount=1
bootdelay=1
bootdir=/boot
bootlimit=1
cma_size=cma=640M@1376M
console=ttymxc3,115200 earlycon=ec_imx6q,0x30a60000,115200
cpu=armv8
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
emmc_dev=1
ethaddr=f8:dc:7a:3e:81:ba
ethprime=FEC
fastboot_dev=mmc1
fdt_addr_r=0x43000000
fdt_high=0xffffffffffffffff
fdtcontroladdr=b6d2d7c0
fdtfile=imx8mm-var-som.dtb
findfdt=if test $fdtfile = undefined; then if test $board_name = VAR-SOM-MX8M-MINI; then if test $som_rev = som_rev10; then setenv fdtfile imx8mm-var-som-rev10.dtb; else setenv fdtfile imx8mm-var-som.dtb; fi;else setenv fdtfile imx8mm-var-dart.dtb;fi; fi;
image=Image.gz
img_addr=0x42000000
initrd_addr=0x43800000
initrd_high=0xffffffffffffffff
kboot=booti
kernel_addr_r=0x40480000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x40480000
loadm4bin=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bootdir}/${m4_bin}; cp.b ${loadaddr} ${m4_addr} ${filesize}
m4_addr=0x7e0000
m4_bin=hello_world.bin
mender_altbootcmd=if test ${mender_boot_part} = 1; then setenv mender_boot_part 2; setenv mender_boot_part_hex 2; else setenv mender_boot_part 1; setenv mender_boot_part_hex 1; fi; setenv upgrade_available 0; saveenv; run mender_setup
mender_boot_kernel_type=booti
mender_boot_part=1
mender_boot_part_hex=1
mender_boot_part_name=/dev/mmcblk1p1
mender_check_saveenv_canary=1
mender_kernel_name=Image
mender_kernel_root=/dev/mmcblk1p1
mender_kernel_root_name=/dev/mmcblk1p1
mender_pre_setup_commands= if test “${ramsize_check}” != “”; then run ramsize_check; fi; if test “${mmcargs}” != “”; then run mmcargs; fi; if test “${videoargs}” != “”; then run videoargs; fi; if test “${optargs}” != “”; then run optargs; fi; run findfdt; setenv mender_dtb_name ${fdt_file}; setenv kernel_addr_r ${loadaddr};
mender_saveenv_canary=1
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/mmcblk1p${mender_boot_part}; if test ${mender_boot_part} = 1; then setenv mender_boot_part_name /dev/mmcblk1p1; else setenv mender_boot_part_name /dev/mmcblk1p2; 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
mender_try_to_recover=if test ${upgrade_available} = 1; then reset; fi
mender_uboot_boot=mmc 0:1
mender_uboot_dev=0
mender_uboot_if=mmc
mender_uboot_root=mmc 0:1
mender_uboot_root_name=/dev/mmcblk1p1
mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc clk_ignore_unused
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
mmcdev=0
mmcpart=1
ramsize_check=if test $sdram_size -le 512; then setenv cma_size cma=320M; else setenv cma_size cma=640M@1376M; fi;
runm4bin=if test ${m4_addr} = 0x7e0000; then echo Booting M4 from TCM; else echo Booting M4 from DRAM; dcache flush; fi; bootaux ${m4_addr};
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}…; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootaa64.efi; then echo Found EFI removable media binary efi/boot/bootaa64.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing…; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing…; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing…; fi; done
script=boot.scr
sd_dev=0
sdram_size=2048
serial#=220c1a09dab4b749
soc=imx8m
soc_type=imx8mm
som_rev=som_rev11
stderr=serial
stdin=serial
stdout=serial
upgrade_available=0
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
use_m4=no
vendor=variscite

Environment size: 6623/131067 bytes

After going though posts from people facing similar error:

https://hub.mender.io/t/issue-with-variscite-var-som-mx8m-nano/2840/11
https://hub.mender.io/t/variscite-var-dart-imx8mm-problem/2811

I made a couple of changes to the local.conf according to those posts, but I am still getting the same error message.

local.conf:

INHERIT += “rm_work”

MENDER_ARTIFACT_NAME = “release-2”
INHERIT += “mender-full”
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = “systemd”
DISTRO_FEATURES_BACKFILL_CONSIDERED = “sysvinit”
VIRTUAL-RUNTIME_initscripts = “”

MENDER_STORAGE_TOTAL_SIZE_MB_imx8mm-var-dart = “13312”
#MENDER_IMAGE_BOOTLOADER_FILE_imx8mm-var-dart = “imx-boot-imx8mm-var-dart-sd.bin”
MENDER_IMAGE_BOOTLOADER_FILE_imx8mm-var-dart = “imx-boot”
MENDER_IMAGE_BOOTLOADER_BOOTSECTOR_OFFSET_imx8mm-var-dart = “66”

IMAGE_BOOT_FILES_imx8mm-var-dart = “”
MENDER_BOOT_PART_SIZE_MB_imx8mm-var-dart = “0”

IMAGE_FSTYPES_remove = “tar.gz wic.gz wic.bmap mender.bmap sdimg.bmap sdcard.gz wic ext4”

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

MENDER_STORAGE_DEVICE_imx8mm-var-dart = “/dev/mmcblk1”
MENDER_UBOOT_STORAGE_DEVICE_imx8mm-var-dart= “0”
UBOOT_CONFIG_imx8mm-var-dart = “sd”

MACHINE_ESSENTIAL_EXTRA_RDEPENDS = “kernel-image kernel-devicetree”
KERNEL_IMAGETYPE_mender-uboot = “Image”

IMAGE_POSTPROCESS_COMMAND_remove = “do_qbsp_image;”

MACHINE_EXTRA_RDEPENDS = “u-boot-fw-utils”
IMAGE_BOOT_FILES = “u-boot.bin”
#MENDER_BOOT_PART_SIZE_MB_mender-uboot = “16”
#PREFERRED_PROVIDER_u-boot-fw-util= “u-boot-fw-utils-mender-auto-provided”

Do have any suggestions to how I can fix this problem? Thank you

I think the issue with needing to add mender-uboot explicitly is due to a change in the Mender defaults in the newer branches. It’s possible we need to update the templates for Zeus. It looks like the templates for Dunfell already have that.

You may also want to review the templates to make sure you have all of the required settings.

I think you want to use “zImage” for KERNEL_IMAGETYPE rather than “Image”. I think that may be causing the BADMAGIC error.

Drew

Hi Drew

Thanks you for clarifying. I really appreciate your support :slight_smile:

I went ahead and used the exact configs from the templates, and changed the KERNEL_IMAGETYPE to zImage, but unfortunately I still get the same error ( Bad Linux ARM64 Image magic!) so the kernel is not loaded.

The only thing that kind of worked was to disable mender-uboot and enable mender-grub:

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

By doing so, the kernel was loaded successfully and the board booted to Boot2qt, but took around 2 minutes to finish booting (without mender it took less than a minute). Doing it like this means that u-boot loaded grub, then grub loaded the kernel and this is not what I want. I need u-boot to load the kernel.

The guy from this post had the same problem, and said he solved it by changing the dtb file in u-boot-variscite.bbappend. I did the same but no success :frowning:
https://hub.mender.io/t/variscite-var-dart-imx8mm-problem/2811/13

Any other suggestions how to fix the “Bad Linux ARM64 Image magic!” error?

That error message seems to indicate that it is still trying to use Image format for some reason. Can you run the following:

bitbake -e core-image-minimal | grep -B25 ‘^KERNEL_IMAGETYPE=’

and also run the following from uboot?

env default -a -f
saveenv
printenv

Drew

The command

bitbake -e b2qt-embedded-qt5-image | grep -B25 ‘^KERNEL_IMAGETYPE=’

returns nothing. I modified it and used:

bitbake -e b2qt-embedded-qt5-image 2>&1 | grep ^KERNEL_IMAGETYPE=

which returns:

KERNEL_IMAGETYPE=“Image.gz”

and this was set in the local.conf file. So it seems it is not being set anywhere else.

u-boot=> env default -a -f

Resetting to default environment

u-boot=> saveenv
Saving Environment to MMC… Writing to MMC(1)… OK
u-boot=> printenv
altbootcmd=run mender_altbootcmd; run bootcmd
baudrate=115200
boot_fdt=try
bootcmd=run mender_setup; setenv bootargs root=${mender_kernel_root} ${bootargs}; if test “${fdt_addr_r}” != “”; then load ${mender_uboot_root} ${fdt_addr_r} /boot/${mender_dtb_name}; fi; load ${mender_uboot_root} ${kernel_addr_r} /boot/${mender_kernel_name}; ${mender_boot_kernel_type} ${kernel_addr_r} - ${fdt_addr_r}; run mender_try_to_recover
bootcmd_mfg=run mfgtool_args;if iminfo ${initrd_addr}; then if test ${tee} = yes; then bootm ${tee_addr} ${initrd_addr} ${fdt_addr}; else booti ${loadaddr} ${initrd_addr} ${fdt_addr}; fi; else echo “Run fastboot …”; fastboot 0; fi;
bootcount=0
bootdelay=1
bootdir=/boot
bootlimit=1
bootscript=echo Running bootscript from mmc …; source
console=ttymxc0,115200 earlycon=ec_imx6q,0x30860000,115200
emmc_dev=1
ethprime=FEC
fdt_addr_r=0x43000000
fdt_file=undefined
fdt_high=0xffffffffffffffff
findfdt=if test $fdt_file = undefined; then if test $board_name = VAR-SOM-MX8M-MINI; then if test $som_rev = som_rev10; then setenv fdt_file imx8mm-var-som-rev10.dtb; else setenv fdt_file imx8mm-var-som.dtb; fi;else setenv fdt_file imx8mm-var-dart.dtb;fi; fi;
image=Image.gz
img_addr=0x42000000
initrd_addr=0x43800000
initrd_high=0xffffffffffffffff
ip_dyn=yes
kboot=booti
loadaddr=0x40480000
loadbootscript=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bootdir}/${script};
loadfdt=run findfdt; echo fdt_file=${fdt_file}; load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${bootdir}/${fdt_file}
loadimage=load mmc ${mmcdev}:${mmcpart} ${img_addr} ${bootdir}/${image};unzip ${img_addr} ${loadaddr}
loadm4bin=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bootdir}/${m4_bin}; cp.b ${loadaddr} ${m4_addr} ${filesize}
m4_addr=0x7e0000
m4_bin=hello_world.bin
mender_altbootcmd=if test ${mender_boot_part} = 1; then setenv mender_boot_part 2; setenv mender_boot_part_hex 2; else setenv mender_boot_part 1; setenv mender_boot_part_hex 1; fi; setenv upgrade_available 0; saveenv; run mender_setup
mender_boot_kernel_type=booti
mender_boot_part=1
mender_boot_part_hex=1
mender_check_saveenv_canary=1
mender_dtb_name=imx8mm-var-som.dtb
mender_kernel_name=Image.gz
mender_pre_setup_commands= if test “${ramsize_check}” != “”; then run ramsize_check; fi; if test “${mmcargs}” != “”; then run mmcargs; fi; if test “${videoargs}” != “”; then run videoargs; fi; if test “${optargs}” != “”; then run optargs; fi; run findfdt; setenv mender_dtb_name ${fdt_file}; setenv kernel_addr_r ${loadaddr};
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/mmcblk1p${mender_boot_part}; if test ${mender_boot_part} = 1; then setenv mender_boot_part_name /dev/mmcblk1p1; else setenv mender_boot_part_name /dev/mmcblk1p2; 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
mender_try_to_recover=if test ${upgrade_available} = 1; then reset; fi
mender_uboot_boot=mmc 0:1
mender_uboot_dev=0
mender_uboot_if=mmc
mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc clk_ignore_unused
mmcargs=setenv bootargs console=${console} rootwait rw ${cma_size}
mmcautodetect=yes
mmcblk=1
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;
mmcdev=0
mmcpart=1
netargs=setenv bootargs console=${console} ${cma_size} ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
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 ramsize_check; 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;
optargs=setenv bootargs ${bootargs} ${kernelargs};
ramsize_check=if test $sdram_size -le 512; then setenv cma_size cma=320M; else setenv cma_size cma=640M@1376M; fi;
runm4bin=if test ${m4_addr} = 0x7e0000; then echo Booting M4 from TCM; else echo Booting M4 from DRAM; dcache flush; fi; bootaux ${m4_addr};
script=boot.scr
sd_dev=0
upgrade_available=0
use_m4=no

Environment size: 4900/131067 bytes

You need to use zImage instead of Image.gz for the KERNEL_IMAGETYPE.
Drew

My mistake. Actually in the local.conf I have set KERNEL_IMAGETYPE=“zImage” but yocto still packages Image.gz instead. I searched all files where this change can be happening and found only one file where it was set to “Image.gz” and that was “variscite.inc”. In this file there is this line:

KERNEL_IMAGETYPE_mx8 = “Image.gz”

I changed it to zImage, but when I complied the kernel I got this error message:

| make[1]: *** No rule to make target ‘zImage’. Stop.

I Googled this error message and found this interesting answer:

No, it isn’t possible to build a zImage for ARM64 platforms (such as the i.MX8MQ).

That is because it was decided in Linux not to add zImage support, so there’s no way around it.

https://community.nxp.com/t5/i-MX-Processors/how-to-build-zImage-for-i-mx8mq/td-p/813439

How can we work around this issue?

Many thanks and appreciation for your help :slight_smile:

Oops, of course. Image is the correct type for 64-bit arm. Sorry about the diversion.

I think the issue is that you need to decompress the Image.gz file. It’s not handled automatically.

As a quick test you can try changing it to “Image” just to see if that gets past the “Bad Magic” issue but I suspect it will be fairly slow loading the kernel in that format.

You can see here how the decompression is handled in the Toradex integration. Presumably something similar will need to be done here for the Variscite platforms.

Drew

Initially I had it set to “Image”. If you look at the serial boot output in my post on 28.04.2021 you can see it set to Image. But I was seeing the same “Bad Magic” issue even then.

Just to clarify, before I attempted to integrate mender the original Boot2Qt was using “Image.gz” kernel type and there was no problem decompressing the kernel then. The board booted successfully.

Dang. In that case, I don’t have any other ideas and no longer have access to the hardware to try and replicate. Hopefully, other community members may have some ideas.

Thank you Drew for trying to help. I will post this issue as a new topic on Mender hub so that others can see it.
Best regards,
Adam

Is there some roadpmap to update this layer to dunfell LTS poky release? Seems to be up to date to thud/warrior only. Thanks.

5 posts were split to a new topic: Fail to build Yocto image for imx8mm-var-dart