2016-05-16 12:37 PM
Hi.
I tried to use __attribute__((at(address))) to define a global variable at certain address and Keil returned error L6971E, which is described herehttp://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0496c/CJAIGFIC.html
I don't really understand what is wrong, because if I use address at the beginning of RAM (let say 0x20000020) the error occurs, but if I use higher address (let say 0x20002000), the error doesn't occur.Could anyone please explain what is wrong here and is it just OK if I define higher address, which is not causing an error?Secondly, do I have to be aware of data alignment when using __attribute__((at(address)))?I mean, do I have to use only 0x.......0, 0x.......4, 0x.......8, ... addresses for integers, only 0x.......0, 0x.......2, 0x.......4, 0x.......6, 0x.......8, ... addresses for half-word and any kind of address for bytes?Thanks a lot.2016-05-16 01:14 PM
Likely because either the linker has given that space to some earlier defined variable, or it otherwise clashes with how space is being allocated. It's not a multi-pass, best fit, type process.
Carve out a location for these fixed items, ideally in a structure, and outside the normal load region. ie create a region at 0x20000000[0x100] that is purely for this stuff.Having a lot of fixed address variables is a poor design strategy.2016-05-16 01:29 PM
We just need to have few fixed variables (2 actually), for access them from a Delphi program via debug protocol. So, they should be located on a known address.
Do you have an example, how to create separate location for these fixed items? This is probably done in scatter file?Am I true about address choosing and data alignment (see my original post)?Thanks2016-05-16 01:53 PM
I would use the natural alignment the compiler uses for those variables, as it would if you listed then within a structure. The Cortex-M3/4 doesn't have too many alignment criticalities, mostly you'd see issues with double word ie 64-bit integers or doubles.