Code Execution bug encountered after setting optimization for size -O0d

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Code Execution bug encountered after setting optimization for size -O0d

ソリューションへジャンプ
1,640件の閲覧回数
joseplluismoral
Contributor II

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:

153850_153850.pngpastedImage_1.png

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

ラベル(1)
1 解決策
1,534件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

I wonder these two variable lastFwLenght and lastFwInitPage have been optimized.

please cast them to "volatile" to avoid optimization.

pastedImage_2.png

then I check disassembly code with -Os option. I can see the related code you mention not being optimized:

pastedImage_3.png


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

元の投稿で解決策を見る

4 返答(返信)
1,535件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

I wonder these two variable lastFwLenght and lastFwInitPage have been optimized.

please cast them to "volatile" to avoid optimization.

pastedImage_2.png

then I check disassembly code with -Os option. I can see the related code you mention not being optimized:

pastedImage_3.png


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,534件の閲覧回数
joseplluismoral
Contributor II

ZhangJennie

Many many many many many (infinite...) many thanks, your help has been very valuable to me

It worked like a charm!

0 件の賞賛
返信
1,534件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

Good to know your problem got solved. My pleasure!

Have a great day,

Jennie Zhang

0 件の賞賛
返信
1,534件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

BTW, My test with your code is under KDS 3.2. for the moment, I don't have KDS3.0 installed.

0 件の賞賛
返信