Page 1 of 1
GCC Place var/struct @ place in RAM
Posted: Mon Dec 19, 2016 1:54 pm
by Tabulous
i need to place a var/struct that is ".noinit" @ a specific place in ram, how would one achieve this with chibios build ?
heres my var declared as noint
Code: Select all
static int32_t var __attribute__ ((section (".noinit")));
Re: GCC Place var/struct @ place in RAM
Posted: Mon Dec 19, 2016 2:02 pm
by Giovanni
Hi,
There is no .noinit section defined, you may use .ramX where X is the ram sector.
Giovanni
Re: GCC Place var/struct @ place in RAM
Posted: Mon Dec 19, 2016 2:12 pm
by Tabulous
Giovanni wrote:Hi,
There is no .noinit section defined, you may use .ramX where X is the ram sector.
Giovanni
are them sections non initialized ?
Re: GCC Place var/struct @ place in RAM
Posted: Mon Dec 19, 2016 3:28 pm
by Giovanni
There are 3 kinds:
.ramX_init is initialized with data or code.
.ramX_clear is zeroed.
-ramX is not initialized.
Symbols are exported for the base of the various sub-areas:
Code: Select all
.ram7_init : ALIGN(4)
{
. = ALIGN(4);
__ram7_init_text__ = LOADADDR(.ram7_init);
__ram7_init__ = .;
KEEP(*(.ram7_init))
KEEP(*(.ram7_init.*))
. = ALIGN(4);
} > ram7 AT > RAM_INIT_FLASH_LMA
.ram7 (NOLOAD) : ALIGN(4)
{
. = ALIGN(4);
__ram7_clear__ = .;
*(.ram7_clear)
*(.ram7_clear.*)
. = ALIGN(4);
__ram7_noinit__ = .;
*(.ram7)
*(.ram7.*)
. = ALIGN(4);
__ram7_free__ = .;
} > ram7
Giovanni
Re: GCC Place var/struct @ place in RAM
Posted: Mon Dec 19, 2016 5:07 pm
by Tabulous
Giovanni wrote:There are 3 kinds:
.ramX_init is initialized with data or code.
.ramX_clear is zeroed.
-ramX is not initialized.
Symbols are exported for the base of the various sub-areas:
Code: Select all
.ram7_init : ALIGN(4)
{
. = ALIGN(4);
__ram7_init_text__ = LOADADDR(.ram7_init);
__ram7_init__ = .;
KEEP(*(.ram7_init))
KEEP(*(.ram7_init.*))
. = ALIGN(4);
} > ram7 AT > RAM_INIT_FLASH_LMA
.ram7 (NOLOAD) : ALIGN(4)
{
. = ALIGN(4);
__ram7_clear__ = .;
*(.ram7_clear)
*(.ram7_clear.*)
. = ALIGN(4);
__ram7_noinit__ = .;
*(.ram7)
*(.ram7.*)
. = ALIGN(4);
__ram7_free__ = .;
} > ram7
Giovanni
mm seems the ocd debugger resets the RAM, is there a way to stop this ?
Re: GCC Place var/struct @ place in RAM
Posted: Mon Dec 19, 2016 5:11 pm
by Giovanni
I don't know, never had the need.
Giovanni
Re: GCC Place var/struct @ place in RAM
Posted: Tue Dec 20, 2016 10:31 am
by alex31
many thanks for the question, and his answer !
I had struggle with non initialization of static variable in ram section for some months, because i used the ramX which is not init.
I will be able to remove the memset that i had to to to manually initialize variable or arrays.
Now that the api is written and lot code use it, it must be kept as it is, but, for conformance with standard variable declaration where
init is done, i had choosen
.ramX_noinit is not initialized.
.ramX_clear is zeroed.
-ramX is initialized with data or code.
Anyway, thanks for information
Alexandre
Re: GCC Place var/struct @ place in RAM
Posted: Wed Dec 21, 2016 12:07 pm
by Tabulous
alex31 wrote:many thanks for the question, and his answer !
I had struggle with non initialization of static variable in ram section for some months, because i used the ramX which is not init.
I will be able to remove the memset that i had to to to manually initialize variable or arrays.
Now that the api is written and lot code use it, it must be kept as it is, but, for conformance with standard variable declaration where
init is done, i had choosen
.ramX_noinit is not initialized.
.ramX_clear is zeroed.
-ramX is initialized with data or code.
Anyway, thanks for information
Alexandre
Have you found away to stop the ocd debugger clearing the noinit sections ?
Everytime i run it it wipes the sections
Re: GCC Place var/struct @ place in RAM
Posted: Wed Dec 21, 2016 1:13 pm
by alex31
I use black magic probe, not openocd ...
Re: GCC Place var/struct @ place in RAM
Posted: Wed Dec 21, 2016 2:32 pm
by Tabulous
Just for others info
it happens when you have selected load image, if you un-tick this then it wont re-flash the image and wont wipe the noint memory.