Skip to main content
JFung.1
Associate II
October 20, 2023
Solved

H563 will have Hardfault when enable SRAM3 ECC

  • October 20, 2023
  • 7 replies
  • 3408 views

I am using the Nucleo board (H563) to test the SRAM ECC

I have create a new project by board selector.

Just have several printf function at main to print out to the SWO.

It is working well without setting the SRAM ECC enable.

However, once set the SRAM3 ECC it will jump to hardfault() after bootup.

 

** I want to put all program under the ECC protection.

   Therefore the heap, stack and bss should be place at ECC protected area.

   How to achieve this?

RAMCFG

SRAM1: HardErase: Enable

SRAM2: HardErase: Enable

 Error code correction: StartECC

SRAM3: HardErase: Enable

 Error code correction: StartECC



STM32H563ZITX_FLASH.ld

------------------------------------------

/* Highest address of the user mode stack */

_estack = ORIGIN(RAM1) + LENGTH(RAM1); /* end of "RAM" Ram type memory */



_Min_Heap_Size = 0x200; /* required amount of heap */

_Min_Stack_Size = 0x400; /* required amount of stack */



/* Memories definition */

MEMORY

{

/* RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K */

RAM1 (xrw) : ORIGIN = 0x20000000, LENGTH = 256K

RAM2 (xrw) : ORIGIN = 0x20040000, LENGTH = 64K

RAM3 (xrw) : ORIGIN = 0x20050000, LENGTH = 256K

BKPSRAM (xrw) : ORIGIN = 0x40036400, LENGTH = 4K

FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K

}

 

My setting as below:

 

 

 

 

This topic has been closed for replies.
Best answer by Tesla DeLorean

>>However, how to do it?

Put a place holder value in the Vector Table, ie 0x20002000, and then once you have the RAM3 suitably initialized,  ldr sp, =0x20052000, or whatever the actual symbol is. ldr sp, =_estack

7 replies

Tesla DeLorean
Guru
October 20, 2023

Expect that you'll need to clear the memory first, say in startup.s, so it has known/valid content in the data and ecc words.

Also watch where the initial SP is pointing,you might need to put a place-holder value in the vector table, and then move it later.

Determine what code is faulting, check your NMI Handler also.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
JFung.1
JFung.1Author
Associate II
October 20, 2023

I already have selected the hardware erase in the RAMCFG option.

How to do that?

JFung.1
JFung.1Author
Associate II
October 20, 2023

I have done more test on it.

If the "_estack" pointer is placed at the SRAM area, and that area to perform Hardware Erase, Hardfault() occur.

If no Hardware Erase is performed and the stack and heap placed at RAM1, both RAM2 and RAM3 ECC could started.

 

So yes, seems the RAM ECC should set before the stack and heap place at that area.

However, how to do it?