rghaddab/mram write robustness#106557
rghaddab/mram write robustness#106557rghaddab wants to merge 8 commits intozephyrproject-rtos:mainfrom
Conversation
b0feb15 to
444d913
Compare
e386c71 to
11b6c99
Compare
11b6c99 to
3582c02
Compare
There was a problem hiding this comment.
How is this change relevant to the PR?
There was a problem hiding this comment.
Well this PR depends on the MRAM_LATENCY service.
This config depends on EVENTS which also depends on MULTITHREADING
so this test doesn't make any sense for me, and it fails because we run into a Kconfig dependency loop
There was a problem hiding this comment.
Why not just add - CONFIG_SOC_FLASH_NRF_MRAM=n in extra_configs instead of removing this test scenario?
d3zd3z
left a comment
There was a problem hiding this comment.
So, I have a bit of a fundamental question about the misaligned write. In general, with most non-volatile storage devices cannot do this in a memory safe way, and at least looking at this implementation, I believe that is also the case here.
What problem is supporting misaligned writes trying to solve. If it isn't done in a power-safe way, what application would find that acceptable.
In general, I would say that flash drivers should never provide workarounds like this, and with how this device appears to work, I would argue that should be the case here as well.
Hi @d3zd3z I would agree as well that misaligned writes is not something that most application would use. |
Misalignment in DTS should not be allowed. DTS should have the write-block-size set to minimal of a device required and assert in driver should not allow that to even compile. The only reason sub-writes could be allowed on MRAM would be the same as it implicitly happens in EEPROMS with larger sizes. |
jonathannilsen
left a comment
There was a problem hiding this comment.
I ran into a few compilation issues when trying to integrate the changes here (building from nrfconnect/sdk-zephyr#3960):
@de-nordic I will remove sub-writes support ( < MRAM_WORD_SIZE). |
The same would apply, either we have read/modify/write support in the flash driver or not. |
8bb5ba4 to
6d0f139
Compare
6d0f139 to
6847218
Compare
Flash drivers should never have read/modify/write support. It makes it impossible to use in a robust way. Robustness needs to be implemented by an FTL, or a filesystem that knows how to handle the complexity behind this. |
Realistically, an EEPROM driver should know about this, and prevent it from being done (at least if it isn't robust). Short of a special kind of |
4f0ae3a to
fa3de24
Compare
|
@d3zd3z can you remove the change request, as I removed the non aligned write-block-size support. |
Add a BULID_ASSERT to make sure that the write_block_size defined in the device tree is a multiple of the MRAM_WORD_SIZE which is 16B (128 bits) Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
When writes are issued to the mram controller without verifying that it is ready, it can cause the reads to be stalled until all writes finish. Fix this by adding a wait busy loop before each MRAM_WORD aligned write and disable autopowerdown before starting the write. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
Fix the case where the MRAM writes get corrupted in some conditions. After each "MRAM_WORD_SIZE write", a read of the written/erased MRAM word is performed while masking the bus faults to avoid halting the system. If an error is detected in the BFSR status bits, retry the write for a maximum of CONFIG_NRF_MRAM_MAX_RETRIES (default 20) times. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
When requesting/releasing the no_latency mode for the mram, verify that the request/release is successful to avoid running into infinite loop if the mram controller is in autopowerdown mode. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
soc_flash_nrf_mram driver needs MULTITHREADING to be compiled. As this test disables MULTITHREADING, the mram flash driver needs to be disabled as well. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
memcpy is not optimized for the Cortex-M core due to this : zephyrproject-rtos#95154 Modify this by writing each word individually. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
fa3de24 to
94e33fd
Compare
Add CONFIG_MULTITHREADING config fragment for nrf54h20/cpuapp Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
RISCV_CORE_NORDIC_CORE platforms cannot be tested with settings subsystem as they cannot enable the MRAM driver. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
|



A series of commits that adds more robustness to the MRAM write/erase function.
It adds the support of non aligned addresses to the write_block_size
It recovers from a bad write by reading back written data and detecting a bus fault