Issues Booting Cortex-M4 and SPI Device Not Found After Torizon OS 7 Update

Hello,

I recently updated my system to Torizon OS 7 and encountered two major issues when trying to run my application on the Cortex-M4 and enable SPI communication.

Issue 1: Cortex-M4 Program Prevents System Booting

I have a project where I load a program onto the Cortex-M4 and communicate with it via rpmsg from Linux. The setup worked perfectly on Torizon OS 6, but after upgrading to Torizon OS 7, the system fails to boot whenever I load my M4 program. The kernel does not start, and the board continuously reboots.

I also tried running the Hello World example from the MCUXpresso SDK, but it resulted in the same issue. However, when I remove the uploaded program form U-Boot, the system boots normally.

I followed these instructions for loading the M4 firmware:

How to Load Binaries on Cortex-M
Hello World Cortex-M Example

Issue 2: SPI Device Missing Under /sys/bus/spi/devices

After updating to Torizon OS 7 and applying my device tree overlay, I am no longer able to find the SPI device under /sys/bus/spi/devices.

Here is my device tree overlay:

/dts-v1/;
/plugin/;

/ {
	compatible = "toradex,colibri-imx8x-eval-v3";
};

&lpspi2 {
	status = "okay";
	spi-slave; 

	slave@0 { 
		compatible = "toradex,evalspi";
		reg = <0>; // Chip select 0
		spi-max-frequency = <2000000>; 
		spi-cpha; // Clock phase
		spi-cpol; // Clock polarity
		status = "okay";
	};
};

&mcp2515 {
	status = "disabled";
};

This exact setup worked on Torizon OS 6, but now the SPI device does not appear under /sys/bus/spi/devices.

Has anyone encountered similar issues after updating to Torizon OS 7?
Any insights on what changes might be affecting the M4 boot process or SPI device detection?

Software and Hardware infos:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           6.6.54-7.1.0-g3493ccd66900 #1-Torizon SMP PREEMPT Tue Dec 17 21:04:41 UTC 2024
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.0/torizon/73741213d16339fd40639896f377654090019de0802df51ff67e7c55e2ef3b44/0
Distro name:              NAME="Torizon OS"
Distro version:           VERSION_ID=7.1.0-build.4
Distro variant:           VARIANT="Docker"
Hostname:                 colibri-imx8x-15339097
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Colibri iMX8QXP on Colibri Evaluation Board V3
Toradex version:          0038 V1.0E
Serial number:            15339097
Processor arch:           aarch64
------------------------------------------------------------

Thanks in advance for your help!

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

Thank you for reaching out with your concerns. Let’s address each of your issues with Torizon OS 7.

Issue 1: Cortex-M4 Program Prevents System Booting

The boot issue with the Cortex-M4 program might be due to changes in Torizon OS 7. Here are some steps to consider:

  1. Compatibility Check: Verify that your M4 firmware is compatible with Torizon OS 7. Changes in the bootloader or kernel might affect M4 initialization.

  2. Configuration Review: Double-check your U-Boot configuration, ensuring memory regions and boot parameters are correctly set for the new OS version.

  3. Logs and Debugging: Try to capture any boot logs or error messages when the M4 program is loaded. These logs can provide insights into the reboot issue.

  4. Example Programs: Since the Hello World example also fails, check for any updates or patches in the MCUXpresso SDK that might address compatibility with Torizon OS 7.

Issue 2: SPI Device Missing Under /sys/bus/spi/devices

For the missing SPI device, consider the following:

  1. Device Tree Overlay: Ensure your device tree overlay is correctly applied. There might be changes in the overlay format or requirements in Torizon OS 7.

  2. Kernel Changes: Review any changes in the kernel configuration or SPI driver support that might affect SPI device registration.

  3. SPI Configuration: Confirm that the SPI bus and devices are correctly configured in the device tree, with the status set to “okay.”

  4. Testing with Containers: If using containers, ensure the SPI device is accessible within the container. You may need to adjust permissions or use the --device flag to expose the SPI device.

I hope these suggestions help you resolve the issues with your Cortex-M4 and SPI device on Torizon OS 7. If you have further questions, feel free to ask.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

Device Tree Overlays on Torizon | Toradex Developer Center.

sure I also update the bootloader to the suggested version as here

here are the booting logs after starting the M4 program once and booting into linux

