Equivalent to IAR’s __no_init variable qualifier
Equivalent to IAR’s __no_init variable qualifier
Hi,
Is there a known workaround/alternative to IAR’s __no_init variable qualifier? The idea is to be able to NOT automatically initialize a variable, not even to 0. The C-runtime start-up code typically copies initialized data by copying from Flash, or in the case of non-initialized data, sets it to 0.
The purpose is to use a bit of RAM to store temporary data after a warm-reset, such as for debugging watchdog resets. I’d like to avoid having to mess with the startup code along with adding a new linker section in RAM.
Hello,
Thank you for reaching out to us!
NOLOAD works regardless of the region type.
The behavior of the IAR
__no_init
extension can be replicated by explicitly placing the variable into a special section, and modifying the linker script accordingly:
test.c:
__attribute__((section(".noinit"))) volatile int flag;
int main() {
if(flag == 3)
return 1;
flag = 3;
return 0;
}
linkerscript.ld:
....
.noinit (NOLOAD) :
{
*(.noinit)
*(.noinit.*)
} > RAM
....
Please let us know if we can be of further assistance.
__
Best regards,
The Open Source Tools Team

日本語
I was reading about NOLOAD (linker), but it seems to only apply to Flash/ROM, and not RAM. Is this true?