Merge pull request #4937 from JasonCang/fixbug-修复stm32_chip_flash驱动扇区计算错误的bug
修改扇区计算错误的bug
This commit is contained in:
commit
f3df67d5f3
|
@ -8,6 +8,7 @@
|
||||||
* 2018-12-5 SummerGift first version
|
* 2018-12-5 SummerGift first version
|
||||||
* 2019-3-2 jinsheng add Macro judgment
|
* 2019-3-2 jinsheng add Macro judgment
|
||||||
* 2020-1-6 duminmin support single bank mode
|
* 2020-1-6 duminmin support single bank mode
|
||||||
|
* 2021-8-11 CX fix the sector calculation error bug
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
@ -280,7 +281,7 @@ int stm32_flash_erase(rt_uint32_t addr, size_t size)
|
||||||
/* Get the 1st sector to erase */
|
/* Get the 1st sector to erase */
|
||||||
FirstSector = GetSector(addr);
|
FirstSector = GetSector(addr);
|
||||||
/* Get the number of sector to erase from 1st sector*/
|
/* Get the number of sector to erase from 1st sector*/
|
||||||
NbOfSectors = GetSector(addr + size) - FirstSector + 1;
|
NbOfSectors = GetSector(addr + size - 1) - FirstSector + 1;
|
||||||
/* Fill EraseInit structure*/
|
/* Fill EraseInit structure*/
|
||||||
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
|
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
|
||||||
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
|
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
|
||||||
|
|
Loading…
Reference in New Issue