flash erase cache invalidate (#3073)
Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
8cd674ac3b
commit
9b4f8a3a29
|
@ -170,6 +170,13 @@ int intFlashErase(flashaddr_t address, size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool intFlashIsErased(flashaddr_t address, size_t size) {
|
bool intFlashIsErased(flashaddr_t address, size_t size) {
|
||||||
|
#if CORTEX_MODEL == 7
|
||||||
|
// If we have a cache, invalidate the relevant cache lines.
|
||||||
|
// They may still contain old data, leading us to believe that the
|
||||||
|
// flash erase failed.
|
||||||
|
SCB_InvalidateDCache_by_Addr((uint32_t*)address, size);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check for default set bits in the flash memory
|
/* Check for default set bits in the flash memory
|
||||||
* For efficiency, compare flashdata_t values as much as possible,
|
* For efficiency, compare flashdata_t values as much as possible,
|
||||||
* then, fallback to byte per byte comparison. */
|
* then, fallback to byte per byte comparison. */
|
||||||
|
@ -211,6 +218,12 @@ bool intFlashCompare(flashaddr_t address, const char* buffer, size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int intFlashRead(flashaddr_t address, char* buffer, size_t size) {
|
int intFlashRead(flashaddr_t address, char* buffer, size_t size) {
|
||||||
|
#if CORTEX_MODEL == 7
|
||||||
|
// If we have a cache, invalidate the relevant cache lines.
|
||||||
|
// They may still contain old data, leading us to read invalid data.
|
||||||
|
SCB_InvalidateDCache_by_Addr((uint32_t*)address, size);
|
||||||
|
#endif
|
||||||
|
|
||||||
memcpy(buffer, (char*) address, size);
|
memcpy(buffer, (char*) address, size);
|
||||||
return FLASH_RETURN_SUCCESS;
|
return FLASH_RETURN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue