Skip to main content
Associate
September 5, 2024
Solved

Test for EDATA FLASH ECC code on STM32H563

  • September 5, 2024
  • 1 reply
  • 2393 views

Hello All,

We are looking into testing our code that access the EDATA and handle FLASH ECCC (single bit error) and ECCD (double bit error).

How can we simulate those errors?

Is it possible to insert single bit or double bit errors using a JTAG? It would useful to test the code without modifying it.

Any alternatives?

This topic has been closed for replies.
Best answer by L_P

The solution is to write to FLASH at least twice using different data for every cycle without erasing. This will trigger an ECC error on the next read attempt.

1 reply

ST Technical Moderator
September 9, 2024

Hello @L_P 

Please refer to the AN5342, it explains how you can trigger an ECC error. 

 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
L_PAuthorBest answer
Associate
September 10, 2024

The solution is to write to FLASH at least twice using different data for every cycle without erasing. This will trigger an ECC error on the next read attempt.

Associate II
September 18, 2024

What method did you use to write to flash? I am also trying to simulate ECC errors in flash, and have tried the above method of writing to flash at least twice with different data without erasing, and then reading. This has not worked for me though.

 

Here's my code:

 if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, Address, ((uint32_t)FlashWordB)) != HAL_OK)
 {
	 Error_Handler();
 }
 if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, Address, ((uint32_t)FlashWordA)) != HAL_OK)
 {
	 Error_Handler();
 }
 uint64_t readData[4];

 for (int i = 0; i < 4; i++) {
	 readData[i] = *((uint64_t *)(Address + i * 8)); // Read 64 bits at a time
 }

 FlashWordB is all 0's, and FlashWordA is all 1's. What's weird though is that when I check the memory afterwards with the cubeProgrammer, that address in memory is still all 0's. When I step through this code with the debugger, the HAL_FLASH_Program function runs without any errors, and it seems that for whatever reason it is just not writing the second time it is called.

@Amel NASRI Do you have any ideas?

 

Thank you!