Skip to main content
Associate
Question

Hard fault during EEPROM emulation Init with STM32C5A

Hello everyone,

I am having an issue with EEPROM Emulation initialization in my STM32 project.

I am currently trying to implement the EEPROM Emulation utility using STM32CubeMX2 v1.1.0.

The program starts with mx_system_init(), which initializes the peripherals and other required modules such as FLASH, RCC, etc. After that, I call mx_eeprom_emulation_init(). During this initialization, the MCU enters a HardFault.

Detailed information

The call hierarchy is:

main() → mx_eeprom_emulation_init() → EE_Init() → EE_FLITF_Init() → Page_GetState() → EE_ITF_FLASH_ReadData()

Inside EE_ITF_FLASH_ReadData(), the code tries to access address:

0x09000018

and immediately enters a HardFault.

I also analyzed the fault using the Fault Analyzer in STM32CubeProgrammer. The results are:

  • SCB_BFAR: 0x09000018
  • BusFault: Precise data access error (PRECISERR)
  • The BusFault is escalated to a HardFault (FORCED)

I also checked the EDATA_EN option bit in STM32CubeProgrammer, and it appears to be enabled correctly.

At this point, I am not sure why accessing the EDATA region causes a BusFault.

Has anyone experienced a similar issue with EEPROM Emulation / EDATA on STM32C5 devices?

Is there any additional configuration required, such as MPU/SAU memory region configuration, privilege settings, or FLASH security/access configuration, before accessing the EDATA area?

Any suggestions would be greatly appreciated.

Thank you.

28 replies

canyldrmAuthor
Associate

Hello everyone,

After a long investigation, I realized that there was one additional setting I had not enabled. In addition to the other configurations, enabling NMI Flash Exception Management resolved the issue I was experiencing during the initialization stage, at least for now.

I have not yet been able to test the write and read operations.

Thank you all for your comments and suggestions. Each one helped me during the troubleshooting process.

ST Employee

Hello ​@waclawek.jan , 

I believe that the 0x08400000 read and the 0x09000018 fault are not the same. With EDATA_EN=0, 0x08400000 is the alternative 64 KB mapping, and it is only used in that configuration. The reads that did not fault were therefore made on a different mapping from the one that faulted.

The fault at 0x09000018 came from a 64-bit access. The EDATA access width must match the configured mode, and a mismatch raises an ECC error reported as NMI. That is a separate mechanism from cacheability.

Kind regards, 

DK

"Please mark my answer as best by clicking on the “Accept as solution"" button if it fully answered your question. This will help other users find this solution faster.​"
waclawek.jan
Super User

Hi ​@Khaled_DHIF ,

Thanks for the explanation.

I need to finally pull out the ‘C5 Nucleo sitting at my shelf and get the blinky working to have a go at this personally… :-)

JW