Hi, I am using the IAR toolchain for our Renesas M16C based project. The device uses a lot of configuration data which are stored within an eeprom. In order to define the placement, I have something like this: eeprom.c: #pragma dataseg="E2PROM_DATA" #define extern /* empty */ #include "eeprom.h" #pragma dataseg=default /* EOF */ and eeprom.h: extern __no_init unsigned char MBUS_exist; extern __no_init char E2_VERSION_TEXT[20]; extern __no_init unsigned char CAN_exists; extern __no_init unsigned char MBUS_exists; /* and so on. */ /* EOF */
I tell the linker to place the E2PROM_DATA segment where the eeprom is mapped into the address space and can use the data from other c sources by including eeprom.h BUT The linker throws away all variables in eeprom.h which are not used anywhere in the projet (there is NO OPTIMIZATION selected!!). This is really bad, since I need a stable address mapping for all configuration data; there might be parameters which may be needed in later software versions; sometimes I build testversions which do not contain all parts. I allways need the variables at the same adresses.
I did already asked the IAR support, but did not get a usable answer (they told me to use volatile, but this does not change anything).
I see the following approaches: a) define a big struct which contains all variables and put that struct into E2PROM_DATA b) put dummy references to all variables into my project c) define the variables in some assembler source. d) the IAR toolchain allows to put variables at numerically known addresses, I could place every variable at some pre-calculated address
a) I would have to change all code referring to (say) E2_VERSION_TEXT to s.E2_VERSION_TEXT (where s is the name of the struct variable). Since my project contains lot of old code, this is not very good. b) ugly, blows up my project with "useless" code (the linker is quite "smart", you have to DO something with a variable or the code is optimized away). c) ugly and dangerous, I have to keep the assembler definitions and c declarations in sync. d) IMHO address calculations should be done by tools, not by programmes due to possible errors.
Has anyone some better idea?
Greetings Dirk Zabel