Pages: [1]   Go Down
Author Topic: [SOLVED] Is there any way to attach -D from within arduino IDE  (Read 1676 times)
0 Members and 1 Guest are viewing this topic.
Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6898
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to attach a -Ddisable_simple_fns option to the compiler command that arduino IDE generates automatically. Is there a way to do it? Thanks. It would be nice to have this hack "custom def" in arduino IDE although I don't know how to.

[Edit]: The solution appears to require either visual studio plugin or arduino 1.5 and creating new board def in boards.txt with a "board_name.build.extra_flags=-Dsomething=value".
« Last Edit: December 28, 2012, 01:26:36 pm by liudr » Logged


Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I believe IDE 1.5 reads the command-lines from platform.txt.


Edit: Remove plural.
« Last Edit: December 28, 2012, 02:59:35 am by Coding Badly » Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6898
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks. I will put IDE upgrade on my agenda once I'm done with work at hand. I am using 1.0 right now.
Logged


North Queensland, Australia
Online Online
Edison Member
*
Karma: 53
Posts: 1785
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I believe IDE 1.5 reads the command-lines from platforms.txt.

Hey, i'm using 1.5.1r2 I cannot find a 'platforms.txt',
I also had a browse through the IDE preferences ( C:\Users\Chris\AppData\Roaming\Arduino ) but no luck. Would be very nice if I could change the optimisation levels.

Any locations I should be looking in?

