AnsweredAssumed Answered

Code Execution bug encountered after setting optimization for size -O0d

Question asked by JOSEP LLUIS MORALES on Jun 18, 2016

Hi everyone!

 

Im using the following setup:

KDS 3.0.0

toolchain: GNU Tools for ARM Embedded Processors (arm-none-eabi-gcc)

toolchain architecture: ARM (AArch32)

 

Im working in a custom from scratch bootloader for target KW01Z128 cortex m0+, after setting up the optimization for size in the project options (Project propierties -> C/C++ Build -> Settings -> Tool Settings -> Optimization) selecting the size optimization -O0s) I found a problem in the debugging.

 

In the debugging process I detect that a C line is not executed, if I remove the optimization and change it for "none O0"

The line is "magically" executed.

 

Here is the problematic optimized code:

I don't know that this is a error produced by the toolchain or KDS.

 

1-. How can I solve that problem keeping the optimization of size activated?

2-. Do you know if there exists

 

PS:

After looking for KDS optimization problem posts and reading it:

Problem with code geting optimized out | NXP Community

 

I have tried the asm("nop"); option but it not solves the problem and the code line optimized is not being executed anyway.

Original Attachment has been moved to: kw01_bootloader_test_bindatafromuart_source.rar

Outcomes