Skip to content

tfm: stack limitation on unsecured application on b_u585i_iot02a_ns #61462

@RomainPelletant

Description

@RomainPelletant

Describe the bug
When using TFM (with STM32U585), the stack is limited on non-secure application.

First test based on tfm_ipc sample:

  • Add several threads in tfm_ipc sample (more than 132KB as total stack)
  • Run tfm_ipc sample : reboot looping after TF-M boot (non secure boot)

Second test based on tfm_ipc sample under stack limit:

  • Same as first test but limit total stack to 131KB
  • Run successfully

Third test without TFM:

  • Remove all TFM-related from TFM_IPC sample
  • Add several threads (more than 200KB as total stack)
  • Run succesfully

Please also mention any information which could help others to understand
the problem you're facing:

  • What target platform are you using?
    STM32U585 custom board
  • What have you tried to diagnose or workaround this issue?
    I tried to increase NS_STACK_SIZE in region_defs.h but no success. Maybe MSPLIM/PSPLIM registers could trigger stack overflow/protection.
    The stack limit reached is equivalent to memory shift by an offset equal to 0x20000 (131072d)
  • Is this a regression? If yes, have you been able to "git bisect" it to a
    specific commit?
    Tested with TF-M 1.7 and TF-M 1.8 with the same result
    Zephyr 3.4.99 (rebased on main)
    MCU: STM32U585QI

To Reproduce
Steps to reproduce the behavior:

  1. Open sample TFM_IPC (in sample/tfm_integration/tfm_ipc)
  2. Increase main stack size and add K_THREAD_DEFINE to reach up to 131KB of stacks
  3. Run with TFM
  4. make & flash (regression.sh && west flash)
  5. See error

Expected behavior
MCU has 768KB of RAM and I expect to use them, at least 256KB.

Impact
showstopper

Logs and console output

[Sec Thread] Secure image initializing!
Booting TF-M v1.8.0
[INF][Crypto] Initialising HW accelerator... complete.
[WRN] This device was provisioned with dummy keys. This device is NOT SECURE
[Sec Thread] Secure image initializing!
Booting TF-M v1.8.0
[INF][Crypto] Initialising HW accelerator... complete.
[WRN] This device was provisioned with dummy keys. This device is NOT SECURE
[Sec Thread] Secure image initializing!
Booting TF-M v1.8.0
[INF][Crypto] Initialising HW accelerator... complete.
[WRN] This device was provisioned with dummy keys. This device is NOT SECURE
[Sec Thread] Secure image initializing!
Booting TF-M v1.8.0
[INF][Crypto] Initialising HW accelerator... complete.

Environment (please complete the following information):

  • OS: MacOS
  • Zephyr SDK 0.15.2
  • Zephyr main for test (TF-M 1.8)

Metadata

Metadata

Assignees

Labels

StaleWaiting for responseWaiting for author's responsearea: TF-MARM Trusted Firmware-M (TF-M)bugThe issue is a bug, or the PR is fixing a bugplatform: STM32ST Micro STM32priority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions