Porting FreeRTOS on nRF5340 with IAR IDE

Hi

I have tried porting FreeRTOS (ARM_CM33_NTZ) on nRF5340 with IAR IDE. The software works as expected when the board is connected to PC and IAR is in debugging mode, otherwise it stuck somewhere in vRestoreContextOfFirstTask() function (I used LED to identify where it is stucking).
I would like to know the result if anyone has tried before.

Thank you
Viet

Are you running from RAM or Flash? If from Flash, did you flash the binary by using Project -> Download -> Download active application menu item?

Can you attach the debugger to the running application to find out where the application is stuck?

I flash it by the method you mentioned above and JFlash tool from Segger as well but it seems that the software stuck in vRestoreContextOfFirstTask().
But when I run it with debugging mode, it works well. So I can’t debug.
Is there any example using ARM_CM33_NTZ with IAR?

You have an option to attach the debugger to the running target without resetting it. See Attach to running target in this guide.

Yes, here it is - FreeRTOS/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects_NTZ/IAR at main · FreeRTOS/FreeRTOS · GitHub.

Tried “Attach to running target” but the result is no change. Always works when debugging is active.

Example above is not included in FreeRTOSv202212.01.zip, right?

When you attach to the running target, it should not reset which means it should remain stuck at whatever position it is. Can you then break in the debugger and examine the call stack? You should also try to reach out to IAR Systems.

If it is not, you should be able to get it from main.

1 Like

It seems that interrupts are disabled after calling vRestoreContextOfFirstTask();
Do you have any suggestion for me?

This is my config for Cortex M33
#define configENABLE_MPU 0
#define configENABLE_FPU 1
#define configENABLE_TRUSTZONE 0
#define configRUN_FREERTOS_SECURE_ONLY 1

It should not differ with debugging. How did you determine that?

Hi Gaurav

It’s been awhile since last time. Now I am using Segger Embedded Studio (SES) with Kernel V11.1.0 but unfortunately I am facing same problem.
I have seen you suggested this in other topic but I couldn’t find where SAU is configured in “/Demo/CORTEX_MPU_M33F_NTZ_Nordic_NRF9160_SES 29”

Thanks.

You mean you are able to debug but not able to run when you do not use the debugger?

Here it is - FreeRTOS/FreeRTOS/Demo/CORTEX_MPU_M33F_NTZ_Nordic_NRF9160_SES/Nordic_Code/nRF/Device/Source/system_nrf9160.c at main · FreeRTOS/FreeRTOS · GitHub.

If the behavior is same with 2 IDEs, I’d also suggest to reach out to Nordic. It may be something hardware specific.

Yes it is.

I have seen this. Mine is the same.

Thank you and I will update you if I can go further with Nordic forum.

I have missed one thing: Set define configUSE_TICKLESS_IDLE from 1 to 0. it is now running.

Thank you!

Thank you for reporting back!

1 Like