Skip to content

Commit

Permalink
Update Zephyr MSDK Hal based on MSDK PR: analogdevicesinc/msdk#1300
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 19, 2024
1 parent d297cb6 commit 4ad58a2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions MAX/Libraries/PeriphDrivers/Source/FLC/flc_me30.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,36 @@ int MXC_FLC_Write(uint32_t address, uint32_t length, uint32_t *buffer)
void MXC_FLC_Read(int address, void *buffer, int len)
{
MXC_FLC_Com_Read(address, buffer, len);

/* ECC error detected */
if (MXC_GCR->eccerr & MXC_F_GCR_ECCERR_FLASH) {
/* Clear the ECC error */
MXC_GCR->eccerr = MXC_F_GCR_ECCERR_FLASH;

/*
* Erasing flash will also erase the ECC bits. These bits are not
* updated until a flash write. Reading from erased memory will
* signal a ECC error that is falsely corrected from 0xFF to 0xFD
* on the 16th byte of each 128-bit line.
*
* Workaround by setting the 16th byte of each line to 0xFF.
*/

/* Get to the 16th byte of each line */
uint32_t addrOffset = (0xF - (address % 0x10));
uint8_t *buffer8 = buffer;

for (int i = 0; i < len; i++) {
/* Check for the erased flash ECC correction */
if (i == addrOffset && buffer8[i] == 0xFD) {
buffer8[i] = 0xFF;
addrOffset += 0x10;
} else if (buffer8[i] != 0xFF) {
/* This could be an actual ECC error */
break;
}
}
}
}

//******************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion MAX/msdk_sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f74f03559d62ca81c948ae36667a2eefef586eca
bdf3bd96fad0afa76d90a90cf4b8a2f2f7882e00

0 comments on commit 4ad58a2

Please sign in to comment.