File tree Expand file tree Collapse file tree 1 file changed +2
-1
lines changed
bsp/stm32/libraries/HAL_Drivers/drv_flash Expand file tree Collapse file tree 1 file changed +2
-1
lines changed Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments