This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430 CCS 5.4/5.5 linker user guide

Other Parts Discussed in Thread: MSP430F5528

Is there a User's Guide for CCS MSP430 linker?

I'm relocating an executable image from high Flash (20-bit address) to RAM for execution.  I found a RAM execution example, but it defines the Flash and RAM addresses in the C-source.  I much prefer to reference the linker, since that's what ultimately determines memory placement.  I just need the starting addresses of the output sections...

Thank you,

-neil

  •  MSP430 Assembly Language Tools v 4.2 User's Guide SLAU131 contains the guide for the MSP430 linker.

    The LOAD_START, LOAD_END, LOAD_SIZE, RUN_START, RUN_END, RUN_SIZE Address and Dimension Operators in a linker command file define symbols for the load and run addresses.

    On a example ARM program I defined the following in the linker command file SECTIONS:

       dummy_handler		: RUN = RAM, LOAD= FLASH0, LOAD_START(ulHighHandlerLoadStart), LOAD_END(ulHighHandlerLoadEnd),LOAD_SIZE(ulHighHandlerSize), RUN_START( ulHighHandlerStartAddr ), RUN_END( ulHighHandlerEndAddr )
    

    And in the main program reference the linker symbols to copy some code from flash to RAM:

    /* RAM */
    extern unsigned char ulHighHandlerStartAddr;
    extern unsigned char ulHighHandlerEndAddr;
    
    /* flash */
    extern unsigned char ulHighHandlerLoadStart;
    
    #pragma CODE_SECTION(ram_test,"dummy_handler")
    void ram_test (void)
    {
    	double fp = sqrt(1028.0);
    
    	printf ("Hello from RM42 - sqrt=%g\n",fp);
    }
    
    int main(void) {
    	(void) memcpy (&ulHighHandlerStartAddr, &ulHighHandlerLoadStart, &ulHighHandlerEndAddr - &ulHighHandlerStartAddr);
    	ram_test ();
    	
    	return 0;
    }
    

    I think should also work with the MSP430 linker, but haven't tested it.

  • I'm getting a warning #17003-D because I'm using the large_memory_model and the Flash source is in far memory @ 0x10000.  The address is being truncated to 16-bits.

    Is there a way to convince LOAD_START to define a long?

    Description Resource Path Location Type <a href="file:/C:/ti/ccsv5/tools/compiler/dmed/HTML/17003.html">#17003-D</a>  relocation from function "FLM_Initialize" to symbol "_ramRunSrc" overflowed; the 17-bit relocated address 0x10000 is too large to encode in the 16-bit field (type = 'R_MSP430_ABS16_MSPX' (15), file = "./FLM.obj", offset = 0x0000000a, section = ".text:FLM_Initialize") FLM.c /SDBOOT_working line 51 C/C++ Problem

    thanks 

  • FLM_iitialize has been written for small code model (using 16 bit address instructions). So the linker cannot relocate the instruction parameter with the 17 (20) bit address. Likely, the code has been written in assembly, so the linker auto-checking for a matching data model doesn't apply (else you'd have seen a different error message complaining about incompatibel data model).

    Just guessing...

  • I have CCS set for mspx Silicon version (which seems to default to large_memory_model), but also set --code_model to large to be sure (maybe I need to set --data_model to large?) .

    The .map output shows both FLM_initialize() and the RAM execution images being loaded into 0x00010000 (high memory).  Debug indicates the local extern as 17-bits...  I just seem unable to set a long variable equal to it.  Tried various masking and casting, but yet it gets truncated to 16-bits.

    I was attempting to preserve my low (16-bit) code space by placing the RAM image(s) in upper memory, but since the RAM functions aren't all that big, I just relocated them to low Flash.  This seems to make the linker happier.  So, unless I hit the low-memory wall some time in the future, I'll just go with this.

    thanks

  • Neil Fortney1 said:
    I have CCS set for mspx Silicon version (which seems to default to large_memory_model), but also set --code_model to large to be sure (maybe I need to set --data_model to large?) .

    The .map output shows both FLM_initialize() and the RAM execution images being loaded into 0x00010000 (high memory).  Debug indicates the local extern as 17-bits...  I just seem unable to set a long variable equal to it.  Tried various masking and casting, but yet it gets truncated to 16-bits.

    On a project for a MSP430F5528 device, with the -data_model set to restricted RAM images were able to be located in flash above 0x010000 (high memory) and no linker warnings were generated the linker symbols created by LOAD_START and LOAD_END. Also checked that the function image could be copied from flash to RAM and successfully ran in RAM.

  • Hello Chester,

    I'm OK with the low-flash work-around, but would be very interested to see your solution, can you post and/or email your example project?

    thank you

  • My example CCS 5.5 project is attached 7827.MSP430_ram_func.zip

**Attention** This is a public forum