• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » MSP430™ Microcontrollers » MSP430 Ultra-Low Power 16-bit Microcontroller Forum » MSP430F5438A Linker file (can not fit code into memory)
Share
MSP430™ Microcontrollers
  • Forum
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
MSP430 Resources
  • MSP430 Product Folder
  • MSP-EXP430G2 - MSP430 LaunchPad Value Line Development kit
  • MSP430 Getting Started Guide
  • MSP430 Microcontroller Projects
  • More Resources >
  • Forums

    MSP430F5438A Linker file (can not fit code into memory)

    This question is not answered
    Russell Lemburg
    Posted by Russell Lemburg
    on Jul 30 2012 14:01 PM
    Prodigy230 points
    LEDGoggles_MSP430_Sw_Rev_B_F5438A.zip

    Hello,

    I'm having trouble with getting a program to fit into flash on an MSP430F5438A. The code size is ~50K, and the total flash memory on the MSP430F5438A is 256K. This uC has 4 flash sections (SLAS612C, p. 14).  If I force things around, the program will sometimes load "successfully" but Code Composer will never reset the CPU (the program will just load, but will not execute). 

    My entire code size is a little larger than the first flash section defined in the datasheet (SLAS612C, p. 14)

    Here's the error (entire project attached as well):


    Program will not fit into available memory.  placement with alignment fails for section ".cinit" size 0x34 .  Available memory ranges: FLASH        size: 0xa380       unused: 0x28         max hole: 0x28    lnk_msp430f5438a.cmd   line 124    C/C++ Problem

    I understand what the error message means, but if I change any of the FLASH or FLASH2 sections, I create all sorts of strange overlaps, and end up blowing the security fuse. Basically my question is: how do I get a large .code base to allocate all the 256K of memory? I have all optimizations turned on for size in linker options, but I cannot figure out how to specify .code to span all 4 flash sections.

    msp430f5438a.cmd

    MEMORY

    {

    .....

        //Here is where the flash range is defined
        FLASH                   : origin = 0x5C00, length = 0xA380
        FLASH2                  : origin = 0x10000,length = 0x35C00

        INT00                   : origin = 0xFF80, length = 0x0002

    .....

        INT62                   : origin = 0xFFFC, length = 0x0002
        RESET                   : origin = 0xFFFE, length = 0x0002
    }

    SECTIONS
    {
        .bss        : {} > RAM                /* GLOBAL & STATIC VARS              */
        .data       : {} > RAM                /* GLOBAL & STATIC VARS              */
        .sysmem     : {} > RAM                /* DYNAMIC MEMORY ALLOCATION AREA    */
        .stack      : {} > RAM (HIGH)         /* SOFTWARE SYSTEM STACK             */

        .text       : {} >> FLASH |  FLASH2   /* CODE                              */ Error usually here
        .text:_isr  : {} > FLASH2             /* ISR CODE SPACE                    */
        .cinit      : {} > FLASH              /* INITIALIZATION TABLES             */
        .const      : {} > FLASH | FLASH2     /* CONSTANT DATA                     */ Error usually here
        .cio        : {} > RAM                /* C I/O BUFFER                      */
        .pinit      : {} > FLASH              /* C++ CONSTRUCTOR TABLES            */
        .init_array : {} > FLASH              /* C++ CONSTRUCTOR TABLES            */
        .mspabi.exidx : {} > FLASH            /* C++ CONSTRUCTOR TABLES            */
        .mspabi.extab : {} > FLASH            /* C++ CONSTRUCTOR TABLES            */

        .infoA     : {} > INFOA              /* MSP430 INFO FLASH MEMORY SEGMENTS  */
        .infoB     : {} > INFOB
        .infoC     : {} > INFOC
        .infoD     : {} > INFOD

    .......

    }


    Best regards,


    Russell

    memory linker msp430f5438a command
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Russell Lemburg
      Posted by Russell Lemburg
      on Aug 07 2012 07:59 AM
      Prodigy230 points
      LEDGoggles.zip

      Hi Dung,

      The linker/memory problems have been fixed. But the MSP430F5438A will only program with JTAG now. This problem seems to be an immediate result of these fixes.

      I've attached the most recent project which programs with JTAG on an EXP430F5438, but no longer programs with Spy-by-Wire (Error: Unknown Device).

      Thank you

      Russ

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Chester Gillon
      Posted by Chester Gillon
      on Aug 07 2012 17:18 PM
      Mastermind7335 points

      Russell Lemburg
      I've attached the most recent project which programs with JTAG on an EXP430F5438, but no longer programs with Spy-by-Wire (Error: Unknown Device).

      When I build that attached project, the reset and timer interrupt vectors are now set correctly in the executable.

      Failure to program can be caused by a program running which crashes the processor before the debugger has a chance to attach to the device.

      The following code initializes the Unified Clock System:

      void initClocks(void)
      {
      UCSCTL0 = 0x1F00; //DCO and MODulation registers (see p. 50 of chip datasheet) DCO=31, MOD=0
      UCSCTL1 = 0x0040; //DCO table for selecting clock ranges on p. 50 of Chip Datashseet DCORSEL = 4
      UCSCTL2 = 0x02DC; //DCO multiplier Divide by 1, multiply by 732
      UCSCTL4 = 0x0333; //Clock source is DCO for ACLK, SMCLK, MCLK
      UCSCTL5 = 0x0550; //Clock divide source (set MCLK to /1, set SMCLK and ACLK to /32)
      UCSCTL6 = 0x01DC; //Set up maximum capacitance for XT1, LF mode, turn off XT2
      }

      It is not commented what frequency crystal is connected to XT1, but assuming a standard XT1 32768Hz crystal that means the MCLK is set to 24MHz. On a MSP430F5438A to allow reliably operation with a MCLK of 24MHz, the PMMCOREV level must first be raised to 3 (see the Recommended Operating Conditions section of the MSP430F5438A datasheet). Looking at the attached code I can't see anything which writes to the PMMCTL0 register. As a result, when initClocks runs to set the MCLK to 24MHz the PMMCOREV will still be at the power on default of zero and the processor will probably crash.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Aug 08 2012 05:48 AM
      Guru141810 points

      Chester Gillon
      assuming a standard XT1 32768Hz crystal that means the MCLK is set to 24MHz.

      This is in a risky range even with the correct PMMCOREV setting. Since the DCO mos tlikely won't have the exact frequency available, it will modulate for an average between a higher and a lower frequency. And the higher one could be (worst case) above the allowed maximum.
      With a real 24MHz crystal, there is no modulation and 24MHz are no problem.

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Chester Gillon
      Posted by Chester Gillon
      on Aug 11 2012 08:59 AM
      Mastermind7335 points

      Chester Gillon
      It is not commented what frequency crystal is connected to XT1

      On further investigation the code isn't actually selecting an external XT1 crystal since:

      a) I can't see any code which is selecting P7.0 / P7.1 for the XIN / XOUT module functions, and thus the pins will be I/O.

      b) The write to UCSCTL6 sets XT1BYPASS bit.

      When the initClocks code was tried in a MSP430F5510 (same UCS and DCO Frequency Ranges as a MSP430F5438A) the resulting MCLK was ~20MHz. The XT1LFOFFG and DCOFFG flags were set (DCO bits were maximum of 31). Presumably the device is using the UCS Fail Safe of souring FLLREFCLK from the REFO.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Russell Lemburg
      Posted by Russell Lemburg
      on Aug 12 2012 12:43 PM
      Prodigy230 points

      We're not using an external crystal, because we do not need very high precision. Is this somehow related to the Spy-by-Wire issues we're having? Perhaps it's related to the frequency difference between 2 and 4-wire JTAG? Quite bizarre.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Chester Gillon
      Posted by Chester Gillon
      on Aug 12 2012 13:05 PM
      Mastermind7335 points

      Russell Lemburg
      We're not using an external crystal, because we do not need very high precision.

      OK, can you clarify what frequency you want MCLK to be. Is it 24MHz derived from the internal REFO?

      Russell Lemburg
      Is this somehow related to the Spy-by-Wire issues we're having?

      Using the initClocks() function I created a test program in a MSP430F5510 (haven't got an actual MSP430F5438A to try - the MSP430F5510 has the same UCS module and DCO frequencies). With the PMMCOREV set to the default level of zero (VCORE measured at 1.4V) then the program didn't crash and I haven't had any debug failures when using a MSP-FET430UIF connected by Spy-By-Wire. i.e. suspect your failures are caused by some other problem, but I don't know what. 

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Brendan Simon
      Posted by Brendan Simon
      on Nov 18 2012 22:10 PM
      Intellectual400 points

      I am getting the same error for .cinit not being able to fit.  NOTE: I am using CCS v5.3.0.00067 (RC1) and targeting MSP430F2618.

      "../lnk_msp430f2618.cmd", line 94: error #10099-D: program will not fit into available memory.  placement with alignment fails for section ".cinit" size 0x7d .  Available memory ranges:
         FLASH        size: 0xcebe       unused: 0x0          max hole: 0x0       
      error #10269: output file "xyz-trunk-codecomposer.out" exceeds code size limit

      It looks like the FLASH section is getting filled first.  I tried putting all FLASH sections before any FLASH2 sections but got the same result.

      I then tried replacing the ">> FLASH | FLASH2" with "> FLASH | FLASH2".  The error about .cinit disappeared, but still getting code size limit errors.

      error #10269: output file "xyz-trunk-codecomposer.out" exceeds code size limit

      So what does the >> symbol do, and why is it only used for the .text section ??  I can't find any documentation that describes it :(

      Brendan Simon (eTRIX)

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Brendan Simon
      Posted by Brendan Simon
      on Nov 18 2012 22:20 PM
      Intellectual400 points

      OK, found it here:

      http://www.ti.com/lit/pdf/slau131

      The >> is used for automatically splitting the section into different areas of a memory region, or across multiple memory regions.

      Now off to find out why my code (ported from IAR) doesn't fit .....

      Brendan Simon (eTRIX)

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Chester Gillon
      Posted by Chester Gillon
      on Nov 18 2012 23:43 PM
      Mastermind7335 points

      Brendan Simon
      So what does the >> symbol do, and why is it only used for the .text section ??

      The >> symbol controls "section splitting". For documentation see section 7.5.4.7 Automatic Splitting of Output Sections Among Non-Contiguous Memory Ranges of the MSP430 Assembly Language Tools v 4.1 User's Guide SLAU131G

      See also MSP430 linker reports "error #10099-D: program will not fit into available memory" even when there is space

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Mark James
      Posted by Mark James
      on Mar 25 2013 18:04 PM
      Prodigy30 points

      I had a similar problem, I'm using an MSP430F5419 with 128K of memory.  The ">>" didn't seem to work, it should have split the code ".text" but didn't, the two Flash segments are separated by the interrupt vectors, my code is reported to be 42.342K and the lower Flash "FLASH" is 41.856K it gave me an error about ".cinit" possibly since it was linked after the code.  Since FLASH2 on my chip is 89.088K I just changed the command to ".text      : {} > FLASH".  I don't know why the linker reports the wrong section or why the ">>" command didn't split my code.  I was using the Large Memory model so I didn't think there would be a problem.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Mar 26 2013 10:45 AM
      Guru141810 points

      Mark James
       I was using the Large Memory model so I didn't think there would be a problem.

      THis isn't important for the linker. It just controls which kind of call/ret instructions the compiler generates (16 or 20 bit). The init code, since it is reached through the reset vector, needs to be in low memory. And it is placed after your code because it is loaded from a library while youre code is loaded from explicitely given object files. Also, you don't use large memory model, so it may be (and that's just guessing) that the linker script in this case will put the init values for your global variables into lower FLASH too. Since this section is placed after all global and static variables are collected, it is too placed after your code.

      You can explicitely put some of your functions into FLASH2 by putting the proper pragmas into the source code.

      Sure, teh linker could do a multi-pass run and optimize placing with the results from the first failed pass (that's actually what you do when thinking 'the linker should...') but it hasn't been designed this way.

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    12
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use