Hi all,
Apparently not the first time discussed In this forum but I still could use some expertise:
I have a Cortex M0+ device and need a variable that is not cleared by a WDT reset. I have added a "noinit" section in the scatter file which now looks like this:
; *************************************************************; *** Scatter-Loading Description File generated by uVision ***; *************************************************************
LR_IROM1 0x08000000 0x00006000 { ; load region size_region ER_IROM1 0x08000000 0x00006000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) .ANY (+XO) } RW_IRAM1 0x20000000 0x00000BFC { ; RW data .ANY (+RW +ZI) } RW_NOINIT 0x20000BFC UNINIT 0x00000004 { ; Uninitialized data, 4 bytes .ANY (+RW) }}
In my code a declare a variable like this:
uint32_t testVariable __attribute__((section("NOINIT"), aligned(4)));
However, after compilation, my .map file says this:
testVariable 0x2000003c Data 4 main.o(NOINIT)
I.e. it is still in the IRAM1 section and is, consequently, zeroed after WDT reset.
How do I fix this ?
Cheers
Eric
Hi Eric.
In a nutshell, the section name containing variables you want uninitialized must start with ".bss", so in your case replace the name "NOINIT" to ".bss.NOINIT" .Explanation:in the document: https://developer.arm.com/documentation/101754/0621/armclang-Reference/Compiler-specific-Function--Variable--and-Type-Attributes/--attribute----section--name-----variable-attribute
it is stated:
To place ZI data in a named section, the <name> must start with the .bss. prefix. Non-ZI data cannot be placed in a section name with the .bss. prefix.
<name>
.bss.
Continuing with the next document: https://developer.arm.com/documentation/101754/0621/armlink-Reference/Scatter-File-Syntax/Execution-region-descriptions/Execution-region-attributes?lang=en
stating:
UNINIT
Use to create execution regions containing uninitialized data or memory-mapped I/O. Only ZI output sections are affected. For example, in the following ER_RW region only the ZI part is uninitialized
Best regards, Milorad
Hi Milorad,
Thank you for your swift response. Your suggestion did not help as this, according to https://developer.arm.com/documentation/ka003046/latest/, is a compiler version related issue. However, I indirectly found the fault: The path I gave to my scatter file was the same as the compiler had, i.e. my noinit section was overwritten every time I compiled. Stupid misstake !
Thanks a lot for your help !
\Eric