PCM052: M4 crashes when accessing SPI3_MCR while kernel 3.13 is running on the A5

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PCM052: M4 crashes when accessing SPI3_MCR while kernel 3.13 is running on the A5

Jump to solution
1,430 Views
mpfgregory
Contributor III

The following scenario crashes the Cortex-M4 on my PCM052:

In the MQX BSP 4.0.1 in init_gpio I do:

SPI3_MCR &= ~((0x3 << 28) | (0x1 << 14)); // DSPI to 0x00 & enables module clock

in order to enable SPI3. This works fine if kernel 3.0 is running on the A5 or the A5 is idle. However, if kernel 3.13 is running on the A5, the A4 crashes here. It looks like I can't access the memory mapped register SPI3_MCR (address 0x400AD000u). If I do:

volatile int i = SPI3_MCR;

it also crashes. I have disabled the SPI and SPI_NOR drivers in the kernel. It works fine for SPI0:

SPI0_MCR &= ~((0x3 << 28) | (0x1 << 14));

-> no crash, SPI0 works as expected.

I have no idea which part of the kernel blocks the register access from the M4.

Labels (3)
1 Solution
1,082 Views
timesyssupport
Senior Contributor II

Hello,

Perhaps the Linux kernel setting the dspi3 clock gate register could be causing issues - this can be removed/disabled by removing line 228 (clk [VF610_CLK_DSPI3] =...) in build_*/linux-3.13/arch/arm/mach-imx/clk-vf610.c; if you're building using Timesys Factory, you can then issue: make kernel-restage && make to rebuild the kernel. Boot with that change and see if the behavior is different.

Thank you,

Timesys Support

View solution in original post

11 Replies
1,082 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

When the A5 is Idle you mean that is in a low power mode? Or before running Linux?

timesyssupport​, Do you know which part of the kernel has to be modified?

Best Regards,

Alejandro

0 Kudos
1,082 Views
mpfgregory
Contributor III

Not in low power mode, just without the SD-card and thus without a valid boot loader.

0 Kudos
1,082 Views
timesyssupport
Senior Contributor II

Hello,

If there is not a bootloader present, what is loading and executing the kernel/dtb?

Thanks,

Timesys Support

0 Kudos
1,082 Views
mpfgregory
Contributor III

There is the standard u-boot that loads the kernel and dtb. The Linux itself runs fine. But if I load a program to the M4, either by mqxboot or by connecting via USB (CMSIS-DAP) and I access address 0x400AD000u from the M4, the M4 crashes, while the Linux on the A5 continues to run normally. This does not happen with kernel 3.0.

0 Kudos
1,083 Views
timesyssupport
Senior Contributor II

Hello,

Perhaps the Linux kernel setting the dspi3 clock gate register could be causing issues - this can be removed/disabled by removing line 228 (clk [VF610_CLK_DSPI3] =...) in build_*/linux-3.13/arch/arm/mach-imx/clk-vf610.c; if you're building using Timesys Factory, you can then issue: make kernel-restage && make to rebuild the kernel. Boot with that change and see if the behavior is different.

Thank you,

Timesys Support

1,082 Views
mpfgregory
Contributor III

This fixed it. Thanks a lot!

When developing the Linux BSP please keep in mind that all peripherals might also be used by the M4. When I disable a peripheral in the kernel config I expect its registers to stay untouched. You already did it for SPI0:

if (of_property_read_bool(np, "vf610-dspi0"))
   clk[VF610_CLK_DSPI0] = imx_clk_gate2("dspi0", "ipg_bus", CCM_CCGR0, CCM_CCGRx_CGn(12));

I think it makes sense to do it similarly for the other peripherals.

0 Kudos
1,082 Views
timesyssupport
Senior Contributor II

Hello,

Good to hear that this resolved the issue - I will pass along your suggestion to our Vybrid developers.

Thank you,

Timesys Support

1,082 Views
karina_valencia
NXP Apps Support
NXP Apps Support

timesyssupport​ please continue with the follow up.

0 Kudos
1,082 Views
karina_valencia
NXP Apps Support
NXP Apps Support

mpfgregory​ did you get previous comment?

0 Kudos
1,082 Views
karina_valencia
NXP Apps Support
NXP Apps Support

alejandrolozano​ please continue with the follow up

0 Kudos
1,082 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

I wonder if timesyssupport​ can add some comments? The behavior is changed with different kernel versions.

/Alejandro

0 Kudos