Go Down

Topic: Compiler optimisation for due board (Read 69 times) previous topic - next topic

himsikha

Hi,

How to change the compiler options for  arduino due (arduino -1.5.7) running on linux machine?

pert

Is there a particular reason you're using Arduino IDE 1.5.7? That is a very outdated version that was only ever considered a beta.

himsikha

Hi,

Yeah its beta version only.
In the arduino 1.8.5 ,i am unable to find find option for arduino due board.So, i am using arduino-1.5.7

pert

They stopped bundling the hardware package for the Due (Arduino SAM Boards) in recent versions of the
  • Arduino IDE but it's quite easy to install it:
  • Tools > Board > Boards Manager
  • Wait for downloads to finish.
  • Click on "Arduino SAM Boards".
  • Click "Install".
  • Wait for installation to finish.
  • Click "Close".


There has been a lot of development on the Arduino IDE since 1.5.7 so you might find it useful to update but the choice is yours of course.

As for the compiler options. These are set in the file platform.txt. Each hardware package has its own platform.txt so you will notice there is one for Arduino AVR Boards and another for Arduino SAM Boards. In your Arduino IDE 1.5.7 installation you will find the Arduino SAM Boards platform.txt at {Arduino IDE instatallation folder}/hardware/arduino/sam/platform.txt.

To make changes to the flags you can edit that file directly. The Arduino IDE only scans platform.txt on startup so you need to close all Arduino IDE windows and then start the IDE again before changes you make to platform.txt will take effect.

There are also some options to add custom compilation flags without editing platform.txt.

You can create a file named platform.local.txt and in that file define any of these properties:
  • compiler.c.extra_flags
  • compiler.c.elf.extra_flags
  • compiler.cpp.extra_flags
  • compiler.ar.extra_flags
  • compiler.elf2hex.extra_flags

You can examine platform.txt to see exactly where those properties will be expanded in the compilation recipes. For example:
Code: [Select]
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {compiler.libsam.c.flags} {includes} "{source_file}" -o "{object_file}"
The same requirement of restarting the IDE applies for platform.local.txt.

There is also the possibility to pass these properties from the command line if you're using the Arduino IDE CLI. For example:
Code: [Select]
arduino --pref compiler.cpp.extra_flags=-O0 --upload --board arduino:sam:arduino_due_x_dbg foobar.ino
Unfortunately it's only possible to do this when compiling from the command line. You can't set the compiler flags as used by compilation in the Arduino IDE GUI from the command line.

More information on the Arduino IDE CLI:
https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc

pert

I should mention if you do update to a recent IDE version that requires you to install Arduino SAM Boards then the platform.txt will be found in a different location on your computer. I can provide instructions for finding that.

Go Up