cancel
Showing results for 
Search instead for 
Did you mean: 

Does Ethernet communication require the use of the MPU?

DBurr
Senior

Hi, in all the example code I've found related to using FreeRTOS and LwIP and performing Ethernet related tasks the MPU is always used to protect the Ethernet DMA. Why is this the case and what could go wrong if the MPU is not used?

Thanks,

Doug

1 ACCEPTED SOLUTION

Accepted Solutions
Piranha
Chief II

The short answer - no.

But there are useful benefits of using MPU. Typically it's used for two purposes:

  1. To configure descriptor memory as a device memory type. This is related to load/store instruction (re)ordering.
  2. To configure/limit/disable data buffer memory caching. This can relieve the code from doing invalidate/flush operations, but it must be noted that, if you implement a zero-copy driver, then the output frames can come from different memories. Therefore at least with zero-copy drivers doing invalidate/flush in code is more flexible solution.

You can find more details on this in AN4838 and AN4839. And also AN4667 and AN4891 are useful. Memory caching obviously is related only to Cortex-M7. As for a memory types...

The Cortex-M processors never perform memory accesses out of order compared to instruction flow, however, the architecture does not prohibit this in future implementations. ARMv7-M code written to be portable to ARMv7-AR processors, like Cortex-A9, must already take account of this ordering model.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0321a/BIHJIIIC.html

But take a note that Cortex-M7 is not included in that AN321 and... Here we go - Cortex-M7 is that future implementation they were talking about and it really is reordering memory accesses.

View solution in original post

4 REPLIES 4
Pavel A.
Evangelist III

The code like this ? It does not protect the DMA. It sets the correct attributes on memory areas shared with the ethernet controller over DMA.

This saves the programmer from flushing and invalidating the cache all the time.

-- pa

Yes, that's the demo code I'm talking about. Ok, thanks for the info.

Piranha
Chief II

The short answer - no.

But there are useful benefits of using MPU. Typically it's used for two purposes:

  1. To configure descriptor memory as a device memory type. This is related to load/store instruction (re)ordering.
  2. To configure/limit/disable data buffer memory caching. This can relieve the code from doing invalidate/flush operations, but it must be noted that, if you implement a zero-copy driver, then the output frames can come from different memories. Therefore at least with zero-copy drivers doing invalidate/flush in code is more flexible solution.

You can find more details on this in AN4838 and AN4839. And also AN4667 and AN4891 are useful. Memory caching obviously is related only to Cortex-M7. As for a memory types...

The Cortex-M processors never perform memory accesses out of order compared to instruction flow, however, the architecture does not prohibit this in future implementations. ARMv7-M code written to be portable to ARMv7-AR processors, like Cortex-A9, must already take account of this ordering model.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0321a/BIHJIIIC.html

But take a note that Cortex-M7 is not included in that AN321 and... Here we go - Cortex-M7 is that future implementation they were talking about and it really is reordering memory accesses.

Thanks for that info. For now I'm keeping my ethernet implementation as similar to the example code as possible so will also use the MPU as used in these examples. I've seen some of the posts you've made about ethernet driver issues in the code provided by ST, are there any specific changes you've made to this that you feel are critically important to achieve best results?