Only one CPU for iMX7D running

Hi, I switched to BSP 5.7.2 (mainline kernel) and now I am wondering, why only one CPU is running. In previous setup (BSP 5.6.0 - not mainline kernel) two CPUs were used.

Used Setup

  • Colibri iMX7D 1 GB V1.1A
  • Kernel 5.4.193-5.7.2-devel+git.f5d73fd6e9f8
  • Based on Toradex BSP Layers and Reference Images for Yocto Project 5.7.2

This is, what I get with following command:

~$ cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 5 (v7l)
BogoMIPS        : 48.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 5

Hardware        : Freescale i.MX7 Dual (Device Tree)
Revision        : 0000
Serial          : 06805514

And this is what dmesg prints out:

~$ dmesg | grep CPU
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[    0.003252] CPU: Testing write buffer coherency: ok
[    0.008055] smp: Bringing up secondary CPUs ...
[    0.008743] smp: Brought up 1 node, 1 CPU
[    0.008764] CPU: All CPU(s) started in SVC mode.
[    1.723740] CPUidle arm: CPU 0 failed to init idle CPU ops
[    2.051202] imx_thermal tempmon: Extended Commercial CPU temperature grade - max:105C critical:105C passive:95C

When comparing with previous BSP (BSP 5.6.0) following gets printed:

~# dmesg | grep CPU
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[    0.003868] CPU: Testing write buffer coherency: ok
[    0.009074] smp: Bringing up secondary CPUs ...
[    0.010125] smp: Brought up 1 node, 2 CPUs
[    0.010170] CPU: All CPU(s) started in HYP mode.
[    0.010184] CPU: Virtualization extensions available.
[    2.589169] imx_thermal tempmon: Extended Commercial CPU temperature grade - max:105C critical:105C passive:95C

Can anyone help me setting up my configuration so that both CPUs are activated? Thanks.

Rob

Hi @Robbie!

Was this test done with a default (unchanged) Reference Image from Toradex?

If yes, could you point which link you used to download from Toradex Download Links (Torizon, Yocto Project Reference Images, WinCE and Partner Demos) | Toradex Developer Center?

If not, please try with a default (unchanged) Reference Image 5.7.2 from Toradex.

Best regards,

Thanks for your quick response.

I tested it with the original (unchanged) Reference Image from Toradex and the result is as expected: Two CPUs are running. So there must be something maybe within the bootloader? When I compare the dmesg outputs (BSP 5.6.0 vs 5.7.2) I see following difference:

smp: Brought up 1 node, 1 CPU
[ 0.008764] CPU: All CPU(s) started in SVC mode.

smp: Brought up 1 node, 2 CPUs
[ 0.010170] CPU: All CPU(s) started in HYP mode.

I do not know what the difference between “SVC” and “HYP” is but maybe this is the reason for it?

Hi @Robbie !

Just to be really clear: you did test both 5.7.2 and 5.6.0 Reference Images from Toradex with no modification on any of both images, right?

Best regards,

Hi @henrique.tx,

We were using a customized BSP Version 5.6.0 → both CPUs were active (good).
Then we switched to a customized BSP version 5.7.2 → only one CPU is active (not good).

And then to verify if the problem occurs on an unmodified BSP 5.7.2 I downloaded the following image. With this image → both CPUs are active (good): https://artifacts.toradex.com/ui/repos/tree/General/tdxref-oe-prod-frankfurt%2Fdunfell-5.x.y%2Frelease%2F21

I hope it makes a little bit clearer now?

Rob

Hello @Robbie,

What customizations are you doing on the image?
Since it works with our unmodified reference image, it looks like the root of the cause could be somewhere in your customization.

Hello @rudhi.tx,

I agree that it has something to do with our customization.

We added some layers, deactivate not needed packages etc. Nothing special (at least I do not see what could have the effect to deactivate one CPU).

But I think I found a solution. In this thread it is mentioned, to set the U-Boot variable bootm_boot_mode=nonsec. So I tried this and now there are 2 CPUs again.

But one thing still makes me unsure. Is it safe to set bootm_boot_mode=nonsec (it was set to bootm_boot_mode=sec before)? This was not necessary in our previous (5.6.0) customization. Any idea?

Thanks.
Rob

Hi @Robbie !

I do not have much information about secure stuff…

I found some links about Arm processor modes:

  1. ARM Processor Modes | Stephen Smith's Blog
  2. U-Boot/Linux and HYP mode on ARMv7 – yet another tech blog
  3. linux - What is the Hypervisor mode in arm? - Stack Overflow

Does it help you?

Best regards,

Hi @henrique.tx ,

Thanks for providing the links. I will read through the links and get back to you.
But I would feel much better if I could switch back to SVC mode (bootm_boot_mode=sec as it was before). Unfortunately I don’t know in which config file I should adjust something to accomplish this (have SVC mode with both active CPUs).
Any help would be appreciated.

Thanks.
Robert

Hi @Robbie !

Could you please share specifically which modification you performed that causet this Arm processor mode change?

Best regards,

Yes, I could share this, but I’m not sure which of those changes matter.
Essentially it’s the addition of a new custom meta layer, changes to the device tree have been made, and changes to the bootloader and kernel config. However, no changes were made to the other meta-xxx layers (meta-freescale, meta-openembedded, meta-toradex-nxp etc.).
I can’t tell which of these changes matters either.
Maybe you can tell me which areas are important?

