Question
Flash Write Errors on STM32WB with BLE Stack
Hi,
I use an STM32WB with the BLE stack. In my code, I need to write data to the flash memory (writing new firmware to a prepared memory area). Unfortunately, when I attempt to write to the flash, an error occurs. Is there anything special that I need to change? This worked fine on other MCUs like the G0 and F4.
bool MM_WriteData(uint32_t addr,uint8_t *data, uint32_t size )
{
uint64_t data64;
HAL_StatusTypeDef status=HAL_OK;
HAL_FLASH_Unlock(); //Unlocks the flash memory
while (__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) != RESET) {}
memcpy(&data64,&data[0], sizeof(uint64_t));
status|=HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, addr, data64);
}
HAL_FLASH_Lock(); //Locks again the flash memory
if(status == HAL_OK)
{
return true;
}
return false;
}
