FreeRTOS-Plus-TCP on TMS570LC435 with MPU

Hello,
I’m writing a TMS570LC435 zero-copy Ethernet driver for FreeRTOS+TCP V4.2.1 and static buffer allocation. I started with a bare metal version with lwip, then used FreeRTOS without MPU and got that running. Now I want to integrate it into our running system with MPU.

There I have a runtime issue with BufferAllocation_1.c. When calling uxListRemove() from BufferAllocation_1.c, I run into a prefetch error. It seems to have something to do with the processor mode (privileged or user mode).

I have found a hacky solution to just change the processor mode before:

portRAISE_PRIVILEGE();
portMEMORY_BARRIER();

( void ) uxListRemove( &( pxReturn->xBufferListItem ) );

portRESET_PRIVILEGE();
portMEMORY_BARRIER();

But then the next function call of a function from list.c causes the same error. I think there must be a better solution for that.

Which API call results in that error?

Can you try making the tasks using FreeRTOS-Plus-TCP APIs privileged? This would confirm that the issue is related to the task attempting to access a memory location without proper access permissions. You can make a task privileged by OR’ing portPRIVILEGE_BIT to the priority value. Here is an example - FreeRTOS/FreeRTOS/Demo/CORTEX_MPU_M7_NUCLEO_H743ZI2_GCC_IAR_Keil/Demo/reg_tests.c at main · FreeRTOS/FreeRTOS · GitHub.

It happens in line 259 when I call ( void ) uxListRemove( &( pxReturn->xBufferListItem ) );. To be precise I saw in the debugger it happens exactly when I want to jump to the address of uxListRemove().

Thank you. That sounds reasonable. I’ll try that tomorrow and give you then feedback.

Hi Gaurav,

Thanks for your support. I just tested your suggestion. It seems to work. I still have some stack overflow somewhere which I need to address, but the problem from above seems to be fixed.

But I needed to modify the FreeRTOS_IPInit_Multi() in FreeRTOS_IP.c. The IP-Task is normally created with xTaskCreateStatic().

Glad that it worked for you!