AnsweredAssumed Answered

MPC-5125 Linker Command File Guidance

Question asked by Tim Hutchinson on Nov 14, 2013
Latest reply on May 22, 2014 by Tim Hutchinson

Hi All,


I need to locate all the uninitialized data variables from a *.c module to MRAM that I have available on the processor LocalPlus Bus. I'm having a difficult time finding documentation for customizing the Linker Command File for an MPC-5125 project using the Classic CodeWarrior for MobileGT V9.2.


I'm guessing that I need to add an entry to the MEMORY section of my project.lcf file like this (added MYMRAM to existing MEMORY contents):


MEMORY      {      SDRAM:  org = 0x00000000, len = 0x10000000      // 256MB DDR SDRAM  = 0x0000_0000 to 0x0FFF_FFFF      MYMRAM: org = 0x10000000, len = 0x00100000      // 1MB MRAM = 0x1000_0000 to 0x100F_FFFF on Processor LocalPlus Bus      SRAM:   org = 0x30000000, len = 0x00008000      // 32K Internal SRAM = 0x3000_0000 to 0x3000_7FFF      IMMR:   org = 0x80000000, len = 0x00100000      // 1MB     = 0x8000_0000 to 0x800F_FFFF      FLASH:  org = 0xFFF00000, len = 0x00800000      // 8MB FLASH   = 0xFFF0_0000 to 0x1_006F_FFFF      }    



Then add an entry to the SECTIONS section of my project.lcf file like this:


SECTIONS      { /* Existing Group definitions for .code, etc. here */       GROUP : {                    /* Add this entry */            .mymram_data : {}           } > MYMRAM       GROUP : {            .rosdata : {}           .sdata : {}           .sbss : {}           } > ram    GROUP : {           .rosdata2 : {}           .sdata2 : {}           .sbss2 : {}           } > ram      GROUP : {           .data : {}           .bss : {}           .image (DATA) :                {                __START_IMAGE_DATA =.;                * (.image_data)                  }           } > ram      }     


Finally I think I need to add a pragma to my vars.c module to put all variables in the myMram section:

#pragma push              //Store pragma context  #pragma section  data_type sdata_type ".mymram_data"  ".mymram_data" //switch to the myMram_data section to store data  unsigned char SourceAlphas[gcMAXINCHANS][gcALPHALENGTH];  unsigned char DestAlphas[gcMAXOUTCHANS][gcALPHALENGTH];  unsigned char OptoAlphas[gcMAXOPTOS][gcALPHALENGTH];  unsigned char RelayAlphas[gcMAXRELAYS][gcALPHALENGTH];  #pragma pop           //Restore pragma context    



When I compile I get the following compiler warning: "No linker command file input for section '.mymram_data' in file ...\project\vars.o. Output section '.mymram_data' will be created". When I look in the "extram_d.MAP file I see a section layout for ".mymram_data" with no data variables in it. I am wondering if I'm even close to a correct solution or way off base? Any documentation for locating a modules RAM variables in a specific address window using the MPC-5125? Maybe I'm close with all this and just need a little tweak? Thanks in advance to any who can help.


Best Regards,

Tim Hutchinson



I've also read that the section pragma is depreciated and instead I should use __declspec() like this? If this is right, how to do all vars in an entire module with this?

__declspec(section ".mymram_data") unsigned char SourceAlphas[gcMAXINCHANS][gcALPHALENGTH];