Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Compiling a Arduino app with compiler switches and not linking to core libraries (Read 17289 times)
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Compiling a Arduino app with compiler switches and not linking to core libraries
Apr 17th, 2013 at 12:16am
 
Hi,

Am trying to build the APM project (https://github.com/diydrones/ardupilot.git) on Visual Micro.

specifically the APMrover2.pde project.

The group uses a custom Arduino IDE that doesn't change a great deal.† Specifically it adds a custom -D (CONFIG_HAL_BOARD == HAL_BOARD_APM2) and does not link with the core libraries, but rather only the libraries they provide which supplant the existing arduino libraries. For referenct, their customozied IDE is located here:

https://code.google.com/p/ardupilot-mega/downloads/detail?name=ArduPilot-Arduino
-1.0.3-windows.zip&can=2&q=

Am not being successful though.† I have VMs path set to the customized build enviro correctly, I have copied all the APM-specific libraries to the library directory of the customized Arduino build.† They are being imported.†

Get a number of redeclaration errors...

I am likely missing something. I can compile the project happily and easily in their build environment. Would like to replatform on the VM environment which I think will be more suitable.† Would greatly appreciate guidance as to what I may be missing.

The compiler output and errors are too long to list here...will do that in a subsequent post.† Can't find an attach file at the moment...

Back to top
« Last Edit: Apr 19th, 2013 at 5:29am by Visual Micro »  
 
IP Logged
 
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Re: Compiling a Arduino app with compiler switches and not linking to core libraries
Reply #1 - Apr 17th, 2013 at 12:19am
 
Output example from Visual Micro (version 12.30)

Quote:
Compiling 'APMrover2' for 'Arduino Mega 2560 or Mega ADK'
Build folder: file://C:\Users\Greg Brill\AppData\Local\VMicro\Arduino\Builds\APMrover2\mega2560
SketchLibFolders
C:\Program Files\arduino-1.0.1\hardware\arduino\cores\arduino;C:\Program Files\arduino-1.0.1\hardware\arduino\variants\mega;C:\ardupilot-arduino\librarie
s\AP_Common;C:\ardupilot-arduino\libraries\AP_Common\utility;C:\ardupilot-arduin
o\libraries\AP_Progmem;C:\ardupilot-arduino\libraries\AP_Progmem\utility;C:\ardu
pilot-arduino\libraries\AP_HAL;C:\ardupilot-arduino\libraries\AP_HAL\utility;C:\
ardupilot-arduino\libraries\AP_Menu;C:\ardupilot-arduino\libraries\AP_Menu\utili
ty;C:\ardupilot-arduino\libraries\AP_Param;C:\ardupilot-ardarduino\libraries\AP_
Declination;C:\ardupilot-arduino\libraries\AP_Declination\utility;c:\ardupilot-a
rduino\hardware\tools\avr\avr\include\;c:\ardupilot-arduino\hardware\tools\avr\a
vr\include\avr\;c:\ardupilot-arduino\hardware\tools\avr\avr\;c:\ardupilot-arduin
o\hardware\tools\avr\lib\gcc\avr\4.3.2\include\;
Summary: Header=1 Prototypes=177 Imports=42
C:\ardupilot-arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101 -DCONFIG_HAL_BOARD=HAL_BOARD_APM2 -Dboard=mega2560 -DVISUALMICRO_COMPILER_VER=1 -I"C:\Program Files\arduino-1.0.1\hardware\arduino\cores\arduino" -I"C:\Program Files\arduino-1.0.1\hardware\arduino\variants\mega" -I"C:\ardupilot-arduino\libraries\AP_Common" -I"C:\ardupilot-arduino\libraries\AP_Progmem" -I"C:\ardupilot-arduino\libraries\AP_HAL" -I"C:\ardupilot-arduino\libraries\AP_Menu" -I"C:\ardupilot-arduino\libraries\AP_Param" -I"C:\ardupilot-arduino\libraries\AP_GPS" -I"C:\ardupilot-

..more of the same, and then...

Filter.h : from
AP_Baro.h : from
APMrover2.pde : from
AP_Math.h : this is the location of the previous definition
APMrover2.pde : In file included from
arduino.h : "RAD_TO_DEG" redefined
LowPassFilter.h : In file included from
Filter.h : from
AP_Baro.h : from
APMrover2.pde : from
AP_Math.h : this is the location of the previous definition
APMrover2.pde : new declaration 'uint8_t digitalRead(uint8_t)'
arduino.h : ambiguates old declaration 'int digitalRead(uint8_t)'
APMrover2.pde : : In function 'uint8_t digitalRead(uint8_t)':
failsafe.pde : new declaration 'uint8_t digitalRead(uint8_t)'
arduino.h : ambiguates old declaration 'int digitalRead(uint8_t)'
APMrover2.pde : : In function 'int8_t test_wp(uint8_t, const Menu::arg*)':
test.pde : cannot pass objects of non-POD type 'class AP_Float' through '...'; call will abort at runtime
APMrover2.pde : : At global scope:
APMrover2.pde : 'void send_simstate(mavlink_channel_t)' declared 'static' but never defined
Error compiling
Build path was: C:\Users\Greg Brill\AppData\Local\VMicro\Arduino\Builds\APMrover2
Back to top
« Last Edit: Apr 19th, 2013 at 5:38am by Visual Micro »  
 
IP Logged
 
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Re: Compiling a Arduino app with compiler switches and not linking to core libraries
Reply #2 - Apr 17th, 2013 at 3:21am
 
HAL Output example from modified arduino ide

Quote:
Building for ArduPilot Mega 2.x
Excluding arduino core from include paths
C:\ardupilot-arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=103 -mcall-prologues -DCONFIG_HAL_BOARD=HAL_BOARD_APM2 -DEXCLUDECORE -IC:\ardupilot-arduino\libraries\AP_Common -IC:\ardupilot-arduino\libraries\AP_Progmem -IC:\ardupilot-arduino\libraries\AP_HAL -IC:\ardupilot-arduino\libraries\AP_Menu -IC:\ardupilot-arduino\libraries\AP_Param -IC:\ardupilot-arduino\libraries\AP_GPS -IC:\ardupilot-arduino\libraries\AP_ADC -IC:\ardupilot-arduino\libraries\AP_ADC_AnalogSource -IC:\ardupilot-arduino\libraries\AP_Baro -IC:\ardupilot-arduino\libraries\AP_Compass -IC:\ardupilot-arduino\libraries\AP_Math -IC:\ardupilot-arduino\libraries\AP_InertialSensor -IC:\ardupilot-arduino\libraries\AP_AHRS -IC:\ardupilot-arduino\libraries\PID -IC:\ardupilot-arduino\libraries\RC_Channel -IC:\ardupilot-arduino\libraries\AP_RangeFinder -IC:\ardupilot-arduino\libraries\Filter -IC:\ardupilot-arduino\libraries\AP_Buffer -IC:\ardupilot-arduino\libraries\AP_Relay -IC:\ardupilot-arduino\libraries\AP_Mount -IC:\ardupilot-arduino\libraries\GCS_MAVLink -IC:\ardupilot-arduino\libraries\AP_Airspeed -IC:\ardupilot-arduino\libraries\memcheck -IC:\ardupilot-arduino\libraries\DataFlash -IC:\ardupilot-arduino\libraries\SITL -IC:\ardupilot-arduino\libraries\AP_HAL_AVR -IC:\ardupilot-arduino\libraries\AP_HAL_AVR_SITL -IC:\ardupilot-arduino\libraries\AP_HAL_PX4 -IC:\ardupilot-arduino\libraries\AP_HAL_Empty -IC:\ardupilot-arduino\libraries\AP_Declination C:\Users\GREGBR~1\AppData\Local\Temp\build2752751859467373936.tmp\APMrover2.cpp -o C:\Users\GREGBR~1\AppData\Local\Temp\build2752751859467373936.tmp\APMrover2.cpp.
o
In file included from C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS.h:7,
† †† †† †† †† †† from APMrover2.pde:54:
C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS_SIRF.h:35: warning: ignoring #pragma pack
C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS_SIRF.h:73: warning: ignoring #pragma pack
In file included from C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS.h:9,
† †† †† †† †† †† from APMrover2.pde:54:
C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS_UBLOX.h:58: warning: ignoring #pragma pack
C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS_UBLOX.h:152: warning: ignoring #pragma pack
In file included from C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS.h:10,
† †† †† †† †† †† from APMrover2.pde:54:
C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS_MTK.h:34: warning: ignoring #pragma pack
C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS_MTK.h:45: warning: ignoring #pragma pack
In file included from C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS.h:11,
† †† †† †† †† †† from APMrover2.pde:54:
C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS_MTK19.h:37: warning: ignoring #pragma pack
C:\ardupilot-arduino\libraries\AP_GPS/AP_GPS_MTK19.h:50: warning: ignoring #pragma pack
In file included from APMrover2.pde:76:
C:\ardupilot-arduino\libraries\SITL/SITL.h:11: warning: ignoring #pragma pack
C:\ardupilot-arduino\libraries\SITL/SITL.h:26: warning: ignoring #pragma pack
test.pde: In function 'int8_t test_wp(uint8_t, const Menu::arg*)':
test.pde:296: warning: cannot pass objects of non-POD type 'class AP_Float' through '...'; call will abort at runtime
APMrover2.pde: At global scope:
APMrover2.pde:119: warning: 'void send_simstate(mavlink_channel_t)' declared 'static' but never defined
C:\ardupilot-arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=103 -mcall-prologues -DCONFIG_HAL_BOARD=HAL_BO
Back to top
« Last Edit: Apr 27th, 2013 at 9:52pm by Visual Micro »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10467
United Kingdom
Re: Compiling a Arduino app with compiler switches and not linking to core libraries
Reply #3 - Apr 19th, 2013 at 4:21am
 
Hi Greg,

I think I have found an easy solution but you need to install the latest visual micro arduino plugin which is disguised on our codeplex site as the Teensy Alpha Version. The version is not alpha any longer I just have not had time to change its name.

Summary - Arduino IDE Custom Hardware Support (Boards)

All Arduino versions support custom "hardware" in a similar manner to how custom "libraries" are supported.

Custom hardware can be defined in a folder called "hardware" that exists at the same location as the "libraries" folder. The following zip contains a "hardware" folder with 3 custom board definitions.

Arduino mega 1280 HAL (apm1)
Arduino mega 2560 HAL (apm1)
Arduino mega 2560 HAL (apm2)

Extract this zip to the same folder that contains the "Libraries, Arducopter, Apmrover etc" folders.

Re-start visual studio after unzipping the file and you should see the three new boards at the end of the arduino boards list. Select the board you require and the compile should be identical to the modified apm arduino ide.

...


Notes

A bug in visual micro means that currently you must leave the project defines (discussed earlier) in visual studio. When the next version of vm is released you will no longer need the defines in Visual Studio because the custom hardware definition automatically includes the correct defines.

The custom hardware "options and defines" syntax is compatible with the Teensy Ide which means that the TeensyDuino Ide will also now compile Apm which might be useful for linux and mac users.

Creating a fork of the arduino ide is no easy task. I notice the apm version does not remember which sketch was last open and suffers a few other minor glitches. The Teensyduino ide is more mature and also caters for "custom" user interface menus should the need arise. (An example of a custom menu is the "Ardupilot" menu in the modified ide).

The diyd community might consider teensyduino in place of the modified arduino ide. You could remove arduino boards that are not used (such as uno) and make a more meaningful boards list for new users.

Visual Micro does not care which ide you have installed. In fact, even the standard arduino 1.0.3 or 1.0.4 ide will work with apm and the custom hal boards.

When using the custom HAL boards that appear in the boards list in the modified arduino ide users will still need to set the HAL options as per the standard apm guidelines.

It is not possible to build a project based on the custom hal boards in the standard arduino ide.

The Teensyduino ide format is a better solution for diydrones than the apm ide because Teensyduino allows the UI and the build process to be altered via the custom hardware definitions. This avoids the need a "hard coded" ide which must be frequently updated.

Diyd seem to recommend placing the "arduino ide" under the apm firmware folder. I guess they feel it is easier for new users to install the software this way. This is not required and in my view it makes things more complicated for users. I would install whichever ide we want to use in a folder such as "c:\arduino\apmIDE". When upgrading the ide I would rename the old one to "c:\arduino\apmIDE_last" and install the new ide in "c:\arduino\apmIDE". So the "current" ide is always in the same place regardless of apm firmware version.

The teensyduino ide supports other variations but I have chosen the 3 HAL board route because it represents less wiki space. We only have to explain to users about switching board between 1280/2560/hal where the modified ide requires us to explain about boards and then about the "Ardupilot" Hal menu options. 3 different variations of HAL board also works well with the compiler cache, no need to re-start ide
Back to top
« Last Edit: Apr 19th, 2013 at 5:27am by Visual Micro »  

WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10467
United Kingdom
Re: Compiling a Arduino app with compiler switches and not linking to core libraries
Reply #4 - Apr 19th, 2013 at 5:22am
 
Greg, thanks for all the posts and emails with so much help. I hope you don't mind but, now that we have a documented solution, I have removed the posts from this thread so that the question and the solution can more easily be used by others.

For completeness I add an example of the apm2 HAL custom board definition contained in the zip of the previous post.

You see that we can† provide the compiler switches, defines and prevent creation of the core.a archive.

We also re-define the arduino core to a dummy core in "hardware\apm\apmHAL". The variants declaration has been removed. -DEXCLUDECORE is redundant but has been included for the purposes of this example...

These custom settings are a combination of standard arduino and teensyduino architectures. The visual studio plugin supports both architectures so we can "mix and match" for a nice simple end result.

Example taken from hardware\boards.txt. Items in red are non standard arduino settings for a 2560 board.


##############################################################

apm2_2560HAL.name=Arduino Mega 2560 HAL (Apm 2)

apm2_2560HAL.upload.protocol=wiring
apm2_2560HAL.upload.maximum_size=258048
apm2_2560HAL.upload.speed=115200

apm2_2560HAL.bootloader.low_fuses=0xFF
apm2_2560HAL.bootloader.high_fuses=0xD8
apm2_2560HAL.bootloader.extended_fuses=0xFD
apm2_2560HAL.bootloader.path=stk500v2
apm2_2560HAL.bootloader.file=stk500boot_v2_mega2560.hex
apm2_2560HAL.bootloader.unlock_bits=0x3F
apm2_2560HAL.bootloader.lock_bits=0x0F

apm2_2560HAL.build.mcu=atmega2560
apm2_2560HAL.build.f_cpu=16000000L

apm2_2560HAL.build.core=apmHAL
apm2_2560HAL.build.option1=-mcall-prologues
apm2_2560HAL.build.option2=-DCONFIG_HAL_BOARD=HAL_BOARD_APM2
apm2_2560HAL.build.option3=-DEXCLUDECORE
apm2_2560HAL.build.linkoption1=-mcall-prologues
apm2_2560HAL.build.noarchive=true
Back to top
« Last Edit: Apr 19th, 2013 at 5:45am by Visual Micro »  

WWW  
IP Logged
 
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Re: Compiling a Arduino app with compiler switches and not linking to core libraries
Reply #5 - Apr 21st, 2013 at 12:59pm
 
You have my undying gratitude.  This is fantastic.  Tried this and I am now getting a compiled result.

What I would add for the benefit of others reading this post, when you are saying "project defines must still be in Visual Studio as discussed before", this is what is meant:

One must open the project properties pane in visual studio for one's project.   So, in my case, in the solution explorer, I select the project under the solution which is "APMrover2," and press F4.  This will open the Project Properties Pane.  Then I add a value for the "Defines-Project" property.  This is what will contain our -D defines.  So in that field, you must have

EXCLUDE_CORE;CONFIG_HAL_BOARD=HAL_BOARD_APM2

And this will translate to:
-DEXCLUDE_CORE -DCONFIG_HAL_BOARD=HAL_BOARD_APM2
on the compilation.

Back to top
 
 
IP Logged
 
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Re: Compiling a Arduino app with compiler switches and not linking to core libraries
Reply #6 - Apr 22nd, 2013 at 6:36pm
 
Question: when I install the teensy version, I get a message upon running Visual Studio that there is a newer version. 

I have downloaded the latest, so is it possible it is checking the non-teensy version?

I am assuming the two can not run concurrently, right?

G
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10467
United Kingdom
Re: Compiling a Arduino app with compiler switches and not linking to core libraries
Reply #7 - Apr 22nd, 2013 at 9:19pm
 
I forgot to mention to click "Cancel" when prompted. The teensy alpha is more recent than the published upgrade. If you click cancel then the prompt will not appear again until either the version you are using changes or the published version changes.

I expect a new release within a week which will replace both the current release and the version you are running. When the next release is published you will genuinely be prompted to upgrade.

T
Back to top
 

WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print