Skip to content

Commit 6a519f6

Browse files
DerekSnellnashif
authored andcommitted
drivers: flash: soc_flash_mcux: remove CMD_MARGIN_CHECK
The CMD_BLANK_CHECK can return errors when the flash is readable, and should only be used after programming, not in is_area_readable(). From the LPC55S69 datasheet: "As cells age and lose charge, a correctly programmed address will fail this check, while still being able to be read successfully for the remaining duration of the data retention time." Signed-off-by: Derek Snell <[email protected]> (cherry picked from commit 88b9cb6)
1 parent 8b5fee6 commit 6a519f6

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/flash/soc_flash_mcux.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static uint32_t get_cmd_status(uint32_t cmd, uint32_t addr, size_t len)
8888
}
8989

9090
/* This function prevents erroneous reading. Some ECC enabled devices will
91-
* crash when reading an erased or wrongly programmed area.
91+
* crash when reading an erased area.
9292
*/
9393
static status_t is_area_readable(uint32_t addr, size_t len)
9494
{
@@ -97,21 +97,13 @@ static status_t is_area_readable(uint32_t addr, size_t len)
9797

9898
key = irq_lock();
9999

100-
/* Check if the are is correctly programmed and can be read. */
101-
status = get_cmd_status(FMC_CMD_MARGIN_CHECK, addr, len);
102-
if (status & FMC_STATUS_FAILURES) {
103-
/* If the area was erased, ECC errors are triggered on read. */
104-
status = get_cmd_status(FMC_CMD_BLANK_CHECK, addr, len);
105-
if (!(status & FMC_STATUS_FAIL)) {
106-
LOG_DBG("read request on erased addr:0x%08x size:%d",
107-
addr, len);
108-
irq_unlock(key);
109-
return -ENODATA;
110-
}
111-
LOG_DBG("read request error for addr:0x%08x size:%d",
100+
/* If the area was erased, ECC errors are triggered on read. */
101+
status = get_cmd_status(FMC_CMD_BLANK_CHECK, addr, len);
102+
if (!(status & FMC_STATUS_FAIL)) {
103+
LOG_DBG("read request on erased addr:0x%08x size:%d",
112104
addr, len);
113105
irq_unlock(key);
114-
return -EIO;
106+
return -ENODATA;
115107
}
116108

117109
irq_unlock(key);

0 commit comments

Comments
 (0)