Skip to content

Commit e81d10f

Browse files
ericmechinkartben
authored andcommitted
drivers: flash: STM32WBA flash_stm32wba_fm.c: fix sector erase error
The STM32WBA Flash Manager driver is failing to erase a sector, instead of erasing one sector, two sectors are erased. Fix it by correctly calculating the number of sectors to erase Signed-off-by: Eric Mechin <[email protected]> (cherry picked from commit 62a1b8a)
1 parent 7074e6b commit e81d10f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/flash/flash_stm32wba_fm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static int flash_stm32_erase(const struct device *dev, off_t offset,
9393
size_t len)
9494
{
9595
int rc;
96-
int sect_num = (len / FLASH_PAGE_SIZE) + 1;
96+
int sect_num;
9797

9898
if (!flash_stm32_valid_range(dev, offset, len, true)) {
9999
LOG_ERR("Erase range invalid. Offset: %p, len: %zu",
@@ -105,6 +105,9 @@ static int flash_stm32_erase(const struct device *dev, off_t offset,
105105
return 0;
106106
}
107107

108+
/* len is a multiple of FLASH_PAGE_SIZE */
109+
sect_num = len / FLASH_PAGE_SIZE;
110+
108111
flash_stm32_sem_take(dev);
109112

110113
LOG_DBG("Erase offset: %p, page: %ld, len: %zu, sect num: %d",

0 commit comments

Comments
 (0)