mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #10248 from VVESTM/issue_9934
TARGET_STM32F7: Refresh cache when erasing or programming flashpull/10215/head
commit
cdc2579b7b
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
static uint32_t GetSector(uint32_t Address);
|
static uint32_t GetSector(uint32_t Address);
|
||||||
static uint32_t GetSectorSize(uint32_t Sector);
|
static uint32_t GetSectorSize(uint32_t Sector);
|
||||||
|
static uint32_t GetSectorBase(uint32_t SectorId);
|
||||||
|
|
||||||
int32_t flash_init(flash_t *obj)
|
int32_t flash_init(flash_t *obj)
|
||||||
{
|
{
|
||||||
|
@ -130,6 +131,9 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
|
||||||
status = -1;
|
status = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCB_CleanInvalidateDCache_by_Addr((uint32_t *)GetSectorBase(SectorId), GetSectorSize(SectorId));
|
||||||
|
SCB_InvalidateICache();
|
||||||
|
|
||||||
flash_lock();
|
flash_lock();
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
@ -139,6 +143,8 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
||||||
uint32_t size)
|
uint32_t size)
|
||||||
{
|
{
|
||||||
int32_t status = 0;
|
int32_t status = 0;
|
||||||
|
uint32_t StartAddress = address;
|
||||||
|
uint32_t FullSize = size;
|
||||||
|
|
||||||
if ((address >= (FLASH_BASE + FLASH_SIZE)) || (address < FLASH_BASE)) {
|
if ((address >= (FLASH_BASE + FLASH_SIZE)) || (address < FLASH_BASE)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -167,6 +173,9 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCB_CleanInvalidateDCache_by_Addr((uint32_t *)StartAddress, FullSize);
|
||||||
|
SCB_InvalidateICache();
|
||||||
|
|
||||||
flash_lock();
|
flash_lock();
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
@ -265,6 +274,23 @@ static uint32_t GetSectorSize(uint32_t Sector)
|
||||||
return sectorsize;
|
return sectorsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets sector base address
|
||||||
|
* @param SectorId
|
||||||
|
* @retval base address of a given sector
|
||||||
|
*/
|
||||||
|
static uint32_t GetSectorBase(uint32_t SectorId)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
uint32_t address_sector = FLASH_BASE;
|
||||||
|
|
||||||
|
for(i=0;i<SectorId;i++){
|
||||||
|
address_sector += GetSectorSize(i);
|
||||||
|
}
|
||||||
|
return address_sector;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t flash_get_erase_value(const flash_t *obj)
|
uint8_t flash_get_erase_value(const flash_t *obj)
|
||||||
{
|
{
|
||||||
(void)obj;
|
(void)obj;
|
||||||
|
|
Loading…
Reference in New Issue