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.

MSPM0G3507: arm-none-eabi-gcc 10.3.1 combination of -O1 and -flto removes interrupt vector table and other functions (MSPM0 SDK 1.20.0.5)

Part Number: MSPM0G3507

Hello,

we are using arm-none-eabi-gcc to cross build for MSPM0G3507 MCU. The version set is

  • arm-none-eabi-gcc: 10.3.1
  • MSPM0 SDK: 1.20.0.5

If using compiler settings -O0 and -flto code runs as expected.

If using -O1/2/s and -flto the binary gets suspiciously small and when downloaded kind of "bricks" the MCU .. at least I cannot access it via SWD anymore.

As a root cause I figured that the interruptVectors table in the startup_mspm0g3507_gcc.c is completely removed from the binary.

If I change 

void (*const interruptVectors[])(void) __attribute__((section(".intvecs"))) = {
    (pFunc)&__StackTop, /* The initial stack pointer */
    Reset_Handler,      /* The reset handler         */
    NMI_Handler,        /* The NMI handler           */

to 

void (*const interruptVectors[])(void) __attribute__((section(".intvecs"), used)) = {
    (pFunc)&__StackTop, /* The initial stack pointer */
    Reset_Handler,      /* The reset handler         */
    NMI_Handler,        /* The NMI handler           */
    HardFault_Handler,  /* The hard fault handler    */
    0,                  /* Reserved                  */

the interruptVectors table is not removed anymore and the code runs. As this modification regards the GCC specific startup file I am fine modifying it.

Yet also the function void DL_Common_delayCycles(uint32_t cycles) in dl_common.c is getting removed when using -O1/2/s and -flto. So still the code shows unexpected behavior in some locations.

I don't want to do modifications in the TI driver lib like setting compiler specific attributes like I did in the startup file.

Any suggestions how to approach this issue? LTOs are absolutely necessary in our project ...

Is there any statement from TI on what arm-none-eabi-gcc versions and optimization options are supported given a specific  MSPM0 SDK?

Any changes the interruptVectors table will be marked with the used attribute in next MSPM0 SDK releases?

Best Regards 

Marco

  • Hello Marco,

    This most likely has to do with the version of GCC you have. The latest version that supports MSPM0 is gcc-arm-none-eabi-9-2019-q4

  • Hello Jace,

    thx for your answer. How would I find out what version of the ARM GNU toolchain supports MSPM0 and which not? Is it the Dependencies section in the MSPM0 SDK release notes?

    I downgraded ARM GNU toolchain to 9-2019-q4 yet got the same behavior as described above ...

    Do you have another idea how to fix this?

  • Marco,


    Latest supported compilers for a given SDK should be in the MSPM0 SDK release notes. That being said, if you are using C++ here, there is a known bug that has not been implemented in the SDK yet that will optimize the intvecs out. To work around this place the "KEEP" or "USED" attributes around the intvecs in the startup file. 

  • Hello Jace,

    yes we are using C++. As mentioned in my initial post using "used" attribute on the intvecs table in the startup file works for the intvecs table.

    Yet I noticed that void DL_Common_delayCycles(uint32_t cycles) in dl_common.c is also optimized out.  Using "used" attribute on this function also works yet is quite the hack as we don't want to modify TI driver lib with compiler specific attributes.

    More problematic is that this raises concerns what additionally might have been optimized out and wasn't detected in our tests ...

    Do you have more details about the known bug? Is there (a rough) timeline for a possible bugfix release?

    Marco

  • Marco,

    Unfortunately, I don't have details here, but I do know these attributes will be added to the MSPM0 startup file inherently as well for the fix.I don't have an exact timeline, but I am escalating to try to get it into the next SDK patch .

  • Hello Jace,

    thx for escalating it. Looking forward to the next SDK release(s) then.

    Regards Marco