cancel
Showing results for 
Search instead for 
Did you mean: 

Strange Issue with startup_stm32f072xb.s and stm32f0xx_it.c order?

suads
Associate III

Hello,

I have a strange issue!, so my project is using cmake to build and it is in c++. Everything is working if i set the startup script (startup_stm32f072xb.s) before stm32f0xx_it.c

0693W00000SvzoNQAR.png 

But if i set it after stm32f0xx_it.c, than nothing happens it is like the mcu freezes or not even start.

As I know the order is irrelevant? Or am I wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
suads
Associate III

Hi I fixed this issue it was a problem with the -flto flag, link time optimization. The size of the output file changes if you change the orders of the source files.

By disabling the -lto flag It was working no mater the order of the source files. Enabling it will not work with different orders of the source files.

I updated the arm compiler from 9.3 to 10.3 and this fixed my issue I can enable the -lfo flag and it works in any order.

View solution in original post

3 REPLIES 3
suads
Associate III

Hi I fixed this issue it was a problem with the -flto flag, link time optimization. The size of the output file changes if you change the orders of the source files.

By disabling the -lto flag It was working no mater the order of the source files. Enabling it will not work with different orders of the source files.

I updated the arm compiler from 9.3 to 10.3 and this fixed my issue I can enable the -lfo flag and it works in any order.

You should be able to use the Linker Script (.LD) to ensure the order of sections and objects, might need a KEEP() to make sure it doesn't jettison the vector table if no secondary references are made to it.

I might use the symbol to set SCB->VTOR in MCU supporting that, in SystemInit()

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Piranha
Chief II

GCC versions 7-9 have a bug with linking weak symbols when LTO is enabled. The following topic has more information about that bug:

https://community.st.com/s/question/0D53W00001JBeSWSA1/dma1channel1irqhandler-is-not-getting-triggered