GCC Place var/struct @ place in RAM

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

Tabulous
Posts: 509
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 17 times

GCC Place var/struct @ place in RAM

Postby Tabulous » Mon Dec 19, 2016 1:54 pm

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")));

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: GCC Place var/struct @ place in RAM

Postby Giovanni » Mon Dec 19, 2016 2:02 pm

Hi,

There is no .noinit section defined, you may use .ramX where X is the ram sector.

Giovanni

Tabulous
Posts: 509
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 17 times

Re: GCC Place var/struct @ place in RAM

Postby Tabulous » Mon Dec 19, 2016 2:12 pm

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 ?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: GCC Place var/struct @ place in RAM

Postby Giovanni » Mon Dec 19, 2016 3:28 pm

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

Tabulous
Posts: 509
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 17 times

Re: GCC Place var/struct @ place in RAM

Postby Tabulous » Mon Dec 19, 2016 5:07 pm

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 ?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: GCC Place var/struct @ place in RAM

Postby Giovanni » Mon Dec 19, 2016 5:11 pm

I don't know, never had the need.

Giovanni

User avatar
alex31
Posts: 374
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 38 times
Been thanked: 61 times
Contact:

Re: GCC Place var/struct @ place in RAM

Postby alex31 » Tue Dec 20, 2016 10:31 am

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

Tabulous
Posts: 509
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 17 times

Re: GCC Place var/struct @ place in RAM

Postby Tabulous » Wed Dec 21, 2016 12:07 pm

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

User avatar
alex31
Posts: 374
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 38 times
Been thanked: 61 times
Contact:

Re: GCC Place var/struct @ place in RAM

Postby alex31 » Wed Dec 21, 2016 1:13 pm

I use black magic probe, not openocd ...

Tabulous
Posts: 509
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 17 times

Re: GCC Place var/struct @ place in RAM

Postby Tabulous » Wed Dec 21, 2016 2:32 pm

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.


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 12 guests