EDIT: windows search is blind ( the machine's fault not the user  smiley-razz ), it was in "D:\arduino-1.5.1r2\hardware\arduino\avr"
« Last Edit: December 28, 2012, 02:26:45 am by pYro_65 » Logged


Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Sorry about that.  The filename is platform.txt (singular; not plural).
« Last Edit: December 28, 2012, 02:59:12 am by Coding Badly » Logged

Offline Offline
Full Member
***
Karma: 10
Posts: 162
IDE for Microsoft Visual Studio and Atmel Studio 6.1, optional USB Debugger
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It's in the exeFolder/hardware/arduino/avr and can work in conjunction with the new properties in the 1.5 boards.txt

Alternatively if you want it to work with 1.0.x formats then the visual studio plugin allows any number of -D defines via the project property "Defines - Project"

But 1.5 might be the simplest route unless you also want intellisense etc and are using windows.
« Last Edit: December 28, 2012, 10:22:17 am by Visual Micro » Logged

Arduino for Microsoft Visual Studio Pro and Atmel Studio 6.1 http://www.visualmicro.com
Arduino Debugger http://www.visualmicro.com/post/2012/05/05/Debug-Arduino-Overview.aspx

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6898
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Where do I get this visual studio plugin?
Logged


Offline Offline
Full Member
***
Karma: 10
Posts: 162
IDE for Microsoft Visual Studio and Atmel Studio 6.1, optional USB Debugger
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Download via the main site here

You need a copy of Visual Studio Pro. This page shows how to get a copy for free

If you have any questions or want the serial debugger upgrade then register for the forum
Logged

Arduino for Microsoft Visual Studio Pro and Atmel Studio 6.1 http://www.visualmicro.com
Arduino Debugger http://www.visualmicro.com/post/2012/05/05/Debug-Arduino-Overview.aspx

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6898
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It's in the exeFolder/hardware/arduino/avr and can work in conjunction with the new properties in the 1.5 boards.txt

Is it only possible to modify boards.txt to add another def in 1.5?

Thanks for the visual studio link.
Logged


Offline Offline
Full Member
***
Karma: 10
Posts: 162
IDE for Microsoft Visual Studio and Atmel Studio 6.1, optional USB Debugger
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've only recently started with 1.5 so can't recall exactly but I think you can add your own overrides and "recipe" patterns directly to the boards.txt. You will find the default settings and recipe patterns in the platform.txt. Example:-

Code:
recipe.cpp.o.pattern=

So this would mean you could copy a board def in the boards.txt, change the name to whatever you want and add your own recipe specifically for your new board definition. This would allow you to optionally invoke your additional compiler defines just by switching board. (I hope this info is correct)

If you have vs installed then it is certainly easier to achieve this with the vs plugin, which also allows us to set a -D list on a per configuration basis. This means, for example, that we can have a -D list for "My Normal Compile" and a list for "My Special Compile" etc.

EDIT: How to copy a board def - Example

Below is the def for the Uno
Code:
##############################################################

uno.name=Arduino Uno
uno.upload.tool=avrdude
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200

uno.bootloader.tool=avrdude
uno.bootloader.low_fuses=0xFF
uno.bootloader.high_fuses=0xDE
uno.bootloader.extended_fuses=0x05
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.bootloader.file=optiboot/optiboot_atmega328.hex

uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard

Below is a duplicate called Arduino Uno 2. Notice that each property for the board starts with a unique id, in this case "uno2". So to copy a def you only need to set the .name property and ensure that each entry starts with a unique id of your choice.
Code:
##############################################################

uno2.name=Arduino Uno 2
uno2.upload.tool=avrdude
uno2.upload.protocol=arduino
uno2.upload.maximum_size=32256
uno2.upload.speed=115200

uno2.bootloader.tool=avrdude
uno2.bootloader.low_fuses=0xFF
uno2.bootloader.high_fuses=0xDE
uno2.bootloader.extended_fuses=0x05
uno2.bootloader.unlock_bits=0x3F
uno2.bootloader.lock_bits=0x0F
uno2.bootloader.file=optiboot/optiboot_atmega328.hex

uno2.build.mcu=atmega328p
uno2.build.f_cpu=16000000L
uno2.build.core=arduino
uno2.build.variant=standard
« Last Edit: December 28, 2012, 01:32:06 pm by Visual Micro » Logged

Arduino for Microsoft Visual Studio Pro and Atmel Studio 6.1 http://www.visualmicro.com
Arduino Debugger http://www.visualmicro.com/post/2012/05/05/Debug-Arduino-Overview.aspx

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6898
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've only recently started with 1.5 so can't recall exactly but I think you can add your own "recipe" pattern directly to the boards.txt. You will find the default "recipe" patterns in the paltform.txt

Code:
recipe.cpp.o.pattern=

So this would mean you could copy a board def in the boards.txt, change the name to whatever you want and add your own recipe specifically for your new board definition. This would allow you to optionally invoke your additional compiler defines just by switching board. (I hope this info is correct)

It's certainly easier to achieve this with the vs plugin which also allows you to set a -D list on a per configuration basis. Hence you can have a -D list for "My Normal Compile" and a list for "My Special Compile" etc.

Thanks. I added a new line phi_panel.build.extra_flags=-Ddisable_simple_fns to a new board def I copied and changed and it did the trick, according to the verbose output. I wonder if I can do phi_panel.build.extra_flags=-DXX=10 with the defined number instead of just defining a name. Will try later.

Code:
##############################################################

phi_panel.name=Phi panel
phi_panel.upload.tool=avrdude
phi_panel.upload.protocol=arduino
phi_panel.upload.maximum_size=32256
phi_panel.upload.speed=115200

phi_panel.bootloader.tool=avrdude
phi_panel.bootloader.low_fuses=0xFF
phi_panel.bootloader.high_fuses=0xDE
phi_panel.bootloader.extended_fuses=0x05
phi_panel.bootloader.unlock_bits=0x3F
phi_panel.bootloader.lock_bits=0x0F
phi_panel.bootloader.file=optiboot/optiboot_atmega328.hex

phi_panel.build.mcu=atmega328p
phi_panel.build.f_cpu=16000000L
phi_panel.build.core=arduino
phi_panel.build.variant=standard
phi_panel.build.extra_flags=-Ddisable_simple_fns

## recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -Ddisable_simple_fns -DF_CPU={build.f_cpu} -D{software}={runtime.ide.version} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
Logged


Offline Offline
Full Member
***
Karma: 10
Posts: 162
IDE for Microsoft Visual Studio and Atmel Studio 6.1, optional USB Debugger
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Great. I don't see why you can't do that. The extra flags are just passed to the compile statement without change, so should work fine.
Logged

Arduino for Microsoft Visual Studio Pro and Atmel Studio 6.1 http://www.visualmicro.com
Arduino Debugger http://www.visualmicro.com/post/2012/05/05/Debug-Arduino-Overview.aspx

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6898
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yep, everything I typed in there gets appended to the compiler options. Thanks for helping me through! Karma for you!
Logged


Pages: [1]   Go Up
Jump to: