VS Arduino | |
Visual Micro >> Project Guidance >> Compiling a Arduino app with compiler switches and not linking to core libraries
https://www.visualmicro.com/forums/YaBB.pl?num=1366154203 Message started by Gregory on Apr 16th, 2013 at 11:16pm |
Title: Compiling a Arduino app with compiler switches and not linking to core libraries Post by Gregory on Apr 16th, 2013 at 11:16pm
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... |
Title: Re: Compiling a Arduino app with compiler switches and not linking to core libraries Post by Gregory on Apr 16th, 2013 at 11:19pm
Output example from Visual Micro (version 12.30)
Quote:
|
Title: Re: Compiling a Arduino app with compiler switches and not linking to core libraries Post by Gregory on Apr 17th, 2013 at 2:21am
HAL Output example from modified arduino ide
Quote:
|
Title: Re: Compiling a Arduino app with compiler switches and not linking to core libraries Post by Visual Micro on Apr 19th, 2013 at 3: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 |
Title: Re: Compiling a Arduino app with compiler switches and not linking to core libraries Post by Visual Micro on Apr 19th, 2013 at 4: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 |
Title: Re: Compiling a Arduino app with compiler switches and not linking to core libraries Post by Gregory on Apr 21st, 2013 at 11:59am
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. |
Title: Re: Compiling a Arduino app with compiler switches and not linking to core libraries Post by Gregory on Apr 22nd, 2013 at 5: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 |
Title: Re: Compiling a Arduino app with compiler switches and not linking to core libraries Post by Visual Micro on Apr 22nd, 2013 at 8: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 |
VS Arduino » Powered by YaBB 2.6.12! YaBB Forum Software © 2000-2025. All Rights Reserved. |