GCC Place var/struct @ place in RAM

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

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

GCC Place var/struct @ place in RAM

Post 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")));
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: GCC Place var/struct @ place in RAM

Post by Giovanni »

Hi,

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

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: GCC Place var/struct @ place in RAM

Post 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 ?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: GCC Place var/struct @ place in RAM

Post 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
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: GCC Place var/struct @ place in RAM

Post 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 ?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: GCC Place var/struct @ place in RAM

Post by Giovanni »

I don't know, never had the need.

Giovanni
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

Re: GCC Place var/struct @ place in RAM

Post 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
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: GCC Place var/struct @ place in RAM

Post 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
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

Re: GCC Place var/struct @ place in RAM

Post by alex31 »

I use black magic probe, not openocd ...
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: GCC Place var/struct @ place in RAM

Post 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.
Post Reply