cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOS in Trustzone

fa31
Associate III

Hi,

I am trying to add FreeRTOS to my project.

Board = Nucleo-U5A5ZJ-Q

Trustzone = enabled

FreeRTOS = in non-secure project

 

 

I have Trustzone enabled, therefore a secure and a non-secure project is generated by CubeMX. I added FreeRTOS in the non-secure project. Upon building the project, it gives the following errors (the output is modified to remove additional build information and long project paths):

 

 
.../GCC/ARM_CM33/non_secure/port.c.obj: in function `vPortSVCHandler_C':
[build] .../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/port.c:1042: undefined reference to `SecureContext_AllocateContext'
[build] .../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/port.c:1047: undefined reference to `SecureContext_LoadContext'
[build] .../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/port.c:1058: undefined reference to `SecureContext_FreeContext'
[build] .../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/port.c:1067: undefined reference to `SecureInit_DePrioritizeNSExceptions'
[build] .../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/port.c:1070: undefined reference to `SecureContext_Init'
[build] .../GCC/ARM_CM33/non_secure/portasm.c.obj: in function `PendSV_Handler':
[build] .../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portasm.c:423: undefined reference to `SecureContext_SaveContext'
[build] .../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM33/non_secure/portasm.c:423: undefined reference to `SecureContext_LoadContext'
 
 
How do I solve these error?
I have already tried the steps described in this post and they did not help me.
 
Thanks!
 
 
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Sarra.S
ST Employee

Hello @fa31

The errors you're getting are related to missing references for secure context functions in your FreeRTOS setup.

You need to include these FreeRTOS files in your Secure project to handle context switching between secure and non-secure parts of the application

  • secure_context.c
  • secure_context_port.c
  • secure_context_port_asm.s
  • secure_heap.c
  • secure_init.c

Hope that helps!

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.

View solution in original post

2 REPLIES 2
Sarra.S
ST Employee

Hello @fa31

The errors you're getting are related to missing references for secure context functions in your FreeRTOS setup.

You need to include these FreeRTOS files in your Secure project to handle context switching between secure and non-secure parts of the application

  • secure_context.c
  • secure_context_port.c
  • secure_context_port_asm.s
  • secure_heap.c
  • secure_init.c

Hope that helps!

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.

fa31
Associate III

Thank you @Sarra.S for the reply. 

For someone trying to solve the same errors:

I added those files from FreeRTOS official git repo: link.

Added the files in my project under Middlewares -> Third_Party -> FreeRTOS -> Source -> portable -> GCC -> ARM_CM33 -> secure, and then added the file paths into my CMakeList and was able to build the project without any errors.