cancel
Showing results for 
Search instead for 
Did you mean: 

TrustZone and LED blinking in the nonsecure project

fa31
Associate III

Hi,

I have generated a CubeMX project with trustzone. So, I have a secure and a nonsecure project. The secure project runs, jumps to the nonsecure project and the nonsecure project tries to blink the red. I am using CMakeLists and have included my_app.c file, in the nonsecure project, where my main() function is located. 

 

My my_app.c file:

#include <stdbool.h>
// Auto-generated main from STM32 project
#include "main.h"
#include "stm32wbaxx_hal_gpio.h"

int main(void)
{
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();

    main2();

    while (true)
    {
        HAL_GPIO_WritePin(RED_GPIO_Port, RED_Pin, GPIO_PIN_SET);
        HAL_Delay(250U);
        HAL_GPIO_WritePin(RED_GPIO_Port, RED_Pin, GPIO_PIN_RESET);
        HAL_Delay(250U);
    }
}

 

The main2() is the original main generated by CubeMX, but I have renamed it and removed everything else from there, and now it only has the blinking LED code. My main2() function in the nonsecure project main.c file:


int main2(void)
{
    HAL_GPIO_WritePin(RED_GPIO_Port, RED_Pin, GPIO_PIN_SET);
    HAL_Delay(250U);
    HAL_GPIO_WritePin(RED_GPIO_Port, RED_Pin, GPIO_PIN_RESET);
    HAL_Delay(250U);
}



When I step into the code, the entry point is the main() function in the my_app.c file. Then I am able to blink the LED in the main2() function but then the code arrives to the while loop in the main() and it crashes.

So, my question is if someone can help me understanding how code through the main.c file can control the LED but the code through my_app.c file cannot?

Thanks!

0 REPLIES 0