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.

.stack in map file is inconsistent with --stack_size

Other Parts Discussed in Thread: MSP430G2755, MSP430G2744, MSPMATHLIB

When I change stack size in CCS Linker option (from default 80 to 120), I can see --stack_size is changed from 80 to 120 in the linker command line. However, the size of .stack section is always 0x40(dec 64). So why it is not consistent with --stack_size?

I have another project, where they are consistent. I don't why. Please help. Thanks

CCS Version: 6.0.0.00190
MSP430G2755
Compiler: TI v4.3.1

  • Do you look in the right .map file, each Project Configuration has its own output directory and also its own .map file.

  • I’m not quite sure of what use a .stack linker section is, because nothing ever gets placed in it. The stack is empty at compiler time.
    However, you can’t ‘set’ or ‘limit’ the stack size anyway. When an instruction causes the stack pointer to decrement (push, call, an interrupt), it will do so. No matter what you have ‘set’ as stack size. And it will continue to do so until it overwrites all your global variables and finally falls out of ram. Nothing but proper coding can prevent this.

    The ‘stack size setting’ is just a fake element to block some ram space during link, so you’ll get a linker error if your global vars don’t leave that much ram free. Also, the compiler should trigger a breakpoint when in debug mode and the stack grows larger than ‘set’. However, this setting has no effect on the generated code at all.

  • To Jens-Michael Gross:

    Yes, I understand using stack size the linker will throw an error if RAM is not enough, and this is what I want now. 

    To Leo Bosch:

    I am pretty sure I am looking at the correct map file.

    The linker command in the log file is:

    'Building target: ED_2744_Grace.out'
    'Invoking: MSP430 Linker'
    "c:/ti/ccsv6/tools/compiler/msp430_4.3.1/bin/cl430" -vmsp --abi=eabi -Ooff --advice:power=all -g --define=__MSP430G2744__ --define=CODE_FOR_ED_APP_WITH_BOOT --define=MCLK_FREQ_MHZ=8 --define=CODE_FOR_ED_G2744_P1 --define=CODE_FOR_ED --diag_warning=225 --display_error_number --diag_wrap=off --printf_support=minimal -z -m"ED_2744_Grace.map" --heap_size=80 --stack_size=80 -i"c:/ti/ccsv6/ccs_base/msp430/include" -i"E:/TI/Projects/AP_ED/AP/ED_2744_Boot" -i"c:/ti/ccsv6/tools/compiler/msp430_4.3.1/lib" -i"c:/ti/ccsv6/tools/compiler/msp430_4.3.1/include" --reread_libs --warn_sections --display_error_number --diag_wrap=off --xml_link_info="ED_2744_Grace_linkInfo.xml" --rom_model -o "ED_2744_Grace.out" -l"./configPkg/linker.cmd"  "./BattVolt/BattVolt.obj" "./EDBuffers/EdBuffers.obj" "./EdSwUpdate/EdWorkingStateSwUpdate.obj" "./EdSwUpdate/EdSwUpdateUtility.obj" "./EdSwUpdate/EdSwUpdateInfo.obj" "./EdWorkingState/EdWorkingStateSearchingAP.obj" "./EdWorkingState/EdWorkingStateRegistering.obj" "./EdWorkingState/EdWorkingStateReceiveGroupEdInfo.obj" "./EdWorkingState/EdWorkingStateLcdRefresh.obj" "./EdWorkingState/EdWorkingStateIdle.obj" "./EdWorkingState/EdWorkingStateEdDedicated.obj" "./EdWorkingState/EdWorkingState.obj" "./Ext/Utilities.obj" "./Ext/RfMsgHeader.obj" "./Ext/Radio_CC1101C.obj" "./Ext/Radio.obj" "./Ext/BipBuffer.obj" "./KeyPad/KeyPad.obj" "./LCD/LcdInterface.obj" "./LCD/LcdApi.obj" "./Led/LedApi.obj" "./Misc/MiscInfo.obj" "./Misc/EdUiDataInfo.obj" "./Misc/EdLog.obj" "./Misc/EdDedicatedInfo.obj" "./Misc/EdBoardInfo.obj" "./Misc/DelayFunc.obj" "./OcFlash/OcFlashApi.obj" "./PowerUp/BoardPowerUpInit.obj" "./Radio/EdRadioInterface.obj" "./Radio/EdRadioApp.obj" "./Radio/EDRadio.obj" "./RfMsgs/EdRfMsgUplink.obj" "./SpiFlash/spiFlashTest.obj" "./SpiFlash/spiFlashApp.obj" "./SpiFlash/SpiFlashInterface.obj" "./SpiFlash/SpiFlashApi.obj" "./Stack/StackProbe.obj" "./TP/TpApi.obj" "./TimerA/TimerUtility.obj" "./TimerA/TimerAInt.obj" "./TimerA/EdTimeManager.obj" "./Uart/UartApp.obj" "./Uart/SimUart.obj" "./msp430CommonDefs.obj" "./main.obj" "./IntVectors.obj" "../lnk_msp430g2744_AppWithBoot.cmd" -l"libc.a" 
    <Linking>
    remark #10422-D: (ULP 6.2) Detected use of a device with available 32-bit hardware multiplier and not also using MSPMATHLIB library (libmath.a).  Recommend using MSPMATHLIB library (libmath.a) for improved performance.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port 4 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    'Finished building target: ED_2744_Grace.out'
    And the .stack and .sysmem in the map file is:
    .TI.persistent 
    *          0    0000042e    00000000     UNINITIALIZED
     
    .sysmem    0    00000474    00000004     UNINITIALIZED
                      00000474    00000004     rts430_eabi.lib : memory.obj (.sysmem)
     
    .stack     0    000005c0    00000040     UNINITIALIZED
                      000005c0    00000002     boot.ae430 : boot.oe430 (.stack)
                      000005c2    0000003e     --HOLE--
  • I’m not familiar with Grace but don’t think the .map file will differ from it.

    As double check you can have a look to the date/time and name at the top of the .map file and also check the value with the ‘__STACK_SIZE’ symbol in the .map file.

  • I checked the file date/time, and it is the correct file. I have even deleted the file and built again, and it is the same result.

    The __STACK_SIZE is also 0x40

    00000600 __STACK_END
    00000040 __STACK_SIZE
    00000004 __SYSMEM_SIZE

  • It’s unbelievable, I’ve never seen any problem here and I’m studying the .map file very often.

    But what I see is your CCS and Compiler version are out of date, maybe you can update them and maybe also Grace, and have new try.

    Also the Stack end is at 600h this is the mirrored space but normally Stack end is at top of RAM in mirrored it is at 9FFh, but this also not the real top of RAM.

    You could have a look/post to your Linker Command file, the .cmd file in the project root.

  • Jianyi Bao said:
    When I change stack size in CCS Linker option (from default 80 to 120), I can see --stack_size is changed from 80 to 120 in the linker command line. However, the size of .stack section is always 0x40(dec 64). So why it is not consistent with --stack_size?

    In a grace project the size of the stack segment isn't set from the CCS Project Properties for the linker.

    Instead, the stack size is get from the Grace .cfg configuration file. To change the stack size, on the "cfg Script" tab of the grace .cfg set the value on Program.stack line:

  • Hi, 

      After modifying stack size from grace .cfg file, the stack size in the map file could be changed now. Thanks.

    Hi, 

      In MSP430G2755, the end address of RAM is 0x600, so the link cmd file is correct.

**Attention** This is a public forum