2024-09-03 09:18 PM
Hello everyone
After using the stm32f207ztg6 to write to flash memory, when I try to run the debug again, the following error appears and the program cannot be executed.
How can I solve the problem?
■ Program used
uint32_t flash_addr = 0x080E0000;
uint32_t writeAddr = flash_addr;
uint8_t testData[8] = {10, 30, 50, 70, 20, 40, 60, 80};
HAL_FLASH_Unlock();
// Flash erase
FLASH_EraseInitTypeDef erase; // Define the erase structure
uint32_t error = 0; // Variable to store the error code
erase.TypeErase = FLASH_TYPEERASE_SECTORS; // Sector erase
erase.Sector = FLASH_SECTOR_11; // Sector to erase: Sector 11
erase.NbSectors = 1; // Number of sectors to erase: 1
erase.VoltageRange = FLASH_VOLTAGE_RANGE_3; // Voltage setting
HAL_FLASHEx_Erase(&erase, &error); // Erase
// Flash write
for (int i = 0; i < 8; i++)
{
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, writeAddr, testData[i]+1); // Write 8 bits
writeAddr += 1; // Advance address by 1 byte (8 bits)
}
HAL_FLASH_Lock(); // Flash lock
testData[0] = *((uint8_t*)flash_addr);
■Error content
error in final launch sequence:
Failed to execute MI command:
load path \\Debug\\flashTest.elf
Error message from debugger back end:
Error finishing flash operation
Failed to execute MI command:
load path \\Debug\\flashTest.elf
Error message from debugger back end:
Error flash finishing operation Failed to execute MI command: load path\\Debug\\flashTest.elf Error message from debugger back end: Error finishing flash operation Error finishing flash operation