cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H5 EDATA read err

Shiro
Associate II

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 ...
6 REPLIES 6
Sarra.S
ST Employee

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 

 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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.

Sarra.S
ST Employee

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?  

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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? 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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.

Hello @Shiro

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

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

Yes! According to RM:

image (4).png

So yes, the high cycle data area should be written before read! 

You can handle it in the NMI interruptions so that when it triggers, you can make an exception for that use case, reset flags and go back to the code, you can use this part of the RM (in green) 

to create the exception: 

image (5).png

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.