2023-04-03 11:23 PM
So i use to stm32cubeide & stm32h743zi. I want to create a variable that the system does not initailize even if the after software reset. just like __no_init in IAR.
i follow this method. but i can't.
https://atadiat.com/en/e-how-to-preserve-a-variable-in-ram-between-software-resets/
Solved! Go to Solution.
2023-04-04 12:56 AM
Try this:
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 319K
NOINIT(xrw) : ORIGIN = 0x2004FC00, LENGTH = 1K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
}
Then create section:
.noinit :
{
KEEP(*(.noinitdata))
} >NOINIT
and create variable:
uint32_t __attribute__(( section(".noinitdata") )) first_run;
2023-04-04 12:43 AM
The default GCC startup code is much simpler than IAR, it initializes only one array of data and one BSS.
The easiest is to use one of SRAM blocks of stm32h743 that are not used for .data, .bss or stack/heap in your linker script. For example if your script uses the AXI SRAM for the "main" data, use SRAM2 or TCM RAM.
2023-04-04 12:56 AM
Try this:
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 319K
NOINIT(xrw) : ORIGIN = 0x2004FC00, LENGTH = 1K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
}
Then create section:
.noinit :
{
KEEP(*(.noinitdata))
} >NOINIT
and create variable:
uint32_t __attribute__(( section(".noinitdata") )) first_run;
2023-04-04 01:32 AM
it is not working.
Couriously, depending on the location of the function that puts a value in the variable, it either keeps or does not retain the value after the reset.
2023-04-04 01:48 AM
Someone had simillar problem here:
https://stackoverflow.com/questions/65577391/stm32-create-ram-section
Try use this instruction.
2023-04-04 02:46 AM
i had set up to use I Cache and D Cache. It didn't work normally at this time. Each cahe is diabled, so it works normally. but i don't know why.
2023-04-20 12:42 AM
@ikassma Do You resolve your problem?
2023-04-20 09:35 PM
yes! I Cache and D Cache Disable. it is works.
Thanks to your advice.