2024-10-17 02:13 AM - last edited on 2024-10-17 02:42 AM by SofLit
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(®ion);
/* 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);
2024-10-17 05:44 AM
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:
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.
2024-10-17 07:17 PM
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.
2024-10-22 07:01 AM
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.
2024-10-23 08:57 AM
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)
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.
2024-10-23 10:53 PM
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.
2024-11-12 05:12 AM
Hello @Shiro,
>>The correct process is,Init ->Erase->Program->Read.
But Init->Erase->Read it'll report error.
Yes! According to RM:
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:
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.