Skip to content

Commit fc7523d

Browse files
ericmechingithub-actions[bot]
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 5e6962c commit fc7523d

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
@@ -104,7 +104,7 @@ static int flash_stm32_erase(const struct device *dev, off_t offset,
104104
size_t len)
105105
{
106106
int rc;
107-
int sect_num = (len / FLASH_PAGE_SIZE) + 1;
107+
int sect_num;
108108

109109
if (!flash_stm32_valid_range(dev, offset, len, true)) {
110110
LOG_ERR("Erase range invalid. Offset: %p, len: %zu",
@@ -116,6 +116,9 @@ static int flash_stm32_erase(const struct device *dev, off_t offset,
116116
return 0;
117117
}
118118

119+
/* len is a multiple of FLASH_PAGE_SIZE */
120+
sect_num = len / FLASH_PAGE_SIZE;
121+
119122
flash_stm32_sem_take(dev);
120123

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

0 commit comments

Comments
 (0)