Unable to set up non-cacheable MPU regions for LwIP/ethernet when using FreeRTOS-MPU on STM32H743ZI?
Hi there,
I've been dealing with this problem for a while, and can't seem to find the root of it. I've already dug through the forums, datasheets, application notes, etc. with no success.
At this point, I'd be very greatful for any pointers or suggestions you may have.
Setup:
- Hardware: Nucleo-H743ZI2
- IDE: IAR for Arm v8.32.1
- SDK: STM32Cube_FW_H7_V1.6.0
Goals:
- Run FreeRTOS + LwIP to serve a test webpage
- Do NOT disable DCache globally
Current status:
- I can run The SDK's LwIP example just fine.
- Does NOT use FreeRTOS
- Allocates a couple MPU regions through ST's HAL to avoid cache coherence problems between the CPU and the Ethernet's DMA
- DCache is enabled
- I can run FreeRTOS' MPU example just fine.
- Allocates MPU regions for multiple tasks through the FreeRTOS API. The FreeRTOS port accesses the MPU directly, so this project does not use ST's MPU HAL
- DCache is enabled
- I can get the system to work with MPU-protected tasks and LwIP's HTTP server at the same time, but:
- If I try to set up MPU regions for the DMA-accessible buffers through the HAL, the MCU hits an "MPU or Execute Never" exception at the first non-privileged instruction fetch.
- The SDK's FreeRTOS port for this core (the M4-MPU port) does not support a NON_CACHEABLE region configuration, so I can't use it to resolve the cache coherence issues
- As a result, the DCache needs to be disabled globally for ethernet to work. Obviously unacceptable
Questions:
- Why doesn't the SDK's ARM_CM4_MPU FreeRTOS port support non-cacheable MPU regions? Or am I missing something?
- Only the ARM_CM23, ARM_CM23_NTZ, ARM_CM33 and ARM_CM33_NTZ define portMPU_NORMAL_MEMORY_NON_CACHEABLE
- Should it be possible to allocate some MPU regions through the HAL and others through FreeRTOS?
- If it is possible, why would my application throw a memory exception on the first non-privileged instruction fetch?
- If it's not possible, why? And how would you suggest I solve the problem? Rewrite the port, use a different one, or use it differently?
I'm attaching my current linker config file, MPU initialization code and ethernetif.c.
All that code is very much work in progress; so please, forgive poor naming, dead code, and similar shortcomings.
Should you need anything else, or if you'd like me to simplify any of that code, please let me know.
Thanks for your time,
JC
