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.

MSP430FR5969: Compiling CTPL using -mcode-region=either

Part Number: MSP430FR5969

Hello,

I have a large application (in combination with CTPL ) that needs to be placed in HIFRAM. I used -mlarge and -mcode-region=either. The code compiles but does not run.

I isolated the issue to CTPL.  CTPL code compiled with -mlarge and -mcode-region=either does not execute, just hangs at the beginning. On comparing assembly file with and without mcode-region, the ctpl functions like ctpl_init are placed in 0x0000 when compiled for placing code in higher fram. Does this affect execution? How do I get to execute CTPL correctly with these settings?

I have shared the assembly listings in links below.

The assembly listing for regular ctpl: https://drive.google.com/file/d/1OFOcCro5Iup-1d6Z9dlP0LmsdokRhVHt/view?usp=sharing
And for  ctpl compiled with -mcode-region=either : https://drive.google.com/file/d/1-Gc-NJ2Wok1airfU3VzcA-0LKSsnvk9B/view?usp=sharing

Regards,
Archie S

  • I suspect a problem with command line options. Did you include the "either" option when linking? I suspect not since your disassembly shows that the ctpl_init code is in section .either.text. The linker should have changed that to either .lower or .upper as there is no such thing as an .either section in the linker script.

  • David, thank you! I added "either" option to the linker. ctpl_
    init code is no longer in .either.text section (updated the link with latest assembly listing). But the compiled code is still not executing

  • I apologize. Even after adding either option to linker, the ctpl_init code is still in .either.text.

  • Hmmm, after further thought, it might be because of that section name. The ":ctpl_low_level" appended to .text might be the problem.  Try deleting it.

  • How will deleting :ctpl_low_level in in assembly listing delete the same binary?

  • Also, with either code region, the ctpl functions are placed from memory 0x00000. Is that okay?

  • The special function registers live down near 0x0000 so that is no place to try and put code. (Programming will of course fail.)

    When gcc modifies a section name for something like -ffunction-sections, it uses a period "." to separate the names. Using a colon might cause the linker to not consider ".text:ctpl_low_level" to be a .text section. Either remove all of that or change the ":" to a ".".

  • I understand how replacing colon with a period might help. But how does changing this in the assembly listing (.lst) file change it in the binary executable file?

    The ctpl_init and other functions placed from 0x0000 are defined in assembly file. Could this maybe affect the way compiler is placing .text in either memory? The assembler also has "either" option enabled
    Also in the disassembly, when compiling without either option, these ctpl_init functions are in .text. Whereas, when compiling with either these ctpl_init functions are in a new section .either.text:ctpl_low_level"

  • In reverse order:

    1) The code-region=either option tells the linker to prepend ".either" to ".text" section names.

    2) The assembler doesn't understand the mcode-region=either option so does nothing to the section names. All code output from the assembler begins at 0x0000 by default. Those addresses get fixed up by the linker in the next step.

    3) The section name in the assembler source is .text:ctpl_low_level. This appears to be confusing the linker. While it does prepend ".either" as expected it does not then try to put it into either .lower.text or .upper.text. Instead it cannot find that name and treats it as an orphan section. Silently. Enable a warning with "--orphan-handling=warn". Or "-Wl,--orphan-handling=warn" if passing the options through gcc.

  • Thank you. With the warning enabled (using gcc), I came across several other orphan sections for functions in my code from .either.text.main to many (all?) ctpl related functions like .either.text.ctpl_WDT_A_epilogue. These functions are defined in .c files and not assemble files. Will these orphan sections affect execution in any way?

    Also, how do I get the code to compile with section name text.ctpl_low_level instead of .text:ctpl_low_level?

  • Edit the source code and change the line with ".section .text:ctpl_low_level". I would have thought that was obvious.

    I tried out that orphan warning and got a lot of useless warnings for code from the C library. The thing to watch for is where it says it is putting the code. You want either .lower.text or .upper.text.

  • David, Thank you! I found .section .text:ctpl_low_level in ctpl_low_level.S. It somehow did not show up in grep results. Replacing : with . in the assembly file got ctpl working. The ctpl_init functions are not in 0x0000 anymore.

**Attention** This is a public forum