Skip to main content
Visitor II
October 17, 2024
Question

STM32H5 EDATA read err

  • October 17, 2024
  • 2 replies
  • 1859 views

I refer to than Example 

en.stm32cubeh5-v1-3-0\STM32Cube_FW_H5_V1.3.0\Projects\NUCLEO-H563ZI\Examples\FLASH\FLASH_EDATA_EraseProgram

 

Init and Write data in 0x0900C000 is ok.But when I restart the device and read data from 0x0900C000,the program entered NMI_Handler,but if I read from 0x0900C002,It worked.

If I didn't write data in 0x0900C000,I can read data successful.

Is there anying wrong with the config of MPU?

 

That's the config of MPU

static void MPU_Config(void)
{
 MPU_Attributes_InitTypeDef attr;
 MPU_Region_InitTypeDef region;

 /* Disable MPU before perloading and config update */
 HAL_MPU_Disable();

 /* Define cacheable memory via MPU */
 attr.Number = MPU_ATTRIBUTES_NUMBER0;
 attr.Attributes = 0 ;
 HAL_MPU_ConfigMemoryAttributes(&attr);

 /* BaseAddress-LimitAddress configuration */
 region.Enable = MPU_REGION_ENABLE;
 region.Number = MPU_REGION_NUMBER0;
 region.AttributesIndex = MPU_ATTRIBUTES_NUMBER0;
 region.BaseAddress = 0x0900C000U;
 region.LimitAddress = 0x0900C000U+(8*(FLASH_EDATA_SIZE/16)) - 1;
 region.AccessPermission = MPU_REGION_ALL_RW;
 region.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
 region.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
 HAL_MPU_ConfigRegion(&region);

 /* Enable the MPU */
 HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}

And after run these code:
if(EE_ProgramWord(0x0900C000, PART_USED_MARK) != HAL_OK)
 return HAL_ERROR;
 EE_ReadWord(0x09010800U);
 EE_ReadWord(0x0900C000U);
 
I can write into 0x0900C000,and read from 0x09010800,but when I read from 0x0900C000,the program entered NMI_Handler.
 
What should I do ...
    This topic has been closed for replies.

    2 replies

    ST Employee
    October 17, 2024

    Hello @Shiro, welcome to ST Community,

    The address 0x0900C000 falls within the high-cycle data area, which has specific configuration requirements, The EDATA1_EN and EDATA1_STRT bits should be set appropriately

    As per the RM0481, flash high cycle data section:

    "A bus error is generated on:

    • Attempt to access an address between 0x0900_0000 to 0x0901_7FFF and this address is not valid (EDATA(1/2)_EN not enabled or EDATA(1/2)_STRT not correct).
    • Attempt to fetch instructions from flash high-cycle data area 

    Erasing the data area sector is possible by normal erase request for the corresponding user flash sector"

    Also, check if there are any ECC errors reported when accessing the address, as the high-cycle data area is protected by a 6-bit ECC. Any issues with ECC could cause a bus error 

     

     

    ShiroAuthor
    Visitor II
    October 18, 2024

    ecc.jpgedata1.jpgedata2.jpg

     

    Hello,Sir,

    I configed these registers,you can see that abrove.But when I read 0x0900C000,there's something wrong with it,you can see status of ECC at first picture.

    ST Employee
    October 22, 2024

    Hello again @Shiro

    There is an an ECC error indicated by the FLASH_ECCDETR register, the data at 0x0900C000 is corrupted, this makes me think that the write wasn't ok, it may be incomplete or interrupted..

    On my side, starting from the same project and changing the base address to 0x0900C000 does not generate an NMI, are there any other changes you made?  

     

    ST Employee
    October 23, 2024

    When the ECCD the flag is raised, an NMI is generated, it can be masked in SBS registers (SBS flift ECC NMI mask register (SBS_ECCNMIR)) for data access (OTP, data area, RO data)

    SarraS_0-1729698870163.png

    You can mask the NMI by this setting this register, however, we have to determine the cause of corruption, will you be able to share a project to reproduce? 

    ShiroAuthor
    Visitor II
    October 24, 2024

    I tried the example STM32Cube_FW_H5_V1.3.0\Projects\NUCLEO-H563ZI\Examples\FLASH\FLASH_EDATA_EraseProgram

    I Annotate these codes:ProgramEdata .

    If I read without writing data to the specified sector, the program will report an error.

    To avoid error,I must first write 0xFFFF in these sectors.

     

    The correct process is,Init ->Erase->Program->Read.

    But Init->Erase->Read it'll report error.