Dear all,
I am running out of internal RAM space in the F28335, so I started to play with the optimizer options (note im using CCS v5.0, and compiler version 6.0.2). The thing is that these optimization options are not very intuitive (i.e. different optimization options are located in different tabs, or they behave against what one may expect).
So here is my case. I built my code with the code optimization level (--opt_level) set to 3. Then at some point I run out of space, and I need now to play with this parameters to make some room. Then, by compiling with different values for --opt_level, I got the following results:
Optimization level |
RAM Free space |
Build OK? |
0 |
0x3D0 |
ERROR. Not enough space in RAM. Cannot allocate an object in that hole size |
1 |
0x1F6 |
OK |
2 |
0x11E |
OK |
3 |
0x10 |
OK |
4 |
- |
ERROR with some volatile variable. |
Does it have any sense? I mean, it would make sense that the more optimized the code is, the faster, but also, the code size would be bigger (and less free space in RAM), however, for opt_level=0, the code size is actually bigger than for opt_level = 1,2, or 3.
I also tried checking the box "Optimize for code size"(--opt_for_space), but against one may think, it decreases the available memory in all cases.
As I said, these parameters are in the "Basic Options" tab of the compiler options, but there are more optimizer options in the "optimizations" tab (not very intuitive). And then I played with the option "Optimize for code speed" . This parameter is usually empty, but if I set it to any value from 0 to 5, the code size will be bigger.
And last, I changed the debugging model from "full symbolic debug" to "symbolic debug for program analisys", throwing these results:
Optimization level |
RAM Free space |
Build OK? |
0 |
0x1F3 |
OK |
1 |
0x44C |
OK |
2 |
0x47A |
OK |
3 |
0x35A |
OK |
4 |
- |
ERROR |
So I can see that code size is much smaller (RAM free space higher), however, again, this size goes up and down apparently randomly with the optimization level (size goes down from 0 to 2, and then goes up with level 3), which doesn't make too much sense to me.
Could you help me understanding a bit better how each optimization parameter works, and what settings I should have assuming I want to free as much space as possible? I also read the documentation TMS320C28x Optimizing C/C++ Compiler, v15.12.0.LTS, however, it didn't help me much.
Thank you beforehand and best regards,
Jorge.