how to make keep ram value after software reset?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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.
- Labels:
-
IAR
-
RAM
-
STM32CubeIDE
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-04-04 1: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-04-04 1:48 AM
Someone had simillar problem here:
https://stackoverflow.com/questions/65577391/stm32-create-ram-section
Try use this instruction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-04-04 2: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-04-20 12:42 AM
@ikassma Do You resolve your problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-04-20 9:35 PM
yes! I Cache and D Cache Disable. it is works.
Thanks to your advice.
