Skip to main content
wvict.1
Visitor II
June 13, 2023
Question

[STM32H757] Issue with the FW running after the compiler optimization is turned on

  • June 13, 2023
  • 1 reply
  • 1274 views

We are developing STM32H757 Firmware using STM32CubeIDE (V 1.10.1, GNU Tools for STM32 (10.3-2021.10)). We have encapsulated an SPI read function based on ST's BSP. When tested on CM7 with optimization options turned off (-O0), the function can run normally and return. However, when the optimization option is set to -O2, the function becomes abnormal. We tried the following:

 

1. Debug with the emulator. With the same code and compilation options, the code can run normally.

2. The problem cannot be reproduced with the emulator. We added two logs before the exception jump, compiled an image, wrote it into flash, and the image can run normally.

3. We added a volatile modifier to the control loop variable, compiled an image, wrote it into flash, and the image can run normally.

 

It seems that none of the three experimental phenomena can be explained. The attachment contains the function code and modification instructions, as well as the flag options of the compiler and linker.

Please help to analyze.

This topic has been closed for replies.

1 reply

S.Ma
Principal
June 13, 2023

So it could be a combination of STLink connected to the target AND optimisations.

If your toolchain can, try to activate each compiler option progressively to find out which one(s) is the culprit (use binary seach way instead of one by one).

Could be timings, SW coding bug....