Skip to main content
suads
Associate III
September 22, 2022
Solved

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

  • September 22, 2022
  • 3 replies
  • 2137 views

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?

This topic has been closed for replies.
Best answer by suads

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.

3 replies

suads
suadsAuthorBest answer
Associate III
September 28, 2022

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.

Tesla DeLorean
Guru
October 7, 2022

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Piranha
Principal III
October 19, 2022

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