This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Scatter file errors when optimize flags applied

Hi, 

I am currently trying to port a benchmark firmware to my MCU that is running on a CM33 processor. I am running into problems when I try to apply certain levels of optimization to my firmware. The environment that I am using is Keil uVision 5, using the CLANG 6.12 compiler.

As a starting point, I take a 'Blinky' sample code that is provided with the MCU (it flashes an LED periodically) and build the project. Everything works as expected. Next, I add the '-Omax' flag to the "C/C++" settings plane of the project options, under "Misc Controls". This also works as expected. 

The next steps are for me to delete the 'Blinky' files from the project and import the benchmark firmware code made up of C code and Assembly code files. After I import the benchmark code and remove the '-Omax' flag, the benchmark will build properly and run as expected. 

The problem occurs when I try to build this benchmark firmware using the '-Omax' flag. The build runs fine until it gets to the linking step, at which point I get the error shown in the screenshot below. 

This is even more confusing, given I was able to build a similar benchmark using the exact same approach, optimization flags and scatter file, without any issues. 

Does anyone have any suggestions about what might be causing this issue within the benchmark specific firmware code (given other benchmarks and sample firmware seem to build fine using the same scatter file)?