# cortex-r5  MPU task with xilinx FreeRTOS BSP

**URL:** <https://forums.freertos.org/t/cortex-r5-mpu-task-with-xilinx-freertos-bsp/7601>\
**Category:** Kernel\
**Created:** [December 29, 2018, 4:29am UTC](https://forums.freertos.org/t/cortex-r5-mpu-task-with-xilinx-freertos-bsp/7601 "2018-12-29T04:29:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [December 29, 2018, 4:29am UTC](https://forums.freertos.org/t/cortex-r5-mpu-task-with-xilinx-freertos-bsp/7601/1 "2018-12-29T04:29:36Z")

</div>

**[faceless900](https://sourceforge.net/u/faceless900/)** wrote on [Saturday, December 29, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/8ac26bb9f8/#7fb0):

Thans for yesterday’s help, Richard. I encountered a new problem when I try to do **memset(addr, 0, size)in my nomal task, and addr is a pointer to physical addresss0x1000 0000** that is a DDR4 address. Of cource I failed and the previous value in ddr did not change.  
I think it is MPU cause this issue so I wanted to build a MPU task with API function **xTaskCreateRestricted** , and then I found that **xTaskCreateRestricted** is an implicit function because **portUSING\_MPU\_WRAPPERS** is zero in **mpu\_wrappers.h**. and I checked this record [https://sourceforge.net/p/freertos/discussion/382005/thread/85ea3529/?limit=25#d985/b6fa/2a7a/c241/7acd](https://sourceforge.net/p/freertos/discussion/382005/thread/85ea3529/?limit=25#d985/b6fa/2a7a/c241/7acd) . So I set portUSING\_MPU\_WRAPPERS to 1 and defined  
vPortResetPrivilege() in my portmacro.h files, I am not sure if it works because a new problem appeared after I set portUSING\_MPU\_WRAPPERS to 1— **unknown type name ‘xMPU\_SETTINGS’**. I think I can google the definetion for **xMPU\_SETTINGS** and add it to my file, but I wonder whether it is right. I doubt that FreeRTOS did not provide MPU for ARM R5 processor?  
My compile tool is xilinx SDK and processor is ARM Cortex-R5, and I build FreeRTOS source file in BSP acording to [https://www.freertos.org/RTOS-Xilinx-SDK-BSP.html](https://www.freertos.org/RTOS-Xilinx-SDK-BSP.html).

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [December 29, 2018, 5:41pm UTC](https://forums.freertos.org/t/cortex-r5-mpu-task-with-xilinx-freertos-bsp/7601/2 "2018-12-29T17:41:08Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Saturday, December 29, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/8ac26bb9f8/#7fb0/00ce):

Unfortunately the FreeRTOS download does not contain an MPU port for the  
R5, although from your description it doesn’t sound like an MPU issue in  
any case. If it were an MPU issue I would expect you would get a memory  
protection fault, but your post didn’t say that was happening. I don’t  
think this a FreeRTOS issue.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [December 29, 2018, 6:22pm UTC](https://forums.freertos.org/t/cortex-r5-mpu-task-with-xilinx-freertos-bsp/7601/3 "2018-12-29T18:22:59Z")

</div>

**[richarddamon](https://sourceforge.net/u/richarddamon/)** wrote on [Saturday, December 29, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/8ac26bb9f8/#d8a5):

I think part of the issue is you don’t create an MPU port by just setting portUSING\_MPU\_WRAPERS to 1. You need the code that actually uses the MPU, and if FreeRTOS doesn’t have an MPU port for the R5, which seems to be what Richard B is saying, The solution would be to look at similar MPU ports and add the needed definitons to match that processor into the port files.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [December 31, 2018, 6:58am UTC](https://forums.freertos.org/t/cortex-r5-mpu-task-with-xilinx-freertos-bsp/7601/4 "2018-12-31T06:58:43Z")

</div>

**[faceless900](https://sourceforge.net/u/faceless900/)** wrote on [Monday, December 31, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/8ac26bb9f8/#8fb8):

I think you were right and that was indeed nothing to do with MPU. mm… I found I misstoke the address when I checked my code again (I give it 0xE000 0000 but not 0x1000 0000), anyway, thanks for help me correct my fault.

---

<div class="post-metadata">

**Author:** ![simon](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@simon](https://forums.freertos.org/u/simon)\
**Post date:** [February 19, 2020, 4:24am UTC](https://forums.freertos.org/t/cortex-r5-mpu-task-with-xilinx-freertos-bsp/7601/5 "2020-02-19T04:24:02Z")

</div>

Hi, I was looking for the same thing than you, faceless900. I’m working on zynqmp processors which have a 2x cortex R5. The FreeRTOS bsp that xilinx provides lacks the support for FreeRTOS + MPU. Heck, the official download of FreeRTOS lacks it too. Don’t knwo why.

Anyway, I did the dirty work and I completed the port myself. I’m pretty proud that I made it work, and I would like to drop the link to my github repo in order for other people looking for the same thing to be able to use it. This post was the first thing that google poped me, so here it is :

> **[simonbeaudoin0935/Xilinx-CortexR5-FreeRTOS-MPU-Port](https://github.com/simonbeaudoin0935/Xilinx-CortexR5-FreeRTOS-MPU-Port)**
>
> The Cortex R5 port of FreeRTOS lacks the support of MPU. This is the modified bsp version that came with XSDK - simonbeaudoin0935/Xilinx-CortexR5-FreeRTOS-MPU-Port

Any contribution to the port will be appreciated! An MPU is a truly useful device when working with many people on a project; people with less experience who silently corrupt whole memory ;p
