cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 HAL Flash Program

Gasper Korinsek
Associate II
Posted on June 29, 2017 at 14:22

7There is a potential bug in the HAL library ver 1.0 for the STM32H7:

Functions FLASH_Erase_Sector and FLASH_MassErase (file stm32h7xx_hal_flash_ex.c,) change the PSIZE value in the FLASH->CRx register according to the VoltageRange argument. The function HAL_FLASH_Program (stm32h7xx_hal_flash.c) seems to expect the default PSIZE value (64-bit).

In other words: calling FLASH_Erase_Sector or FLASH_MassErase functions with a VoltageRange argument other than FLASH_VOLTAGE_RANGE_4, changes the behaviour of the HAL_FLASH_Program function.

Separate questions:

Is there any plan to support 8, 16 or 32-bit programming parallelisms in the HAL_FLASH_Program API?

#flash #hal #stm32h7
14 REPLIES 14
Imen.D
ST Employee

Hello,

We have already passed this issue along to our development team.

A new API __HAL_FLASH_SET_PSIZE() will be added to Flash driver to set the Flash parallelism parameter for Program and Erase operations.

Please, keep an eye out for the next update !

Kind Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

can you please send me the application code

EZamo.1
Associate III

I'm using the default linker script (Auto-generated by STM32CubeIDE for the STM32H743) and it shows the various sections getting mapped to the 2MB of flash. However, how do I know which memory/sector is unused and therefore safe to FLASH_Erase_Sector / HAL_FLASH_Program ? I don't have too much data that I need in NVM, but according to UM2217, it sounds like you have to erase an entire 128Kbytes sector, but flashing is done in 32-byte chunks only (256-bit).. ?

> how do I know which memory/sector is unused

Usually one can be pretty sure that the very first sector at 0x08000000 (bank 1 sector 0) is occupied by user application or bootloader.

About the rest, you can only check whether a whole page is erased (all bytes are FFs) or not.

>  it sounds like you have to erase an entire 128Kbytes sector, but flashing is done in 32-byte chunks only (256-bit).

Correct.

-- pa

Hi Volker Bremauer,

Can you provide the project in public?

Thanks in advance.