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

Optimization Error

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.

Parents Reply Children
  • 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.

  • Good Moorning,

    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.