# FreeRTOS Cortex M33 NTZ, without MPU

**URL:** <https://forums.freertos.org/t/freertos-cortex-m33-ntz-without-mpu/9260>\
**Category:** Kernel\
**Created:** [March 17, 2020, 6:38pm UTC](https://forums.freertos.org/t/freertos-cortex-m33-ntz-without-mpu/9260 "2020-03-17T18:38:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fusedFET](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@fusedFET](https://forums.freertos.org/u/fusedFET)\
**Post date:** [March 17, 2020, 6:38pm UTC](https://forums.freertos.org/t/freertos-cortex-m33-ntz-without-mpu/9260/1 "2020-03-17T18:38:06Z")

</div>

Hi!  
I just found a strange case where FreeRTOS Kernel V10.3.1 causes a systematic hardfault in vRestoreContextOfFirstTask(); when vTaskStartScheduler() is called for the first time.

The basic setup is:

- Nrf9160 Cortex M33
- No TrustZone, with FPU, without MPU
- Eveything is running in non\_secure.
- Using the existing GCC/ARM\_CM33\_NTZ/non\_secure ports.

> #define configENABLE\_MPU 0  
> #define configENABLE\_FPU 1  
> #define configENABLE\_TRUSTZONE 0

The hardfault occurs when vRestoreContextOfFirstTask() branches (BX R2) to 0xFFFF FFBC, trying to exit the SVCall\_Exception.

It is my first time playing around with M33 cortexes, so I might have missconfigured something else, but I guess this specific configuration results in an incorrect EXC\_RETURN value.

Is this a known problem?

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [March 17, 2020, 7:09pm UTC](https://forums.freertos.org/t/freertos-cortex-m33-ntz-without-mpu/9260/2 "2020-03-17T19:09:51Z")

</div>

> [@](#):
>
> Eveything is running in non\_secure.

How do you determine that the MCU is running non-secure. Is the TrustZone disabled in hardware?

I do not have the hardware you mentioned but I will check the configuration on a different hardware and update. Meanwhile, would you please try with configRUN\_FREERTOS\_SECURE\_ONLY set to 1 in your FreeRTOSConfig.h:

```
#define configRUN_FREERTOS_SECURE_ONLY 1

```

Thanks.

---

<div class="post-metadata">

**Author:** ![fusedFET](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@fusedFET](https://forums.freertos.org/u/fusedFET)\
**Post date:** [March 17, 2020, 7:55pm UTC](https://forums.freertos.org/t/freertos-cortex-m33-ntz-without-mpu/9260/3 "2020-03-17T19:55:19Z")

</div>

Hey, thank you for your answer.  
It seems like adding

> #define configRUN\_FREERTOS\_SECURE\_ONLY 1

did fix the problem.  
I did set all flash regions as non-secure, as such I expected everything to run as non-secure.  
I think I’ll need to look up some more documentation about TZ.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [March 17, 2020, 9:58pm UTC](https://forums.freertos.org/t/freertos-cortex-m33-ntz-without-mpu/9260/4 "2020-03-17T21:58:15Z")

</div>

Glad that it worked for you. What it means is that the TrustZone is not disabled and the MCU is running as secure. As you rightly said, you need to check the document about how to disable TrustZone in hardware.

Thanks.
