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.

linker cmd file editing

Other Parts Discussed in Thread: MSP430F5659

ok i need to port code that works with one micro controller and make it work for a msp430F5659 and in the original code there are specific things with the origin specified and length in hex.  can someone explain to me exactly what to do to put them into the new linker file as in can i take memory from flash for example and allocate it to what i want and just change the length of the flash?  if anyone knows alot about this and can give me a little tutorial or point me to a good one it would be greatly appreciated.

  • Robert,

    You are thinking along the right path.

    Lets say you have a flash segment that is 0x1000 in size and located at address 0x1000.

    Next lets say you want to create space in the flash that is 0x100 bytes in size. You would modifiy it something like this:

     

    -- Original Linker script

    FLASH                   : origin = 0x1000, length = 0x1000

    -- Now the modified

    MYVAR                  : origin = 0x1000, length = 0x0100

    FLASH                   : origin = 0x1100, length = 0x0F00

    In the modified Linker script, this moved the flash start address by 0x100 bytes, and reduced the size by 0x100 bytes.

    You would then need to add MYVAR to the section space underneat the .stack settings:

    .myvar     : {} > MYVAR      

     

    This is a CCS example of how you would use a $pragma to put it into the space you created:

    #pragma SET_DATA_SECTION(".myvar")

    unsigned char foo[0x100];

    #pragma SET_DATA_SECTION           

    This would put a 0x100 byte sized array into the "MYVAR" section you created in flash.

     

    Hope this helps!

     

    -Jason

     

  • thank you

    thats exactly what i was thinking i just didn't want to do it then port the rest of the code and find out i was wrong from the get go with the linker file.  i guess the only other thing i would be wondering incase you know is (remember im modifying existing code to work with the new chip we are gonna use which has more FLASH and a section of FLASH2) can i break up say FLASH2 into FLASH2 and FLASH3.  i ask because some of the parts of the old linker file has a the origin and length set that works with the old chip my boss said he wanted that part not modified. so if the origin started right in the middle of FLASH2 could i just take off the appropriate length from flash two and at the end of the length of what i inserted next number start an origin of FLASH3 with its appropriate new length then add it  with an or operator to any part that had FLASH | FLASH2  ie. FLASH | FLASH2 | FLASH3.  as well as can i change the INT00 through INT62 or are thoughts important the way they are.  I ask this stuff cause if the answer is yes to all then im home free on making everything fit together nicely...   there is also an INF0A - 0D im wondering if they can be changed as well.  any help will be appreciated.

**Attention** This is a public forum