2025-02-16 09:30 AM - last edited on 2025-02-18 03:42 AM by Andrew Neil
Hii Sir,
Recently I have got Nucleo-H563ZI nucleo board and i was trying to do programming for blinking led present on the board with the trust zone activated, but i am unable to get how to do it.
The process i follow is;
1) Created new stm32 project -> Give the name of the project -> selected with TrustZone -> Finish. As the onboard LED was already defined in the .ioc file. Therefore generated the project with the default configuration, under main folder, two more folder were generated secure and non-secure. in nonsecure folder -> Core -> Src -> main.c in this main.c file searched for while loop and added toggleing of led code in it and build the code. As there was confusion which code to be uploaded first i tried to upload the nonsecure folder but the led was not blinking (only the led was on ) during this when I press the reset button the led was off. second time, I build the secure folder code and flash it in the microcontroller toggleing was working but the led that was on was off.
2) I followed some youtube tutorial in that in stm32cube ide there was example code, i searched for the GPIO_Toggle code with trustzone for the particular board (STM32H563ZI nucleo) and generated code for it but that was also not working.
I am getting confused and not getting the flow that how write code for this microcontoller as in this I was facing problem with led blinking, consider i want to connect mpu6050 which has i2c protocol for communication how to write code for it like after initializing the pin in ioc file and code generation what steps to be done.
As previously, I was using STM32F407 there was direct coding that due to Trustzone I am getting confused about the flow.
Thankyou,
Regards,
Shubham
2025-02-18 07:57 AM
Hi @Shubham08,
when TZ is selected, the MCU always starts by executing the secure code. This typically sets the boundaries in which the non-secure code can execute. Then it invokes the non-secure code.
In STM32Cube_FW_H5_V1.5.0\Projects\NUCLEO-H563ZI\Examples\GPIO\GPIO_IOToggle_TrustZone is very nice example of the LED blinking demo with TZ enabled.
The readme.file included there will explain how to initiate the debugging with TZ.
BR,
J
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.
2025-02-18 10:31 PM
Sir I followed this step but the highlighted step is not working in stm32cube ide and the steps after that is more confusing.
2025-02-19 08:41 AM
Hello @Shubham08 ,
the point is to have both loaded, which for some reason is not default.
It's easier in normal commercial IDE.
BR,
J
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.
2025-02-19 06:39 PM
Thank you sir for giving the step through image. I tried to debug after it but was unable to see the Toggle of led. I doubt that the toggle will be seen on the port or in the user-led present on the board. As in the readme file, LED1 corresponds to secure IO and LED2 corresponds to non-secure IO.
If I have connected button and led externally to any pin of the microcontroller then how to write code for it and in which folder
2025-02-20 08:16 AM
Hello,
at first you make sure if you borad Nucleo-H563ZI is TZEN enable using STM32CubeProgrammer and verify the option byte(TZEN,SECWM1_PSTRT,SECWM1_PEND,SECWM2_PSTRT,SECWM2_PEND) are configured correctly.
please apply the step in readme in the part of Hardware and software environment
User Option Bytes requirement (with STM32CubeProgrammer tool)
this is link of application Tx_SecureLEDToggle_TrustZone that you can try it
the part of "How to use it ?" in the readme can help you to work the application in 3 IDE (EWARM, MDK-ARM, STM32CubeIDE)
Always Build xxxxx_S Build xxxxx_NS Load non-secure binary Load secure binary
Best regards.