Colibri iMX8X # setenv load_cmd "ext4load mmc 0:1"
Colibri iMX8X # setenv m4_0_image "/ostree/deploy/torizon/var/hello_world.bin"
Colibri iMX8X # setenv loadm4image_0 ${load_cmd} ${loadaddr} ${m4_0_image}
Colibri iMX8X # saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
Colibri iMX8X # run m4boot_0
16088 bytes read in 5 ms (3.1 MiB/s)
Power on aux core 0
Copy image from 0x95c00000 to 0x34fe0000
Start M4
bootaux complete
Colibri iMX8X # boot
switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
969 bytes read in 3 ms (315.4 KiB/s)
## Executing script at 9d480000
7599 bytes read in 5 ms (1.4 MiB/s)
122344 bytes read in 8 ms (14.6 MiB/s)
239 bytes read in 5 ms (45.9 KiB/s)
Working FDT set to 9d400000
Applying Overlay: colibri-imx8x_vga-640x480_overlay.dtbo
2222 bytes read in 5 ms (433.6 KiB/s)
Applying Overlay: colibiri-imx8x_disable-lpuart2.dtbo
404 bytes read in 6 ms (65.4 KiB/s)
Applying Overlay: colibri-imx8x_disable-cm40-uart_overlay.dtbo
412 bytes read in 5 ms (80.1 KiB/s)
Applying Overlay: colibri-imx8x_disable-uart0_overlay.dtbo
404 bytes read in 6 ms (65.4 KiB/s)
Applying Overlay: colibri-imx8x_hmp_overlay.dtbo
1321 bytes read in 5 ms (257.8 KiB/s)
Applying Overlay: colibri-imx8x_spidev_overlay.dtbo
586 bytes read in 5 ms (114.3 KiB/s)
11342096 bytes read in 262 ms (41.3 MiB/s)
13127163 bytes read in 303 ms (41.3 MiB/s)
   Uncompressing Kernel Image to 0
## Flattened Device Tree blob at 9d400000
   Booting using the fdt blob at 0x9d400000
Working FDT set to 9d400000
   Loading Device Tree to 00000000fd633000, end 00000000fd673fff ... OK
Working FDT set to fd633000

Starting kernel ...

[    1.584215]  mu_a1: failed to power off resource 214 ret -22


U-Boot 2024.04-7.0.0+git.22d100d163d8 (Jan 01 1970 - 00:00:00 +0000)

CPU:   NXP i.MX8QXP RevC A35 at 1200 MHz at 50C

DRAM:  2 GiB
Core:  248 devices, 24 uclasses, devicetree: separate
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Model: Toradex 0038 Colibri iMX8QXP 2GB WB IT V1.0E
Serial#: 15339097
Boot:  MMC0
Reset cause: SCFW fault reset

 BuildInfo:
  - SCFW f407904f, SECO-FW c9de51c0, IMX-MKIMAGE ca5d6b2d, ATF 9ce177d
  - U-Boot 2024.04-7.0.0+git.22d100d163d8

flash target is MMC:0
Net:   eth0: ethernet@5b040000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
969 bytes read in 3 ms (315.4 KiB/s)
## Executing script at 9d480000
7599 bytes read in 5 ms (1.4 MiB/s)
122344 bytes read in 9 ms (13 MiB/s)
239 bytes read in 5 ms (45.9 KiB/s)
Working FDT set to 9d400000
Applying Overlay: colibri-imx8x_vga-640x480_overlay.dtbo
2222 bytes read in 5 ms (433.6 KiB/s)
Applying Overlay: colibiri-imx8x_disable-lpuart2.dtbo
404 bytes read in 6 ms (65.4 KiB/s)
Applying Overlay: colibri-imx8x_disable-cm40-uart_overlay.dtbo
412 bytes read in 5 ms (80.1 KiB/s)
Applying Overlay: colibri-imx8x_disable-uart0_overlay.dtbo
404 bytes read in 6 ms (65.4 KiB/s)
Applying Overlay: colibri-imx8x_hmp_overlay.dtbo
1321 bytes read in 5 ms (257.8 KiB/s)
Applying Overlay: colibri-imx8x_spidev_overlay.dtbo
586 bytes read in 5 ms (114.3 KiB/s)
11342096 bytes read in 262 ms (41.3 MiB/s)
13127163 bytes read in 302 ms (41.5 MiB/s)
   Uncompressing Kernel Image to 0
## Flattened Device Tree blob at 9d400000
   Booting using the fdt blob at 0x9d400000
Working FDT set to 9d400000
   Loading Device Tree to 00000000fd634000, end 00000000fd674fff ... OK
Working FDT set to fd634000

Starting kernel ...

[    1.604893]  mu_a1: failed to power off resource 214 ret -22
Starting systemd-udevd version 255.13^
sysroot.readonly configuration value: 0 (fs writable: 1)
Using legacy ostree bind mount for /
[   16.028659] Bluetooth: hci0: unexpected event for opcode 0x0000


This device was successfully paired on Torizon Cloud!

if I do setenv bootcmd "run m4boot_0; ${bootcmd}" then the system keep rebooting

Greetings @adel7b,

I did some testing on my side. I used a Colibri i.MX8X and flashed the latest Torizon OS 7.1.0 release for reference.

For issue 1, I seem to be able to reproduce the same results as you. There’s probably something that needs to be adjusted or examined in the newer underlying BSP. I will need to report this internally for further investigation.

For issue 2. First of all you roverla for SPI seems “old”. Our current overlay to enable spidev looks like this: colibri-imx8x_spidev_overlay.dts « overlays - device-tree-overlays.git - Sources for Device Tree Overlays

When I apply this overlay I can see the spi just fine:

torizon@colibri-imx8x-06750825:~$ ls /sys/bus/spi/devices/spi0.0/
driver  driver_override  modalias  of_node  power  spidev  statistics  subsystem  uevent

I have the other M4 related overlays applied alongside the spidev overlay, so that doesn’t seem to cause any issues or conflicts.

Best Regards,
Jeremias

1 Like