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
Anything equivalent for NXP?
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.
tried second one as following:
__attribute__((section(".bss.ARM.__at_0x20019000"))) uint8_t testBuf2;
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.
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?
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)
} > address
and in your main code, define the variable like this:
__attribute__((section(".noninit"))) __attribute__((used)) int noninit_var;
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.
I tried add small two linker files with your additional memory and section defines, unfortunately, the noninit_var 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?
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.
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.
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.
I hope that this information helps!
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?