Skip to content

Commit f3df67d

Browse files
authored
Merge pull request #4937 from JasonCang/fixbug-修复stm32_chip_flash驱动扇区计算错误的bug
修改扇区计算错误的bug
2 parents 92df292 + 6dd8682 commit f3df67d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f7.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* 2018-12-5 SummerGift first version
99
* 2019-3-2 jinsheng add Macro judgment
1010
* 2020-1-6 duminmin support single bank mode
11+
* 2021-8-11 CX fix the sector calculation error bug
1112
*/
1213

1314
#include "board.h"
@@ -280,7 +281,7 @@ int stm32_flash_erase(rt_uint32_t addr, size_t size)
280281
/* Get the 1st sector to erase */
281282
FirstSector = GetSector(addr);
282283
/* Get the number of sector to erase from 1st sector*/
283-
NbOfSectors = GetSector(addr + size) - FirstSector + 1;
284+
NbOfSectors = GetSector(addr + size - 1) - FirstSector + 1;
284285
/* Fill EraseInit structure*/
285286
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
286287
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;

0 commit comments

Comments
 (0)