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.

CCS/CCSTUDIO: How to use .cmd to fix a whole .c code file compiling result into a fixed flash address?

Part Number: CCSTUDIO
Other Parts Discussed in Thread: CC1310

Tool/software: Code Composer Studio

Hi Team,

My customer has a request to fix a whole .c code file compiling result into a fixed flash address, I think it should be done in the .cmd file.

Any examples or formats of .cmd file modification I can reference for this use case? I suppose it should be in SECTION / GROUP define in .cmd file, am I right?

The TI device is CC1310, but I believe it is not directly relevant, it could be any devices.

Thanks!

  • I want restate the problem, to be sure I understand it correctly.  Your customer wants to allocate all the functions from one C source file to a specific address in flash memory.  Is that correct?  For now, I presume it is.

    For general background on the linker command file, please read the article Linker Command File Primer.

    There is more than one way to do it.  I think this is the most straightforward.

    In the linker command file, in the SECTIONS directive, have an entry similar to ...

        special_output_section
        {
            name_of_file.obj(.text)
        } > SPECIAL_MEMORY_RANGE

    This forms an output section named special_output_section.  It contains one input section, which is the .text input section from the object file name_of_file.obj.  It is allocated to an address in the SPECIAL_MEMORY_RANGE.  The SPECIAL_MEMORY_RANGE is specified in the MEMORY directive (not shown in this example).  If desired, replace SPECIAL_MEMORY_RANGE with a hard coded address such as 0x4000.

    Thanks and regards,

    -George

  • Hi George,

    To be more accurate, not only the functions, but also all the variables in one C source file to a specific address in flash memory.

    I tried something, from output .map file looks it works: put sensor.c functions & variables into flash address starts at FLASH_SENSOR, and the length is 0x2000 (defined at the beginning of .cmd file, not pasted here)

        GROUP
        {
        	sensor_code {sensor.obj}
        } LOAD = FLASH_SENSOR

    Does it look OK to you? Anything else to be aware of?

    Thanks!

  • That works, but this is cleaner ...

    sensor_code
    {
       sensor.obj
    } > FLASH_SENSOR

    This creates an output section named sensor_code.  It is made up of all the input sections, both code and data, in the object file sensor.obj.  It is allocated to an address in the memory range FLASH_SENSOR.

    Thanks and regards,

    -George

  • Yan said:
    I tried something, from output .map file looks it works: put sensor.c functions & variables into flash address starts at FLASH_SENSOR

    Won't placing writable variables into FLASH will cause the program to fail to write to the variables?