2023-10-20 07:13 AM
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:
Solved! Go to Solution.
2023-10-20 09:00 AM
>>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
2023-10-20 07:17 AM - edited 2023-10-20 07:19 AM
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.
2023-10-20 07:19 AM
I already have selected the hardware erase in the RAMCFG option.
How to do that?
2023-10-20 08:23 AM
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?
2023-10-20 09:00 AM
>>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
2023-10-23 09:22 AM
Thank you for your advise.
If I place the stack at the RAM1 at compile time and put the SP to RAM3 after the MX_RAMCFG_Init() it could working properly.
However, below procedure will hardfault at memcpy before MX_RAMCFG_Init().
Place the stack into RAM3 at compile time,
copy the stack content at RAM3 to RAM1, change the SP from RAM3 to RAM1
Run the init functions including the MX_RAMCFG_Init().
** the MX_RAMCFG_Init() including the Hardware Erase
copy back the stack content at RAM1 to RAM3, change the SP from RAM1 to RAM3
is there any method to init the SRAM ECC before the .bss, .data and stack?
2024-08-27 05:57 AM
Hello JFung.1,
I hope you've found good answer to your issue since.
I'm being facing the same case but I'm not able to follow your path through the land of solution...
If you succeeded, do you mind to share your solution with me?
Thank you
2024-08-27 09:08 AM
I don't have good solution either.
Since I have another work to do than just pending on this topic.
I have tried if not copying the content it will have problem.
The interesting point is the "MX_RAMCFG_Init()" is run after the init.of the stack and memory.....