i am writing this to tell you a problem i am facing: when I turn on optimization with gcc, any level ranging from 1 to 3, my system won´t run, it crashes with undf or data abort. If I turn it off, my system runs without any problem. The system crashes if I use the -fomit option too.
I am using yagarto gcc 4.2.2 and at91sam7xc256, freertos 4.7.1, lwip 1.2.0.
First, stop the debugger after the crash to see where you are. I guess you will be in an abort handler. If so look at the abort link register to find the instruction that caused to exception.
Second, remove most of your application code and definitely remove lwip. Then write a simple task that does nothing but flashes an LED.
I just downloaded the latest V4.2.2 Yagarto and tried it with the ARM7_AT91SAM7X256_Eclipse project at -O0, -O3 and -Os optimisation levels with no problems.
thanks for the replies, I made the led test and it worked too. So I investigated deeper into my code and disabled two interrupts I had, TC0 and SSC. Then everything worked.
What is funny is that the code works without problems when I have no optimization. Either of them enabled, it does not work.
moreover, there is no context switch from within these two ISRs.
i will try to debug more. will post here the results.
i´ve made it work, i had to use the naked attribute and the port save context, the same thing other interrupts that cause a context switch does, but even when it is not the case.
please, if possible, change the lwip rowley documentation to warn other users too.
[Bug c/25428] New: arm-elf-gcc generating wrong code with -O flag at functions with __attribute__ ((interrupt ("IRQ")))
* From: "th dot r dot klein at web dot de" <gcc-bugzilla at gcc dot gnu dot org>
* To: gcc-bugs at gcc dot gnu dot org
* Date: 15 Dec 2005 14:57:21 -0000
* Subject: [Bug c/25428] New: arm-elf-gcc generating wrong code with -O flag at functions with __attribute__ ((interrupt ("IRQ")))
* Reply-to: gcc-bugzilla at gcc dot gnu dot org
If a little bit more complex interrupt function is required the compiler
genrates wrong code (olny with -O flag set).