I tested 2 images, one created by Yocto and the second from pre-built image of below nxp.com site, and on both them, the demo rebooted the M4 partition correctly, without crashing the system, thus we can conclude the demo is fine.
i.MX 8QuadXPlus Multisensory Enablement Kit | NXP
I suspect the way you're creating the boot container could be leading to the problem. Please follow the below step-by-step and let me know if it works for you.
1- On mkimage make sure to checkout the correct branch, I'm using the rel_imx_4.14.98_2.0.0_ga.
root@ubuntu:~/hd/nxp/imx-mkimage$ git checkout rel_imx_4.14.98_2.0.0_ga
2 - According to the document i.MX_Linux_User's_Guide.pdf:
To boot a Linux image on i.MX 8QuadMax and i.MX 8QuadXPlus, four elements are needed:
• Bootloader (imx-boot built by imx-mkimage), which includes U-Boot, Arm Trusted Firmware, DCD file, System
controller firmware, and the SECO firmware since B0.
• Arm Cortex-M4 image
• Linux kernel image (Image built by linux-imx)
• A device tree file (.dtb) for the board being used
• A root file system (rootfs) for the particular Linux image
3 - So let's just concentrate on the 2 first elements, the bootloader and the M4 image:
Copy below files from your compiled directory, or for testing purpose, you can use the bin files from Yocto. The files must be copied to the folder /imx-mkimage/iMX8QX/
cp scfw_tcm.bin ~/hd/nxp/imx-mkimage/iMX8QX
cp u-boot-spl.bin-imx8qxpmek-sd ~/hd/nxp/imx-mkimage/iMX8QX/u-boot-spl.bin
cp u-boot-imx8qxpmek.bin-sd ~/hd/nxp/imx-mkimage/iMX8QX/u-boot.bin
cp bl31-imx8qx.bin ~/hd/nxp/imx-mkimage/iMX8QX/bl31.bin
cp mx8qx-ahab-container.img ~/hd/nxp/imx-mkimage/iMX8QX
Then copy the desired M4 image:
cp imx8qx_m4_TCM_srtm_demo.bin ~/hd/nxp/imx-mkimage/iMX8QX/m4_image.bin
*note that some files were renamed during the copy.
4 - Run the make for target on the imx-mkimage folder (tip: if you run just make, you will see all the options)
root@ubuntu:~/hd/nxp/imx-mkimage$ make SOC=iMX8QX flash_linux_m4
5 - Your boot + M4 image is ready to be flashed on sdcard:
root@ubuntu:~/hd/nxp/imx-mkimage$ sudo dd if=iMX8QX/flash.bin of=/dev/<SD card device> bs=1K seek=32 conv=fsync