Skip to content

Commit 62a1b8a

Browse files
ericmechindanieldegrasse
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 <eric.mechin@st.com>
1 parent f8b4a04 commit 62a1b8a

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
@@ -95,7 +95,7 @@ static int flash_stm32_erase(const struct device *dev, off_t offset,
9595
size_t len)
9696
{
9797
int rc;
98-
int sect_num = (len / FLASH_PAGE_SIZE) + 1;
98+
int sect_num;
9999

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

110+
/* len is a multiple of FLASH_PAGE_SIZE */
111+
sect_num = len / FLASH_PAGE_SIZE;
112+
110113
flash_stm32_sem_take(dev);
111114

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

0 commit comments

Comments
 (0)