cancel
Showing results for 
Search instead for 
Did you mean: 

stm32h563 edata Code Generation issue

BenoitS
Associate

Hello,

On flash option byte I need to use only one sector. Only Edata bank1 is activate. No other option bytes are required.

CubeMx generate MX_FLASH_Init with Edata configuration commented. What other option byte is necessary to select to use Edata on bank1?

Can you help me?

target: STM32H563ZI

stm32CubeMx 6.11.0

stm32Cube MCU Package STM32H5 1.2.0

 

Regards 

2 REPLIES 2
CMAHM.1
ST Employee

Hello @BenoitS ,

Did you try to check the EDATA1_EN option byte using STM3CubeProgrammer?

CMAHM1_0-1714727150181.png

Hi @CMAHM.1

I have the similar question. My board is STM32H573I-DK. EData seems not be enabled after MX_FLASH_Init().

Here is the code generated by CubeMX.

 

static void MX_FLASH_Init(void)
{

    /* USER CODE BEGIN FLASH_Init 0 */

    /* USER CODE END FLASH_Init 0 */

    FLASH_OBProgramInitTypeDef pOBInit = {0};

    /* USER CODE BEGIN FLASH_Init 1 */

    /* USER CODE END FLASH_Init 1 */
    if (HAL_FLASH_Unlock() != HAL_OK)
    {
        Error_Handler();
    }

    /* Option Bytes settings */

    if (HAL_FLASH_OB_Unlock() != HAL_OK)
    {
        Error_Handler();
    }
    pOBInit.OptionType = OPTIONBYTE_EDATA;
    pOBInit.Banks = FLASH_BANK_BOTH;
    pOBInit.EDATASize = 1;
    if (HAL_FLASHEx_OBProgram(&pOBInit) != HAL_OK)
    {
        Error_Handler();
    }
    if (HAL_FLASH_OB_Lock() != HAL_OK)
    {
        Error_Handler();
    }
    if (HAL_FLASH_Lock() != HAL_OK)
    {
        Error_Handler();
    }

    /* Launch Option Bytes Loading */
    /*HAL_FLASH_OB_Launch(); */

    /* USER CODE BEGIN FLASH_Init 2 */

    /* USER CODE END FLASH_Init 2 */

}

 

 

I tried to access 0x0900A800 by CubeProgrammer but it showed Data read failed. 

But if checked the EDATA1_EN option by CubeProgrammer. It worked.

Is there any bug or what I missed?

P.S. I also uncommented  

/*HAL_FLASH_OB_Launch(); */

but still not worked.