-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MPU/flash: replace MPU_ALLOW_FLASH_WRITE by more fine-grained settings #13913
Comments
When the MPU is enabled, if you want to be able to write to flash, you need to enabled the |
I think this is only enabled, by default in Bluetooth -supported builds. So I doubt that it is. |
Could this issue be closed? |
Hi, The catch here is that user normally dont want to have the ability to write to the flash (when NAND flash is used) - that is why we have MPU. We want to catch the program exception when something goes wrong - when it really try write into FLASH area because some pointer is wrong. In our SW we need sometime update backup firmware or update system environment variables. NAND memories have controller to write/read/erase memory and for SAM device you are filling the shadow register via write to FLASH area but you are not really writing into the flash. When this shadow register is filled then you can issue a command to write the shadow register into the specific FLASH address. The problem here is that I must fill the shadow register via writing to the flash area. From my point of view setting MPU_ALLOW_FLASH_WRITE is a workaround and not true solution - it leaves FLASH open for writing but in real it is not possible. My understanding of MPU_ALLOW_FLASH_WRITE is that can use this with NOR memories when I can do direct FLASH write without use special flash controller. |
Thanks for the details. I have retitle the issue as it's a generic issue with MPU and flash support in Zephyr and not specific to the SAM E70 flash driver. |
Any solution we pick here, @aurel32 will eat at least one MPU region, AFAICS. |
Hi, |
Agreed, we still need to keep one region for the program execution and then we need a new region to program the flash.
The behavior is not at the flash driver level, but at the MPU level. Therefore the behavior is the same for all SoCs. |
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:
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.
The text was updated successfully, but these errors were encountered: