We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Good Moorning,
I open this post, because i am working in a proyect with Ethernet, but i have a strange issue that i cant find the source of problem. I hope you can help me, Thanks.
The problem, is that in optimization O0 the proyect not work propertly, it occurs a hardfault handler in parte of code that dont have sense. While if i use the optimization Oz, work propertly.
With other levels of optimization, appear same error that O0.
I indicate aditional information of the proyect:
MCU: STM32F779NI ETH_Controller: KSZ9031MNX Library_Ethernet: LWIP ARM Compiler: 6.11
Also, comment that i was modify the Scatter file. I modify it because of i need have reserved RAM (MPU) for the DMA Ethernet.
Thanks for your help.
Kinds Regards.
What I'd do is try and narrow it down. Most importantly, to the module level. Optimise separate modules at different levels. Then look into ways of narrowing it down to a function within the (hopefully) single module. Then look at the (hopefully) single function and consider looking at the assembler that the compiler produced.
So have you used the Hard Fault information to see what, exactly, was the cause?
Lots of information online on debugging Cortex-M Hard Faults ...
errors that are optimization level dependent are usually timing related
Or memory related.
Mostly it exposes latent flaws in logic or expectations. Failure to use volatile when appropriate. Folding of writes to HW registers. Changes mix in register/stack usage, again volatile may mean a value held in registers is not consistent with memory copy. Extra fun can be had involving caching.
Indeed!
Thank you very much for you answers.
I was testing some of you suggestions, and i found a piece of the problem. It was related with the memory reserved that free at tcp connections.
After found this error, i have been trying with diferents optimization levels:
- Go on working correctly at Oz -'Seems' working correyly at O1 - Not work O0
Now, at O0 dont work and when fail, it dont give a concrete error, Simply the program stop, and i dont have any information of errors, this appears at a memory position that not have sense and in the table of fails indicate state halted and breakpoint.
I will trying to found why dont work at O0.
If you have any suggestions, i would appreciate it, beacause of the last was good aimed.
Again,thank you very much for you help.
The code will likely only work properly at optimization level -O2 or -O3 -- or another level provided you enable enough optimizations. The optimization levels -O0, -O1, etc., are shorthand for enabling sets of optimizations. See, for example,
gcc.gnu.org/.../Optimize-Options.html
And you can review the ARM compiler reference, too.
-O2 can make code a little harder to follow, due to the re-arranging of operations that the compiler does, but not impossible.