cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX HAL_FLASH read write

FJB2069
Associate III

I have a small working touchGFX project with freertos app on a stm32F746-disco.

 

I want to write a few variables to flash so I am trying to call write/read in StartDefaultTask, but I get a Hard Fault when I go to Lock the Flash.  I have tried a few different locations  (0x60000000 & 0x70000000) that should not be used.

Why might this not be working?

 

 

/* USER CODE BEGIN 0 */

uint32_t Flash_Address = 0x60000000;  

/* USER CODE END 0 */


void StartDefaultTask(void *argument)
{
  /* USER CODE BEGIN 5 */


//  /* Infinite loop */
  for(;;)
  {
    osDelay(100);

	 HAL_FLASH_Unlock();
   	 HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Flash_Address, 0x13);
   	 HAL_FLASH_Lock();

  }
  /* USER CODE END 5 */
}

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

Flash_Address = 0x60000000 ? How?

The Flash address starts at 0x08000000 and end address at 0x80FFFFF for STM32F746 MCU. 0x60000000 address is not in the range of the internal Flash. Also your procedure to write to the Flash is incorrect. You need to erase the Flash sector before writing to it. Please refer to this example on how to write to the infernal flash memory: https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects/STM32756G_EVAL/Examples/FLASH/FLASH_EraseProgram

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
SofLit
ST Employee

Hello,

Flash_Address = 0x60000000 ? How?

The Flash address starts at 0x08000000 and end address at 0x80FFFFF for STM32F746 MCU. 0x60000000 address is not in the range of the internal Flash. Also your procedure to write to the Flash is incorrect. You need to erase the Flash sector before writing to it. Please refer to this example on how to write to the infernal flash memory: https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects/STM32756G_EVAL/Examples/FLASH/FLASH_EraseProgram

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
FJB2069
Associate III

Thanks!