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
Solved! Go to Solution.
Hi,
I wonder these two variable lastFwLenght and lastFwInitPage have been optimized.
please cast them to "volatile" to avoid optimization.
then I check disassembly code with -Os option. I can see the related code you mention not being optimized:
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi,
I wonder these two variable lastFwLenght and lastFwInitPage have been optimized.
please cast them to "volatile" to avoid optimization.
then I check disassembly code with -Os option. I can see the related code you mention not being optimized:
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
ZhangJennie
Many many many many many (infinite...) many thanks, your help has been very valuable to me
It worked like a charm!
Good to know your problem got solved. My pleasure!
Have a great day,
Jennie Zhang
BTW, My test with your code is under KDS 3.2. for the moment, I don't have KDS3.0 installed.