Browse Source

drivers: flash: stm32: fix flash write error handling

The stm32 flash driver returns success even though
writing failed when instruction cache was enabled.
Fix by not overriding error code when re-enabling
instruction cache.

Signed-off-by: Riku Karjalainen <riku.karjalainen@vaisala.com>
pull/74303/head
Riku Karjalainen 1 year ago committed by Alberto Escolar
parent
commit
ff0635d700
  1. 8
      drivers/flash/flash_stm32l5x.c
  2. 8
      drivers/flash/flash_stm32wbax.c

8
drivers/flash/flash_stm32l5x.c

@ -367,10 +367,16 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset, @@ -367,10 +367,16 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset,
}
if (icache_enabled) {
int rc2;
/* Since i-cache was disabled, this would start the
* invalidation procedure, so wait for completion.
*/
rc = icache_wait_for_invalidate_complete();
rc2 = icache_wait_for_invalidate_complete();
if (!rc) {
rc = rc2;
}
/* I-cache should be enabled only after the
* invalidation is complete.

8
drivers/flash/flash_stm32wbax.c

@ -262,10 +262,16 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset, @@ -262,10 +262,16 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset,
}
if (icache_enabled) {
int rc2;
/* Since i-cache was disabled, this would start the
* invalidation procedure, so wait for completion.
*/
rc = icache_wait_for_invalidate_complete();
rc2 = icache_wait_for_invalidate_complete();
if (!rc) {
rc = rc2;
}
/* I-cache should be enabled only after the
* invalidation is complete.

Loading…
Cancel
Save