Comments (4)
I think you are saying that this debug optimisation flag has no effect on the Uno as debugging as a whole is not implemented?
No, I was saying that the developers likely saw no reason to configure the platform to adjust the compilation commands according to the "Optimize for Debugging" setting since the primary use case for that setting is the Arduino sketch debugger and this platform can't be used with the Arduino sketch debugger.
However, the "Optimize for Debugging" feature can be used by a platform even if it has not been configured for sketch debugger support.
this had no effect
Did you add a compiler.optimization_flags
property reference to the compilation command patterns?
The patch should look something like this:
--- a/platform.txt
+++ b/platform.txt
@@ -17,15 +17,21 @@ compiler.warning_flags.default=
compiler.warning_flags.more=-Wall
compiler.warning_flags.all=-Wall -Wextra
+# Fallback property definition for compatibility with development tools that don't have the "Optimize for Debugging" control.
+compiler.optimization_flags=-Os -g
+# See: https://arduino.github.io/arduino-cli/latest/platform-specification/#optimization-level-for-debugging
+compiler.optimization_flags.release=-Os -g
+compiler.optimization_flags.debug=-O0 -g
+
# Default "compiler.path" is correct, change only if you want to override the initial value
compiler.path={runtime.tools.avr-gcc.path}/bin/
compiler.c.cmd=avr-gcc
-compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects
-compiler.c.elf.flags={compiler.warning_flags} -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections
+compiler.c.flags=-c {compiler.optimization_flags} {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects
+compiler.c.elf.flags={compiler.warning_flags} {compiler.optimization_flags} -flto -fuse-linker-plugin -Wl,--gc-sections
compiler.c.elf.cmd=avr-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -flto -MMD
compiler.cpp.cmd=avr-g++
-compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto
+compiler.cpp.flags=-c {compiler.optimization_flags} {compiler.warning_flags} -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto
compiler.ar.cmd=avr-gcc-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=avr-objcopy
(note the addition of the {compiler.optimization_flags}
property references)
You can do this in platform.local.txt
if you like.
from arduinocore-avr.
Hi @per1234 ,
oops! What a plank I am. I completely forgot to add the property reference to the compilation references. 😢 I have done so, as per your example, and everything is fine now. I have tested with an optimised for debugging and a release compilation and the debug settings are perfect.
Thank you very much indeed. This is a great help. I can get back to debugging code for my next Arduino book!
I've now closed this issue. Thanks again.
All the best,
Norman. (Author of Arduino Software Internals and Arduino Interrupts)
from arduinocore-avr.
Hi @NormanDunbar. The platform developer has complete control over the effect (or lack thereof) of the IDE's Sketch > Optimize for Debugging option through the platform configuration files:
The compiler.optimization_flags.debug
property has not been configured in the "Arduino AVR Boards" platform's configuration files. This means the Sketch > Optimize for Debugging option in Arduino IDE has no effect when compiling for a board of this platform. The compilation will proceed as appropriate for production application regardless of the setting of that menu option.
Since the platform has not been configured for use with the Arduino IDE 2.x integrated sketch debugger, a compiler.optimization_flags.debug
property in this platform would not be directly useful to Arduino IDE users. It could be for users like yourself who are using an external debugger though so we can consider this a feature request. We must weigh the benefit for the advanced users with this use case against the harm such a configuration will cause for the beginners who will enable the option without understanding what it does, forget all about it, and then suffer from excessive program size from there on.
from arduinocore-avr.
Good Morning @per1234 .
Many thanks for a prompt response. If I'm reading you correctly, I think you are saying that this debug optimisation flag has no effect on the Uno as debugging as a whole is not implemented?
- I tried adding
compiler.optimization_flags.debug=-O0 -g
toplatform.local.txt
and after restarting the IDE, this had no effect. - I also tried adding it to
platform.txt
and again, this had no effect.
I wasn't sure from your reply if you simply meant that this setting hadn't been configured, but it seems that it's not actually available to be used.
No worries, I can compile and link manually with the proper debug settings.
Best regards,
Norman.
from arduinocore-avr.
Related Issues (20)
- Version 1.8.6 missing on downloads.arduino.cc, no signature for version 1.8.5 HOT 2
- GPG signatures missing for versions 1.8.5 and 1.8.6
- elf files for bootloaders HOT 1
- Add printing to NULL in the Print class? HOT 3
- UDEV rules for: Bricked Counterfeit Serial (UART) IC HOT 2
- Make your Uno Kit USB serial firmware missing ?
- How can i install it? HOT 1
- -DCDC_DISABLED not working HOT 6
- Update bootloaders HOT 4
- Wstring: getBytes() method is not clear to use with passing number of bytes to fill in buffer
- Create baseclass for HardwareSerial and SoftwareSerial HOT 1
- Stream#find does incorrect comparison HOT 1
- USB suspend not implemented
- Arduino UNO R4 and Wire library HOT 1
- Wire library read() returns 0xFF on reading only one byte HOT 2
- Arduino.h Defines Macros that Should be Functions HOT 1
- USB enumeration timeouts due to missing ZLPs HOT 4
- STK600 support
- Add a function returning currently used analogRead resolution HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinocore-avr.