This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Turning off CCS4 compiler optimizations

Other Parts Discussed in Thread: PMP

Hi,

I am having trouble turning off the compiler optimizations in CCS4. In Build Properties -> Compiler -> Basic Options, I have explicitly set the optimization level to 0, however, it seems no effect at all. 

I have this piece of codes:


unsigned long address = 0;

address = APP_START_ADDRESS + sizeof(unsigned long);
    (*((void (*)(void))(*(unsigned long *)address)))(); 


The compiler seems to have optimized the address variable for me and the value of address becomes 0xFFFFFFFF when it runs to the last line of code. I have to explicitly declare address as volatile in order to have the correct value. 

Best regards,
Wilson Fok, PMP 

 

  • Wilson,

    To completely disable the optimizer you must leave this drop-down menu as blank. You are not the first one that comes with this question, therefore I will file an enhancement that explicitly says (disabled) on the drop-down option or something like that.

    Regards,

    Rafael

  • Wilson,

    I filed the enhancement request SDSCM00039552 today. Check its status at the link SDOWP below.

    Regards,

    Rafael

  • Hi Rafael,

    I tried setting the optimization level and optimize for speed options to "blank" instead of 0. When I started debugging, I got "Debug Port Error" message and the program stops running.

    The program works again if I set both options back to 0.

    Regards,
    Wilson Fok, PMP


    desouza said:

    Wilson,

    To completely disable the optimizer you must leave this drop-down menu as blank. You are not the first one that comes with this question, therefore I will file an enhancement that explicitly says (disabled) on the drop-down option or something like that.

    Regards,

    Rafael

     

     

  • Wilson,

    When are you seeing the Debug Port Error? While loading the code to the target or after you start running when it reaches main()?

    The error itself is usually an emulation error that can be caused by a disconnection or code that causes a reset or a device exception.

    To rule out any issues with the loading process itself, can you try to start the debug session manually? Check the last item of the Strategy for debugging JTAG connections at the page below:

    http://processors.wiki.ti.com/index.php/Debugging_JTAG_Connectivity_Problems

    If the loading runs fine but it fails to reach main, I wonder if the initialization code has a rogue pointer or variable that may be trying to modify a specific part of your memory that is not being occupied by the optimized code. When the optimizer is disabled, the code grows and therefore could be destroyed by it.

    The same above is true if the code reaches main but fails to properly run after that.

    Another test I would do is increase the stack size - the non-optimized code may require more stack to allocate variables and therefore cause a disruption between the two configurations. 

    I can think of additional issues like racing conditions and others, but if you suspect that something is wrong with the compiler tools we would need a test case or even your project to try to reproduce it.

    Hope this helps,

    Rafael