IMX7D M4 freeze when booting Linux

I attempt boot firmware on Cortex-M4 core but there is problem: it freezes when booting Linux kernel.

I use Iris board v1.1 and Colibri iMX7D 1GB module.

I have installed Linux Console Image and then rebuild Linux Kernel from git repository:

git clone -b toradex_5.4-2.1.x-imx git://git.toradex.com/linux-toradex.git

If I use 4.14 kernel from this branch: git clone -b toradex_4.14-2.3.x-imx git://git.toradex.com/linux-toradex.git then Cortex-M4 works perfectly.

In any case I have used standard config:

make colibri_imx7_defconfig 

and standard dts-file:

make DTC_FLAGS="-@" imx7d-colibri-emmc-iris.dtb

Compiler: gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf

This commands I have also executed in U-boot:

 Colibri iMX7 # setenv fdt_fixup 'fdt addr ${fdt_addr_r} && fdt rm /soc/aips-bus@30800000/spba-bus@30800000/serial@30890000'
 Colibri iMX7 # saveenv

Code, running on Cortex-M4 (and hardware_init.c from freertos-colibri-imx7/examples/imx7_colibri_m4/demo_apps/rpmsg/str_echo_bm example):

#include "string.h"
#include "assert.h"
#include "board.h"
#include "mu_imx.h"
#include "debug_console_imx.h"

int main(void)
{
	hardware_init();
	/* Print the initial banner */
	PRINTF("\r\nRPMSG String Echo Bare Metal Demo...\r\n");

	uint32_t volatile tick = 0;

	__disable_irq();
	for (;;) {
		if (++tick == 500000) {
			tick = 0;
			PRINTF("a\r\n");
		}
    }
}

The call __disable_irq() is inserted to exclude just in case situation of hanging in IRQ handler.
In case of use 5.4 kernel printing “a” ceases after some iteration, in case of use 4.14 kernel printing goes on.
Do you have any idea how to solve this issue?

Could you provide a full compilable code for M4? Which exactly images you are referring as 4.14 and 5.4 kernels? Are you starting any additional app/services at Linux side?

Yes, here it is: link text. This is source code + necessary freertos files.

Compiler: gcc-arm-none-eabi-10-2020-q4-major.

The 5.4 kernels I have taken from toradex git branches: toradex_5.4-2.1.x-imx and toradex_5.4-2.3.x-imx.

Right now I use kernel 5.4.77-31031-g322691f7b572 from toradex_5.4-2.1.x-imx.
4.14 kernel is from toradex_4.14-2.3.x-imx branch.

I have only configured network by creating file /etc/systemd/network/ and I have not started any app/services.

@mst31,

Which BSP and U-Boot versions are you using?

Does the default hello_world demo app work?

U-Boot 2019.07-3.0.4+g26d926eda0 (Apr 17 2020 - 15:39:59 +0000)
I tried two versions of BSP: 5.0.0 / 5.1.0 and 5.2.0.
Hello_world demo from here:
https://developer.toradex.com/files/toradex-dev/uploads/media/Colibri/FreeRTOS/Binaries/Colibri_iMX7_M4_FreeRTOS_V1.0.1_20160809.tar.gz
prints “Hello World!” one time.
But my code sample in question also works for 1-2 seconds while Linux booting.
Also if I do run Cortex-M4 only in U-boot

run m4boot

then there is no freezing.

Did you add clk_ignore_unused to U-Boot defargs variable?

Yes. In attachment my modified uEnv.txt filelink text

Another I added command:
setenv fdt_fixup ‘fdt addr ${fdt_addr_r} && fdt rm /soc/aips-bus@30800000/spba-bus@30800000/serial@30890000’

Well, I don’t know then. But without clk_ignore_unused I have similar symptoms like you, Linux starts and soon M4 stops sending to serial1 (serial@30890000). In contrast if I instead don’t fdt rm serial1, then M4 keeps running but Linux panics and dies.

Sorry, I mentioned wrong BSP version to you. I use this version:
https://docs.toradex.com/107509-colibri-imx7-emmc_console-image-tezi.tar

@mst31,

Can you please try your application again with a latest nightly of our Linux BSP (version 5.2.0)?

You should be able to install that from the CI feeds on the Toradex Easy Installer or by downloading it manually.

I have tried to install BSP version 5 and to run application on Cortex-M4. Now Cortex-M4 works normally, but Linux hangs on “Starting kernel…”

  1. BSP was taken from here: https://artifacts.toradex.com/artifactory/tdxref-oe-prerelease-frankfurt/dunfell-5.x.y/monthly/8/colibri-imx7-emmc/tdx-xwayland/tdx-reference-minimal-image/oedeploy/Colibri-iMX7-eMMC_Reference-Minimal-Image-Tezi_5.2.0-devel-202103+build.8.tar I installed it using USB-Flash and Toradex Easy Installer. In file u-boot-initial-env I changed variable fdt_board to iris.

  2. Elf-file for Cortex-M4 I compiled from source mentioned above. Then I
    copied it over scp and installed following:

    cd /tmp

    mkdir data

    mount /dev/mmcblk0p1 ./data

    cp ./testproject.elf ./data/cortex-m4.elf

    umount ./data

    sync

  3. U-boot settings:

    setenv defargs clk_ignore_unused

    setenv m4boot ‘fatload mmc 0:1 ${loadaddr} cortex-m4.elf && bootaux ${loadaddr}’

    saveenv

@mst31,

What is your M4 application doing? Could you please share your binary so I cant test this on my side?

Also, can you try the hello-world example just to validate? That works on my side.

This is binary: link text
and their source: https://share.toradex.com/0vha4cbzl3rf1jg?direct
Application simply prints string “a” periodically.

Hello-world from here: https://developer.toradex.com/files/toradex-dev/uploads/media/Colibri/FreeRTOS/Binaries/Colibri-iMX7-M4_FreeRTOS_1.2-20170407.zip
works and prints “Hello World!”, but Linux side hangs too.

UART_B on Linux was disabled in both cases:

setenv fdt_fixup 'fdt addr ${fdt_addr_r} && fdt rm /soc/aips-bus@30800000/spba-bus@30800000/serial@30890000'

@mst31,

Thanks for your feedback. I’ll try this on my side and let you know.

Hello!
As a result? Were you able to get this error?

mst31, check to see if fdt_fixup is being called as you expected. I’m working in a recent setup like yours and it looks like this part of the script environment got changed somehow. I can’t get this stuff to boot either, but manually modifying the DTB gets me closer.

If you dig into the BSP5 release notes, fdt_fixup has been removed from BSP5. Search on ELB-2710.

So the Toradex documentation here to remove the &uart2 node is obsolete. We need to figure out how to use the new overlay system to remove a node, or manually add fdt_fixup back into the uboot environment / boot.scr.

@lkoziarz,

The most elegant way to “remove” a node using overlays would be to effectively disable it, e.g.

&uart2 {
    status = "disabled";
};

This should have the same effect as manually removing a node on the device tree.

@gustavo.tx,

Could you please provide a reference .dtbo for BSP5 to allow us to try this? In my trials with the latest kernel, even removing UART2 does not allow the kernel to boot. Others have mentioned this on this forum as well.

Many of us, especially Qt/Yocto customers, can’t use BSP2.8, and as far as we can see that was the last version that has a working example of A7/M4 working together.

I also had some issues running both cores with the BSP 5 with the iMX7. Instead of BSP 2.8 or 5, I fell back to the BSP 3.0.4.

toradex_4.14-2.3.x-imx

https://developer.toradex.com/knowledge-base/build-u-boot-and-linux-kernel-from-source-code#tab-imx7