Skip to main content
FJB2069
Senior
December 6, 2024
Solved

TouchGFX HAL_FLASH read write

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 */
}

 

 

 

This topic has been closed for replies.
mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
December 6, 2024

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 "Best answer" on the reply which solved your issue or answered your question.

2 replies

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
December 6, 2024

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 "Best answer" on the reply which solved your issue or answered your question.
FJB2069
FJB2069Author
Senior
December 6, 2024

Thanks!