Place a few variables in fixed location in RAM with NOINIT attribute

cancel
Showing results for 
Search instead for 
Did you mean: 

Place a few variables in fixed location in RAM with NOINIT attribute

351 Views
ping1
Contributor IV

Hello, All

I need to put a few of them into fixed location, purpose of this is to pass some settings between second bootloader and application, I can put variables with  __SECTION(noinit, bank) attribute, but I am not sure how to put it into fixed location in that bank, read this post here : https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Placing-data-at-an-address/m-p/473552

however, not all information is there on how to create own sections and own linker script, and it is not only one variable needs to be in fixed location, there is a few. I wonder what is the way to do that, it is easy with TI's compiler with following #progma

#pragma NOINIT (myVariables)
#pragma location = 0x20000000
uint32_t myVariables;

Anything equivalent for NXP?

Regards!

Ping

 

Labels (1)
Tags (1)
0 Kudos
9 Replies

306 Views
crist_xu
NXP Employee
NXP Employee

Hi, 

     you can try __attribute__((at(address), zero_init)), the address is where you want to place your data if you use keil compiler v5,

and with __attribute__((section(".bss.ARM.__at_address"))), the addres has the same meaning, if you use keil compiler v6. And i think 

the GCC has the same funtions as the Keil.

 

Regards,

           Crist

299 Views
ping1
Contributor IV

Hi, Crist

tried second one as following:

__attribute__((section(".bss.ARM.__at_0x20019000"))) uint8_t testBuf2[128];

it is not working, it still put variables at another address, it seems 0-inited. 

The first one doesn't compile.

Not sure what I did wrong? I am using NXP MCUXpresso v11.3.

Regards!

Ping

Ping

0 Kudos

302 Views
ping1
Contributor IV

Hi, Crist,

Thanks for your input!

The first one doesn't compile, I get a warning saying zero_init attribute ignored, changed to noinit, got same warning.

The second one seems hopeful, but how to input the absolute address there? could you give an example please? 

Regards!

Ping

 

0 Kudos

292 Views
crist_xu
NXP Employee
NXP Employee

Hi,

    It seems that that two codes are all for Keil. So if you want to use this in MCUXpresso, i think you 

can try this, i have tried this under the GCC, sorry for that i do not have the MCUXpresso installed, but i think that this can work:

   put this in your link file:

address (RW) : ORIGIN = the absolute address(such as 0x20000000), LENGTH = array_size(such as100)

.noninit (NOLOAD):
{
*(.noninit)
} > address

   and  in your main code, define the variable like this:

  __attribute__((section(".noninit"))) __attribute__((used)) int noninit_var[100];

  After that, the noninit_var will be placed into the address you just want, and under noiniting. So the way is to define a section which has only your variable, and then place it at the address.

 

Regards,

     Crist

 

0 Kudos

273 Views
ping1
Contributor IV

Hi, Crist

I tried add small two linker files with your additional memory and section defines, unfortunately, the noninit_var[100] is not end up in the intended address, it is only noinited. 

Also tried to modify the automatically generated linker file and add the sections, it ends up with a hard fault when running.

Could you provide a simple example with a whole project please?

Regards!

Ping 

0 Kudos

274 Views
ping1
Contributor IV

Hi, Crist

Thanks for reply, I am new to NXP and linker script and currently use Managed Linker script from IDE. So have a few questions:

1. Do I need to modify memory configuration? I think the address part need to be put in memory region.

2. Same question for new .noinit  section, it won't be generated automatically, shall do a separate small linker file for this too?  

3. Or do I need to create another linker file for this only, will it be work together with the automatically generated one? or will it in conflict with each other?

Or shall I stop use the automatically generated one, and create my own - which I need some instructions.

Regards!

Ping

 

0 Kudos

265 Views
crist_xu
NXP Employee
NXP Employee

Hi, Ping,

      Sorry, i am not so familiar for the MCUXpresso, i am using the ARM-NONE-EABI-GCC under the linux, I think you shoud create a new linker script by yourself, I will attach the link file and the main.c of the GCC, you can take it as a reference. 

      Also, if it is possiable, could you please attach your project? I think it will be helpful for your issue.

 

Regards,

    Crist

0 Kudos

336 Views
gusarambula
NXP TechSupport
NXP TechSupport

Hello Ping,

There following Community Document has some more information on how to handle variables in the NoInit section. While it’s not based on an i.MXRT, the basic concepts remain.

https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/EXAMPLE-S32K144-noinit-section-usage/t...

I hope that this information helps!

Regards,
Gustavo

0 Kudos

321 Views
ping1
Contributor IV

Hello, Gustavo

Thanks for reply, the link answered how to make variable NoInit, which can be done by __SECTION(noinit, bank), but didn't say how to make it at fixed location.

Is there a way to do let a variable at a fixed location pls?

Regards!

Ping

Tags (1)
0 Kudos