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.

#pragma CODE_SECTION and #pragma DATA_SECTION directed to the same section

Other Parts Discussed in Thread: MSP430F167

In an earlier version of CCS (CCS2.0) for MSP430, a standard C file,  containing code and tables of constants was compiled and linked into a specific flash memory region in a MSP430F167 known as section ".new_boot"

This area of boot code needed to be completely contained in a separate flash area so it could be used to update the main code, which is in a different section.

All code and constants for this boot file were successfully put in this single section using  two pragmas directed to the SAME section, ".new_boot"

code was pushed into this ".new_boot" section via

#pragma CODE_SECTION(function_name, ".new_boot")

constant data was ALSO put in the same "new_boot" section via

#pragma DATA_SECTION(array_name,".new_boot")

I am trying to move the code to CCSV6 and it appears this feature no longer works as these pragmas cannot reference the same section.

Is there a work around short of splitting the existing ".new_boot" section into separate data and code sections and manually managing their sizes?

For this application, it was very useful to be able to let the code and constant data be automatically placed in the same section.

  • I think you can define and use many many different named memory section in the compiler. At link time, you can then assign which named section, or which group of named sections combined to specific physical address range.
  • This is an excellent tip.

    Per your suggestion, if one looks at the sections defined in the lnk_msp430F167.cmd, a number of sections are defined to all go to the same FLASH memory area.

    .text : {} > FLASH /* Code */
    .cinit : {} > FLASH /* Initialization tables */
    .const : {} > FLASH /* Constant data */

    I need to create a new section for constants and then direct it into the same area as the code section goes.

    Perhaps something like

    .new_boot : {} > NEW_BOOT /* boot code for MSP430 */
    .new_boot_data : {} >NEW_BOOT /* boot code data constants */

    That should put all the code + data in the same reserved flash location.


    Thanks very much.
  • I do not know the specific syntax and rules. But the principle should apply.
    The compiler uses logic sections, each with a symbolic name for the benefit of the programmers.
    The linker uses physical sections, each with a physical address range. (Which imply if it is RAM, Flash, or Vector Flash for the specific chip.)
    A linker command file tells the linker which logic sections go together and fit into which physical section.
    People commonly use a "de facto standard" linker command file, which unfortunately may not be suitable for your kind of use. For your kind of application, alternatively, they may use two non-overlapping linker command files and split the project into two projects, one for the stationary loader and the other for the transient code being loaded.
    I suppose the user's manual will tell you all these.

**Attention** This is a public forum