STM32F7 MPU Memory Restrictions (Shareable attribute)
- Dominant language
- C
- Stars
- 4k
- Forks
- 1.7k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 237
Description
Came across a problem configuring the MPU for a board running the STM32F777. The system locked the board and I believe that the lock was caused by the` MPU_RASR_S` attribute being used on a memory region that didi not support sharing.
The code was configuring the MPU using the `mpu_user_intsram` macro in `mpu.h` which expands to the following:
```C
#define mpu_user_intsram(base, size) \
do \
{ \
/* The configure the region */ \
mpu_configure_region(base, size, \
MPU_RASR_TEX_SO | /* Ordered */ \
MPU_RASR_C | /* Cacheable */ \
/* Not Bufferable */ \
MPU_RASR_S | /* Shareable */ \
MPU_RASR_AP_RWRW /* P:RW U:RW */ \
/* Instruction access */); \
} while (0)
```
This passes the `MPU_RASR_S` attribute to `mpu_configure_region` which attempts to set the appropriate attributes for the memory region.
I was executing `mpu_user_intsram(0x20070000, 0x8000)` and this address is in a region that is not shareable and this caused my application to lock.
I finally resolved this by removing the shareable attribute to get the system running.
Now according to _PM0253 - STM32 Programming Manual_, the majority of the memory map is not shareable (Table 17 in Rev 5 of this document). In fact only 0xA0000000-0xBFFFFFFF and 0xE0000000-0xE00FFFFF are allowed to be shareable.
Given this restriction I think it would be advisable to make shareable an explicit option as these macros only work correctly for a small portion of the memory map.
Contributor guide
Assessment
This issue has not been assessed yet.