cortex-r5 MPU task with xilinx FreeRTOS BSP

faceless900 wrote on Saturday, December 29, 2018:

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 . 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.

rtel wrote on Saturday, December 29, 2018:

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.

richarddamon wrote on Saturday, December 29, 2018:

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.

faceless900 wrote on Monday, December 31, 2018:

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.

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 :

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