Thanks.
Rob

Hi

Potentially, all of them :sweat_smile:

Best regards,

Okay. I’ll read through the provided links and give you feedback. I’ll also check the differences between the kernel configs. Maybe I’ll find something promising.

Thanks.
Rob

I have looked again at the difference of the bootloader between the unchanged BSP 5.7.2 and our BSP. Here I noticed that in the unmodified BSP the variable bootm_boot_mode is also set to ‘nonsec’. This explains why both CPUs are active in the unmodified BSP!
Question: Do you have a reason why in the original BSP this variable is set to ‘nonsec’ instead of ‘sec’?
In this thread it is mentioned that the mainline kernel boots in the non-secure world. It also mentions that if a mainline kernel is used, then a mainline U-Boot should also be used with PSCI support enabled for the mx7. Can you tell me how to enable this? How can a mainline U-Boot be used? Then I could set the variable back to ‘bootm_boot_mode=sec’ and both CPU would run probably…

Thanks for your support.
Rob

Hi @Robbie!

Here goes quite a lengthy answer written with @rafael.tx’s aid. Hopefully, it helps to understand this boot mode stuff.

About bootm_boot_mode on upstream and downstream kernel

Historically, the downstream kernel boots with bootm_boot_mode=sec (and controls itself the 2nd core), and the upstream kernel boots with bootm_boot_mode=nonsec (and uses PSCI to control the 2nd core).

Unfortunately, I do not have information on why it is like this. One could try to dig into the mailing lists and find out why Upstream chose to do like this (getting this kind of information from NXP will probably be way harder).

One possible explanation could be that having the kernel booting with the processor in a less privileged mode is usually considered a good approach.

About this:

Could you please specify if you are using upstream/downstream on both?

Differences between upstream and downstream kernel for Colibri iMX7

Regarding boot mode

From our documentation, we can see that U-Boot is the same regardless of using kernel upstream or downstream (Build U-Boot and Linux Kernel from Source Code | Toradex Developer Center). The difference we have (nonsec vs sec) for BSP 5 comes from a patch within Toradex’s BSP:

It is applied on the recipe u-boot-toradex_toradex-2020.07.bb only for Colibri iMX7 with upstream (mainline) kernel:

Regarding PSCI

You can see some PSCI-related configurations from the device tree from the upstream kernel:

You can also see that cpu0 and cpu1 have the cpu-idle-states on upstream:

But not from downstream:

Sumarizing

When using upstream, bootm_boot_mode is used as nonsec. Having boot mode as sec doesn’t mean secure boot. It only means that the kernel is booting in a higher privileged state.

Let us know if this helps you :slight_smile:

Best regards,

Thank you very much for the detailed explanation. This helps a lot…

For the BSP 5.6.0 we were using downstream and for the BSP 5.7.2 we were using upstream.

But in the meantime I realized that with BSP 6.2.0 bootm_boot_mode is set to sec. So we will try to switch to this version of the BSP.

So again, thank you very much for your effort and you can close this ticket.

Thanks.

Rob

Hi @Robbie !

From what I could see, that’s actually true! I didn’t know about that :sweat_smile:

I tried to boot using sec (default) and nonsec (setenv bootm_boot_mode nonsec in U-Boot) on Reference Minimal 6.2.0 Upstream and it loaded both CPUs on COlibri iMX7 1GB (eMMC) V1.1A:

root@colibri-imx7-emmc-06674596:~# cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 5 (v7l)
BogoMIPS        : 48.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 5

processor       : 1
model name      : ARMv7 Processor rev 5 (v7l)
BogoMIPS        : 48.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 5

Hardware        : Freescale i.MX7 Dual (Device Tree)
Revision        : 0000
Serial          : 06674596

I would like to call your attention to U-Boot’s source code (arch/arm/cpu/armv7/Kconfig · v2022.07 · U-Boot / U-Boot · GitLab):

Say Y here to boot in secure mode by default even if non-secure mode
is supported. This option is useful to boot kernels which do not
suppport booting in non-secure mode. Only set this if you need it.
This can be overridden at run-time by setting the bootm_boot_mode env.
variable to “sec” or “nonsec”.

So I would like to ask: What is your use case and why would you need the sec?

Best regards,

Hi @henrique.tx

I think I misunderstood the meaning of the sec vs nonsec. I agree that it would be better to boot the kernel in less privilege mode. So for now, I will set this variable to nonsec. By the way, will you also switch back to nonsec for newer BSP ( >6.2.0)?

Again, many thanks for your time and clarification on this topic.

Thanks.

Rob

Hi @Robbie ,

Sorry for the late response. I talked to some of my colleagues here.

So the situation is as follows:

The downstream version used a proprietary way of booting the cores of the SoC. There sec was used. Now starting from newer versions Toradex is only building upstream. There the cores are booted through the standard PSCI.

The commit is still there in kirkstone it’s just not used anymore.

https://git.toradex.com/cgit/meta-toradex-bsp-common.git/tree/recipes-bsp/u-boot/u-boot-toradex/0001-colibri_imx7-boot-linux-kernel-in-secure-mode.patch?h=kirkstone-6.x.y

Best Regards
Kevin

Hi @kevin.tx ,

Thanks a lot for the valuable information. This helped me a lot.

Best Regards,

Rob

1 Like