Hello all,
I have a project that I wrote a few years ago using Arduino IDE 1.8.5. The source code is too long to post here, but is available on GitHub (yes, this is actually a link to github.com): GitHub - OpenPanzerProject/TankIR: A standalone tank IR device for use with Arduino UNO/Nano/other ATmega328 boards
The project is designed to run on any ATmega328 board; I always compile for the Nano. It is basically an IR sending and receiving program, but instead of the usual TV remote stuff it implements IR codes used in the RC tank hobby.
The program not only compiles fine in 1.8.5 but when loaded onto a board it actually functions as designed. Here are the compiled results:
Sketch uses 24300 bytes (79%) of program storage space. Maximum is 30720 bytes.
Global variables use 1462 bytes (71%) of dynamic memory, leaving 586 bytes for local variables. Maximum is 2048 bytes.
Recently I had another use attempt to compile in 1.8.13 and he reported getting the "stability problems may occur" warning. I downloaded 1.8.13 and confirmed, here are the compile results:
Sketch uses 25028 bytes (81%) of program storage space. Maximum is 30720 bytes.
Global variables use 1864 bytes (91%) of dynamic memory, leaving 184 bytes for local variables. Maximum is 2048 bytes.
Low memory available, stability problems may occur.
Dynamic memory for the same code has increased almost 400 bytes from 1,462 to 1,864.
I thought to myself, "I should see at what point between 1.8.5 this changes." Lo and behold, the sketch won't even compile on 1.8.6 through 1.8.9, in all four cases I get the same error message from the compiler:
lto1.exe: internal compiler error: in lto_output_varpool_node, at lto-cgraph.c:624
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper.exe: fatal error: C:\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status
compilation terminated.
c:/arduino/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Nano.
When we get to 1.8.10 compilation works once more, but with the same larger size tallies that we get in 1.8.13 listed above. (I did not test 1.8.11 or 1.8.12)
I have a slew of other sketches from different projects laying around, and I compiled a few in 1.8.5 compared to 1.8.13. In all cases that I tried, the compiler actually gave me a smaller final program in the end with 1.8.13, as we would expect as optimizations improve. But for this specific project, the result is the opposite.
We have tried running the Tank IR code compiled on 1.8.13 in the real world, and in fact it does not work although we have not delved into exactly where it is breaking. But it seems likely at some point it is running out of memory and going into an unpredictable state.
Turning on verbose output for the compiler shows some mild warnings (typedef was ignored in this declaration, variable set but not used, etc...) Those can be cleaned up but don't in my opinion account for the 400 byte difference.
Now the failure to compile in 1.8.6 through 1.8.9 is probably an important clue, but the error message given doesn't mean much to me personally so I am not sure how to leverage that.
I am happy to do my own legwork, but although I have written lots of programs this sort of thing is a bit outside my expertise and I'm not sure where to start figuring things out.
And yes, it likely is possible to reduce the size of the sketch and I think that is a good exercise for me to do, but I would still like to get the bottom of this particular issue.
Any pointers or hints of things to explore would be most appreciated. My gratitude in advance!
Luke