Skip to main content
Associate
September 15, 2026
Question

STM32U575 + TrustZone + X-CUBE-FREERTOS 1.6.0: missing Secure FreeRTOS sources in generated project

  • September 15, 2026
  • 5 replies
  • 60 views

Hi,

I am using:

  • STM32U575VGT6Q
  • STM32CubeIDE 2.1.1
  • STM32Cube FW U5 V1.9.0
  • X-CUBE-FREERTOS 1.6.0 / FreeRTOS 11.2
  • TrustZone enabled
  • FreeRTOS running in NonSecure (TZ_Non_Secure)
  • FreeRTOS Secure support enabled (TZ_Secure)

The generated NonSecure project fails at link time with:

undefined reference to `SecureContext_AllocateContext'
undefined reference to `SecureContext_LoadContext'
undefined reference to `SecureContext_FreeContext'
undefined reference to `SecureContext_SaveContext'
undefined reference to `SecureContext_Init'
undefined reference to `SecureInit_DePrioritizeNSExceptions'

Some of them are followed by:

Unknown destination type (ARM/Thumb)
dangerous relocation: unsupported relocation

The NonSecure linker correctly links:

Secure/Debug/secure_nsclib.o

but CubeMX did not copy the required Secure FreeRTOS source files into the generated project:

secure_context.c
secure_context_port.c
secure_heap.c
secure_init.c

Only the corresponding .h files were copied under:

Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33/secure/

The four .c files are present correctly in the installed X-CUBE-FREERTOS 1.6.0 package.

As a workaround I manually copied those four .c files into the Secure project and added these include paths:

../../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33/secure
../../NonSecure/Core/Inc

After that, the Secure project compiled successfully and the NonSecure linker errors disappeared.

Is this a known CubeMX / X-CUBE-FREERTOS 1.6.0 code generation issue for STM32U5 TrustZone?

I can provide the .ioc and generated project files if needed.

 

5 replies

ST Technical Moderator
September 15, 2026

Hello ​@bitsandscience 

Let me thank you for posting and welcome to the ST Community.

For more investigation, I recommend that you provide your Ioc.File.

Thanks.

Mahmoud

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate
September 15, 2026

Hi Mahmoud,

 

Find the file attached.

 

Thanks.

 

Carlos

ST Technical Moderator
September 16, 2026

Hello ​@bitsandscience 

I reproduced the behavior described, you should enable the FreeRtos package in the secure context.

Then generate the code.

You should also build the secure project before the non-secure project and the build will be finished without errors.

 

I will be waiting for your feedback.

Thanks.

Mahmoud

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.