Optimisation

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why would a project fail to run with no optimmisation and work with all the others?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is a thread somewhere around which gives some explanation for this. If I remember it right, to make it simple: it is because the GCC was not meant for Harvard architecture mcus.
But either search for that thread or wait until some GCC guru comes in here.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sikolymester wrote:
There is a thread somewhere around which gives some explanation for this. If I remember it right, to make it simple: it is because the GCC was not meant for Harvard architecture mcus.
But either search for that thread or wait until some GCC guru comes in here.
That is just wrong... So GCC is not meant for all modern kinds of CPUs?

Sometimes optimization is needed because code is not tested in all corner cases. Sections with critical timing might fail when compiled with no optimization.

You should compile your application with the optimization level you assume you will be shipping with, or else you might trip into bugs after releasing.

I typically compile with -Os if size is most important, or -O2 if speed is more important.

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For in-system debugging (with JTAG) I have used -O0. Is that wrong? So far I haven't seen any anomalies in debugging mode, but indeed have had problems with the non-optimized or slightly optimized (-O1) code when uploaded to the board.

hce wrote:
Sometimes optimization is needed because code is not tested in all corner cases. Sections with critical timing might fail when compiled with no optimization.
This makes sense. Do you have any practical example where this might happen? I would assume that this is highly related to the internal peripherals of AVR32 as I have had problems, for example, with the SPI where the test application worked with -O2 but not with -O0. (The application was only communicating with the display.)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interesting, I isolated the problem. Back to my trouble with declaring a naked ISR... Oh Lord