Skip to content

MPU/flash: replace MPU_ALLOW_FLASH_WRITE by more fine-grained settings #13913

@andrewboie

Description

@andrewboie

Logging from a message from JK on slack:

Hi, Im using SAME70 (Cortex-M7) platform and I have a problem with the FLASH driver when MPU is enabled. The basic problem is that MPU is protecting FLASH before writing - this is what we actually want. How ever the FLASH controller does not count with this behavior and need to perform the write operation into the FLASH address area, which cause write into internal latch registers. So when the MPU is enabled and protecting the FLASH area, this operation cause MPU to rise exception - as expected. However this write can be anywhere where the FLASH memory is expected (but it dont have to be installed) There is no simply workaround, i see three options:

  1. Disable before write and then enable MPU - with multi threading this is might not be a good idea. I have a limited knowledge here.
  2. Shrink down the MPU area to make a free space which is not covered by MPU. But the size of MPU area is defined as 2^x - so shrinking down is pretty complex.
  3. Create workaround which will not cover all FLASH variant (I can write beyond the installed flash area, but for example with SAME70 this is working only for 515KB and 1MB flash and it will not work for 2MB flash as I can't write beyond the 2BM flash area)
    We can create all patch variants, But Im not sure which one is preferred by Zephyr community. Can some help me to make a good decision.

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions