Page 6 states that platform.txt exist in:
C:\Users\XXXX\AppData\Roaming\Arduino15\packages\arduino\hardware\avr\1.6.x\platform.txt
However I have found that inside mu PC; C:\Users\XXXX\AppData\Roaming\Arduino15 , there is no folder name packages. I have searched in hidden files also.
However I have found platform.txt file in:
C:\Program Files\Arduino\hardware\arduino\avr
Not sure if I have to edit in this. I have attached a copy.
There are three places where -Os is found, line 23,26 & 30.
So should I change at these 3 places only depending on requirement:
No optimization: -O0
speed optimization: -O3
size optimization: -Os
balance optimization: -O2
So should I change at these 3 places only depending on requirement:
No optimization: -O0
speed optimization: -O3
size optimization: -Os
balance optimization: -O2
Why do you think you need to change the optimization level?
Want to learn abt optimization & test the result, how it changes the time/size in arduino.
In final code, I may use default setting. But at learning stage I want to leran them.
Since I have multiple files in my code, so should I replace "-Os" with "-fwhole-program -O3"?
I have made 3 changes in platform.txt as present in: Line 23, 26 & 30.
i.e changed O0,Os & O3
compiler.c.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -MMD
# -w flag added to avoid printing a wrong warning http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
# This is fixed in gcc 4.8.3 and will be removed as soon as we update the toolchain
compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections
compiler.c.elf.cmd=avr-gcc
compiler.S.flags=-c -g -x assembler-with-cpp
compiler.cpp.cmd=avr-g++
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
On new sketch (empty setup & loop), code builds without any warning on Os, O3. However when I changed it to O0 it shows warning in many compiled files. Why this error?
In file included from C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\USBAPI.h:27:0,
from C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\Arduino.h:225,
from C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial2.cpp:25:
c:\program files\arduino\hardware\tools\avr\avr\include\util\delay.h:95:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp]
# warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"
Also my code has multiple .ino & .h files. So will chnaging only these three opt flag will include all files or I have to do something else.
Default -Os
Sketch uses 22502 bytes (8%) of program storage space. Maximum is 253952 bytes.
Global variables use 674 bytes (8%) of dynamic memory, leaving 7518 bytes for local variables. Maximum is 8192 bytes.
Same code size generated for below thre options
a) Replace -Os by -O3
b) Replace -Os by -fwhole-program -O3
c) Replace -Os by -flto -O3
Sketch uses 44858 bytes (17%) of program storage space. Maximum is 253952 bytes.
Global variables use 686 bytes (8%) of dynamic memory, leaving 7506 bytes for local variables. Maximum is 8192 bytes.
Havent tested on hardware yet. Will check. ordered new finger print module.