I am trying to design a UART bootloader for STM32G474RE microcontroller. I am having problem in Flash erasing part of the code. Before designing bootloader for STM32G474RE microcontroller, I tried for STM32F767Zi Nucleo kit. and it is working fine on that kit. The code for the Nucleo kit is as follows:
if( is_first_block ) {
printf("Erasing the Flash memory...\r\n");
//Erase the Flash
FLASH_EraseInitTypeDef EraseInitStruct;
uint32_t SectorError;
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.Sector = FLASH_SECTOR_5;
EraseInitStruct.NbSectors = 2; //erase 2 sectors(5,6)
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
ret = HAL_FLASHEx_Erase( &EraseInitStruct, &SectorError );
if( ret != HAL_OK )
{
break;
}
}
Here I am erasing 2 sectors.
Now when I am trying for STM32G474RE, I am having following issues:
- There is no option to erase sectors (Only pages)
- EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3; this command is giving error when I compile the code. ( I have checked stm32g4xx_hal_flash.h file but there is no information about it whereas stm32f7xx_hal_flash.h file has information about it.
It would be great if some could help me and guide me about these issue from their experience. I have attached photo of the error. Please have a look.