Skip to main content
Visitor II
June 29, 2017
Question

STM32H7 HAL Flash Program

  • June 29, 2017
  • 4 replies
  • 5246 views
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
    This topic has been closed for replies.

    4 replies

    Technical Moderator
    June 29, 2017
    Posted on June 29, 2017 at 15:17

    Hello

    tenson

    ,

    I will check and raiseinternally yourreported issue and therequest to

    support 8, 16 or 32-bit programming parallelisms in the HAL_FLASH_Program API

    .

    Icome back to you if we will have any taken actions.

    Regards

    Imen

    Visitor II
    June 29, 2017
    Posted on June 29, 2017 at 17:18

    One further question regarding STM32H7xx FLASH operations:

    Looking at the RM0433 user manual:

    Chapter 3.2, page 112

    Flash programming by 256 bits

    Double-word, word, half-word and byte write operations

    Chapter 3.3.7, page 121

    Since a 10-bit ECC code is associated to each 256-bit data Flash word, only write

    operations by 256 bits are supported.

    Does this mean that it is not possible to write a single byte into the FLASH memory on the STM32H7?

    Thank you and best regards,

    Technical Moderator
    June 29, 2017
    Posted on June 29, 2017 at 18:45

    Hi

    Korinsek.Gasper

    ,

    Does this mean that it is not possible to write a single byte into the FLASH memory on the STM32H7?

    It is possible to force

    the write operation without filling the missing data by activating the FW1/2

    bit in FLASH_CR1/2.

    This will force all missing data “high�?.

    You can use the SRAM

    backup to build a word with 256 bit before write into the Flash. It's more optimized.

    Regards

    Imen

    Visitor II
    June 29, 2017
    Posted on June 29, 2017 at 15:20

    Hello Imen D.

    Thank you for fast response.

    Visitor II
    April 16, 2018
    Posted on April 16, 2018 at 09:04

    Hi, I am using V1.2.0 of stm32h7xx_hal_flash_ex to erase individual sectors. Directly after the erase cycle I do a blank check which reports errors. When setting a breakpoint I can see in the debugger that effectively the flash is not empty:

    0690X00000604RBQAY.jpg

    When stepping the flash contents updates and then it is completely erased.

    I have tried with different voltage range settings but nothing helps. What could be the issue here?

    Thanks,

    Andre

    ST Employee
    May 4, 2018
    Posted on May 04, 2018 at 11:52

    Hello Andre,

    1/ Does the HAL API HAL_FLASHEx_Erase() report a HAL_ERROR or HAL_OK?

    2/ Is Cache activated in your application?

    In fact, when cache is activated, the CPU could be seeing an old data available in cache, and not the new data available in flash memory. So, a cache maintenance in needed after erase.

    BR,

    Tarek

    Technical Moderator
    October 8, 2018

    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

    Visitor II
    February 16, 2020

    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).. ?

    Super User
    February 16, 2020

    > 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