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.

TMS320VC5509A: .map file Memory allocation issue. (CCS 6.2 with Compiler 3.2)

Hello,

Software is not working, If I define the extern variables in a particular file (ex. main.c) but it works If I define the same variable in different file (ex: test.c). Also if I initialize with 0 its not working but If I initialize with particular value it works. Also I did compare both working and non working .map files and it appears that non working build map file shows that address are not continuous even though no static variables are defined in that file. 

I defined MSThreshold, IGDThreshold, MSChecksum as Unsigned 16 bit value. I did load the release build symbols into target debugged the release build software and it appears that MSChecksum is not 16bit value the lowest 16bit values are different and why it shows two 16bit values in the memory location and in the map file shows 0x0084bc is MSThreshold, 0x0084bd is IGDThreshold, 0x0084be is MSChecksum and 0x0084bf is not found in the memory map file.


test.h:
extern Uint16 MSThreshold;
extern Uint16 IGDThreshold;
extern Uint16 MSChecksum;

main.c: (not working)
#include "test.h"
Uint16 MSThreshold = 300;
Uint16 IGDThreshold = 46;
Uint16 MSChecksum = 300;

test.c ( working)
#include "test.h"
Uint16 MSThreshold = 300;
Uint16 IGDThreshold = 46;
Uint16 MSChecksum = 300;


Memory view:-

0x0084BC MSThreshold
0x0084BC 012C
0x0084BD IGDThreshold
0x0084BD 002E
0x0084BE MSChecksum
0x0084BE 012C 7503

CCS: 6.2

Compiler version 3.2.

Is there any specific reason why CCS generates builds differently ? Is there memory alignment issue?.  Please advise.

Thanks,

Ramesh G

  • Hi Ramesh,

    Because the release build is using the code optimization automatically, the un-referred (unused) variables will be removed automatically. If you want to keep those variables, please add the "volatile". It will force the compiler and linker to keep the un-referred variables.

    main.c:
    #include "test.h"
    volatile Uint16 MSThreshold = 300;
    volatile Uint16 IGDThreshold = 46;
    volatile Uint16 MSChecksum = 300;

    Best regards,

    Ming

  • Thank you for the prompt response Ming. Variables (MSThreshold, IGDThreshold, MSChecksum) are used in the software many places. Also I did not enable any optimization option in the compiler setting (Please refer compiler screenshot below). 

    Yes, we do use volatile in many places where registers or FPGA related information but not for all the normal variables. Question is even though optimization not enabled and variables are used in the software why need to force volatile?. and why Uint16 MSChecksum shows 32 bit value instead of 16bit in the memory view.?

    Memory view:-

    0x0084BC MSThreshold
    0x0084BC 012C
    0x0084BD IGDThreshold
    0x0084BD 002E
    0x0084BE MSChecksum
    0x0084BE 012C 7503

    Thank you,

    Ramesh G

  • Hi Ramesh,

    First of all, can you explain the following statement a little bit more:

    "Software is not working, If I define the extern variables in a particular file (ex. main.c) but it works If I define the same variable in different file (ex: test.c)"

    What do you mean the software is not working?

    Secondly,

    Memory view:-

    0x0084BC MSThreshold
    0x0084BC 012C
    0x0084BD IGDThreshold
    0x0084BD 002E
    0x0084BE MSChecksum
    0x0084BE 012C 7503

    looks correct to me and it matches the MAP file MSChecksum (0x0084BE) = 300.

    Can you send me the linker command file and the two map files (working and not working)?

    The only difference between putting variables in main.c or in test.c is the data section location depending on the linker command file.

    Best regards,

    Ming