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.

Program is unable to fit in to available memory when using SQRT() function

Other Parts Discussed in Thread: MSP430G2403, MSP430G2553, MSPMATHLIB, MSP430F425

Hi,

     I am working over a project, where accelerometer data is being collected and monitored using msp430g2403. I am using  sqrt() function to calculate the resultant of the 3 axis data of LIS3DH accelerometer. I have worked on msp430g2553 before and implemeted the similar code over it. I havent found any issues, but when I have ported the code from MSP430g2553 to msp430g2403. here the error

"../lnk_msp430g2403.cmd", line 93: error #10099-D: program will not fit into available memory.  placement with alignment fails for section ".text" size 0x3450 .  Available memory ranges:
   FLASH        size: 0x1fe0       unused: 0x1ed4       max hole: 0x1ed4    
error #10010: errors encountered during linking; "odg_MD_LIB.out" not built

pops up. On debugging I have found this. When I have commented the line

        temp = ((x*x)+(y*y)+(z*z));

//        res_i = sqrt(temp);

and ran the code, then it seems to work. On uncommenting this line, complier throws the above error. please help me in understanding this issue and also to overcome this problem..

Thanking you,

Sri.

  • You said your code works with G2553, why do you attempt to change to G2403? What is the difference between G2553 and G2403? If it is the price of the chip? if so, why not change to G2303 (which is even cheaper)?

    Aside form the price, the memory size of G2403 is smaller then that of G2553. Could that be the reason causing your problem? Eliminate some lines of your code could reduce the amount of memory required. Could that be an indication of what you already found out?

  • sri-sri said:
    I am using  sqrt() function to calculate the resultant of the 3 axis data of LIS3DH accelerometer.

    Two ways to reduce the code size for a square root calculation are:

    1) If compiling using CCS using the output format set to eabi (ELF) use sqrtf (32-bit float) rather than sqrt (64-bit double).

    2) Use sqrtf from MSPMATHLIB (Edit: but not supported on a MSP430G2 device)

    See the posts at the end of CCS v5.3 error reading 'used' flash in map file for the possible code size reduction.

  • I downloaded CCS and ported my code from IAR for msp430F425.

    In my application I also have functionality to calculate sqrt(64-bit), it was working fine in IAR using <math.h> where as I am getting compilation error in CCS. when I comment sqrt function it works fine.

    error #10099-D: program will not fit into available memory. run placement with alignment fails for section "BSS_GROUP" size 0x108 . Available memory ranges:
    RAM size: 0x200 unused: 0x91 max hole: 0x91

    Please suggest me the way.

  • The linker (not the compiler, it is a linker error!) tells you that only 0x91 bytes of ram are unused but 0x108 are required at the moment of the error (when trying to place the BSS_GROUP).
    The use of SQRT apparently causes some additional ram to be allocated and it won't fit into the limited ram of this MSP.
    The code requires 23 bytes more than you have.

    You may try reducing the reserved stack memory size in the project settings, but be sure the program doesn't need it (it does not limit the stack, only reserves the given amount of ram when linking)

  • Thanks for the reply,

    It's a linker error. after your suggestion, I reduced one global array size from 80 to 50 (saved 30-bytes) but even though I am getting error:

    error #10099-D: program will not fit into available memory. run placement with alignment fails for section "BSS_GROUP" size 0xea . Available memory ranges:
    RAM size: 0x200 unused: 0x79 max hole: 0x79
    error #10010: errors encountered during linking; "TEST.out" not built

    Just for your information, I ported code from IAR to CCS, I think it should not give (DATA) code issue. My application uses sqrt 4-times, I am getting error even when I enable sqrt at first place. Is this the limitation of CCS or any other way to calculate square root of 64-bit value int. Please help me on this.

  • Neeraj Verma said:
    I am getting error even when I enable sqrt at first place

    Of course!

    It makes no difference whether you call a function once or a million times; it still uses the same amounts of memory - that's one of the main points of using functions!

  • Thanks for you reply,

    Your answer doesn't match with my problem/query, My problem is "I am getting linking error (code size issue) when using sqrt in CCS" whereas same code works fine on IAR (target is msp430F425).

    FYI, Calling same function from several (million) places also takes code memory.

  • Neeraj Verma said:
    Your answer doesn't match with my problem/query, My problem is "I am getting linking error (code size issue) when using sqrt in CCS" whereas same code works fine on IAR (target is msp430F425).

    Most probably sqrt() function of IAR library takes less code FLASH or RAM space and/or IAR compiler output is smaller than CCS. Compilers are not the same. If your program can't fit available memory - use either more memory or write smaller code or change compiler or rewrite sqrt() . What's the problem?

    http://www.codeproject.com/Articles/69941/Best-Square-Root-Method-Algorithm-Function-Precisi

  • Ilmars said:
    Most probably sqrt() function of IAR library takes less code FLASH or RAM space and/or IAR compiler output is smaller than CCS.

    Or IAR does reserve less space for stack/heap by default. Or the reserved stack space had been reduced in the IAR project settings to make the linker error disappear (note that the stack space setting does not affect the generated code or runtime behaviour at all - it is just a threshold value for forcing a linker error if too much ram is used for variables)

**Attention** This is a public forum