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
Arduino-style projects with other Toolchains (Read 17328 times)
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Arduino-style projects with other Toolchains
Apr 21st, 2013 at 1:13pm
 
Related to my other post: http://www.visualmicro.com/forums/YaBB.pl?num=1366154203

In the project I am working with, we compile in the Arduino/Processing style, but we have different toolchains, not just Arduino.
So, while we may compile using the arduino compilers for our 2560 target (HAL_BOARD_APM2), there is also a GCC x86 compile (HAL_BOARD_SITL) and a ARM one (HAL_BOARD_PX4).    The SITL uses the standard GCC, and the Px4 uses an ARM compiler, specifically this one: https://launchpad.net/gcc-arm-embedded/+download

In all cases, we use the Arduino/Processing "style" of build (include paths of headers, combine all PDE files into one, etc.), only the toolchain differs.   The MAKE files for these other platforms actually replicate the Arduino style.
So I am wondering and very helpful: would it be possible to use VM to use these other toolchains in the same way it uses the arduino one?   I think/hope that nothing more would be needed than pointing to the different toolchain executables, but, of course, things are not always so simple.  But if it is, then we would have the ultimate cross-platform environment here.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino-style projects with other Toolchains
Reply #1 - Apr 21st, 2013 at 2:18pm
 
Hi,

We have a version under development that allows toolchains and build processes to be registered.

However you might be able to use some of what is already there

1)
You can set a different avr toolchain in Tools>options however the program names such as avr-gcc need to remain the same

2)
The boards.txt def supports specifying different toolchain exe names which is how we build teensy 3.0 for ARM. To cut a long story short, you specify the exe names and vm passes all the standard arguments as if it was using avr. This sounds like it will do as you describe.

Here is an example of the boards properties you can set:-

Code:
teensy3.upload.avrdude_wrapper=teensy_reboot
teensy3.build.mcu=mk20dx128
teensy3.build.cpu=cortex-m4
teensy3.build.option1=-mthumb
teensy3.build.option2=-nostdlib
teensy3.build.option3=-D__MK20DX128__
teensy3.build.cppoption1=-fno-rtti
teensy3.build.linkoption1=-mthumb
teensy3.build.linkscript=mk20dx128.ld
teensy3.build.architecture=arm-none-eabi
teensy3.build.command.gcc=arm-none-eabi-gcc
teensy3.build.command.g++=arm-none-eabi-g++
teensy3.build.command.ar=arm-none-eabi-ar
teensy3.build.command.objcopy=arm-none-eabi-objcopy
teensy3.build.command.objdump=arm-none-eabi-objdump
teensy3.build.command.size=arm-none-eabi-size
teensy3.build.core=teensy3
teensy3.build.noarchive=true
teensy3.build.elide_constructors=true
teensy3.build.gnu0x=true
teensy3.build.dependency=true
teensy3.build.time_t=true
#teensy3.build.linker_relaxation=true
teensy3.build.post_compile_script=teensy_post_compile
 



Note that the "build.architecture" property specified the name of a folder that exists below the "ArduinoIDE\Hardware\Tools" folder.

Normally an Arduino Ide would simply use the exe programs from "ArduinoIDE\Hardware\Tools\Avr", however Teensy3 has its own toolchain architecture specified in "build.architecture=arm-none-eabi". This forces the compiler to use the core from "ArduinoIDE\Hardware\Tools\arm-none-eabi" instead of "ArduinoIDE\Hardware\Tools\avr"

After you have set the architecture of a board to a different toolchain all you then need to do is to specify the names of the programs that are run at various compile/upload stages as follows:-.

Code:
apm2halARM.build.architecture=arm-none-eabi
apm2halARM.build.command.gcc=arm-none-eabi-gcc
apm2halARM.build.command.g++=arm-none-eabi-g++
apm2halARM.build.command.ar=arm-none-eabi-ar
apm2halARM.build.command.objcopy=arm-none-eabi-objcopy
apm2halARM.build.command.objdump=arm-none-eabi-objdump
apm2halARM.build.command.size=arm-none-eabi-size
 



The uploader can also be mapped to a different exe name:-

Code:
apm2halARM.upload.avrdude_wrapper= 



Finally you have additional properties that enable you to include .ld scripts and other stuff if required.

So in summary, hopefully you just need to add a "Tools>myArmXyz" to the ide/hardware folder and make a new boards.txt entry in "sketchbook\hardware\myHalCore"

Does all this make sense?
Back to top
 
WWW  
IP Logged
 
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Re: Arduino-style projects with other Toolchains
Reply #2 - Apr 21st, 2013 at 2:27pm
 
It does make sense, and it is what I hoped; you've developed a pretty open architecture.

I can and and will try these steps to see if I can get a ARM build.

Really the only non-optimal thing is to have to change the path to the toolchain in Tools->Options.  Am sure in your next version, its a dropdown.

When do you think there will be an alpha of your new version that supports the registration of toolchains?  Would love to alpha/beta that.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino-style projects with other Toolchains
Reply #3 - Apr 21st, 2013 at 2:39pm
 
Oh yes, I forgot to put a folder picker on the "AVR Toolchain" property. Will do for the release over the next 7 days. Interested to hear how you get on with this in the current version. If you have problems tell me where to download the arm stuff.

The new ide architecture should be available over the next couple of months. The intention is to prove it by supporting "arduino 1.0.x, arduino 1.5 and TI Launchpad" with it (out of the box).

There are some other features in the version due in the next week that might help. Example: The sketchbook path can optionally be set in Visual Studio, which means that we never have to open the arduino ide.

Changes to the sketchbook path in Visual Studio take immediate affect causing the boards, libraries lists, intellisense etc. to instantly reflect the change. This avoids the need to re-start the ide after changing this property which makes it easier for new users. Hopefully new users just need to install, set the paths, select the board, open APMrover (if not already open) and click compile  Smiley
Back to top
 
WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino-style projects with other Toolchains
Reply #4 - Apr 21st, 2013 at 11:02pm
 
One point worth considering..

I don't think setting the toolchain path is the best all round solution. If we own both an apm and a PX4 then this option becomes cumbersome when switching projects.

The best solution would be to add an "APM PX4" board to the boards list setting the architecture name to PX4, then creating an "arduinoide\hadware\Tools\PX4" folder to contain the toolchain.

If you go down this route I can add the ability store toolchains under the "sketchbook/hardware/tools" folder instead of with the ide.

This would mean the toolchain can switch when the board is switched, much easier for users than setting a toolchain location.

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



Posts: 18
Re: Arduino-style projects with other Toolchains
Reply #5 - Apr 22nd, 2013 at 2:28am
 
I think that is fine;  In every case, PX4, APM are their own boards, so this makes sense as the way to do it.  Setting a tool chain specific to a board makes the most sense.

The only odd target would be the SITL (Software In The Loop) where we compile an ELF and run for the OS we are testing on.  That uses a GCC compiler for the OS, but we can just pretend that's a board and call it BOARD_SITL.

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



Posts: 10395
United Kingdom
Re: Arduino-style projects with other Toolchains
Reply #6 - Apr 22nd, 2013 at 1:28pm
 
Makes sense
Back to top
 
WWW  
IP Logged
 
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Re: Arduino-style projects with other Toolchains
Reply #7 - Apr 22nd, 2013 at 8:32pm
 
Am trying the suggestion:

"The best solution would be to add an "APM PX4" board to the boards list setting the architecture name to PX4, then creating an "arduinoide\hadware\Tools\PX4" folder to contain the toolchain. "

The first thing I am doing is SITL, which is just a GCC for the OS, uses x86 gcc compilers (cygwin) to create an ELF file.

I am getting an error, "Unable to determine a Tools/ARchitecture location for this board".

I have this as my board description (I know that some of these params make no sense, but I am trying at a high level to just see if I can get the system to use the gcc compilers under the ide\tools\SITL directory):

SITL.name=SITL

SITL.upload.protocol=wiring
SITL.upload.maximum_size=258048
SITL.upload.speed=115200
SITL.bootloader.low_fuses=0xFF
SITL.bootloader.high_fuses=0xD8
SITL.bootloader.extended_fuses=0xFD
SITL.bootloader.path=stk500v2
SITL.bootloader.file=stk500boot_v2_mega2560.hex
SITL.bootloader.unlock_bits=0x3F
SITL.bootloader.lock_bits=0x0F
SITL.build.mcu=x686
SITL.build.f_cpu=x686
SITL.build.architecture=SITL
SITL.build.core=SITL
SITL.build.option1=-mcall-prologues
SITL.build.option2=-DCONFIG_HAL_BOARD=HAL_BOARD_SITL
SITL.build.option3=-DEXCLUDECORE
SITL.build.noarchive=true
SITL.build.command.gcc=gcc
SITL.build.command.g++=g++

What in here am I missing?  The exe's are gcc and g++ and they are in the ide\tools\SITL directory.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino-style projects with other Toolchains
Reply #8 - Apr 22nd, 2013 at 9:15pm
 
Hi,

I've altered the next build to include a folder location hint in the error message Smiley

Some things that I hope help...

Based on your config the plugin is looking in "[arduino ide]\hardware\tools\SITL\bin" instead of "arduino\hardware\tools\avr\bin"

I also see you have opted to override the tool executable names, I assume you have a file called g++.exe which you have specified instead of avr-g++.exe?
Back to top
 
WWW  
IP Logged
 
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Re: Arduino-style projects with other Toolchains
Reply #9 - Apr 22nd, 2013 at 9:25pm
 
Yes, there is a file called g++ and gcc.   What I did not realize is that it is sitl/bin and not just sitl/.   So let me put the build stuff in there and see what I get.

Also, I assume that

sitl.option1=EXCLUDE_CORE
sitl.option2=HAL_BOARD=SOMETHING
sitl.option3=...

There can be as many options as are needed?  it is just, option[n]= ?
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino-style projects with other Toolchains
Reply #10 - Apr 22nd, 2013 at 9:30pm
 
Yes an unlimited number of defines.

It is teensy syntax design, I'll add support for some other things that will help. There is no reason why we don't have settings such as:-

.extra.defines=

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



Posts: 18
Re: Arduino-style projects with other Toolchains
Reply #11 - Apr 22nd, 2013 at 9:41pm
 
ok, progress.  We are using the right tools now...

But we are trying to compile a non-existant file...

It can't seem to find the pde files.  Any idea where it is looking?  Nothing has changed from our successful APM2 location wrt. pde files and locations.

See below:

Compiling 'APMrover2' for 'SITL'
Build folder: file://C:\Users\Greg Brill\AppData\Local\VMicro\Arduino\Builds\APMrover2\SITL
SketchLibFolders
Summary: Header=1 Prototypes=167 Imports=42
Additional Defines: VISUALMICRO_COMPILER_VER=1;
Architecture Tools: C:\arduino\hardware\tools\SITL\bin\
C:\arduino\hardware\tools\SITL\bin\g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=x686 -DF_CPU=x686 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=101  -mcall-prologues  -DVISUALMICRO_COMPILER_VER=1 -I"C:\ardupilot\hardware\apm\cores\SITL" -I"C:\ardupilot\libraries\AP_Common" -I"C:\ardupilot\libraries\AP_Progmem" -I"C:\ardupilot\libraries\AP_HAL" -I"C:\ardupilot\libraries\AP_Menu" -I"C:\ardupilot\libraries\AP_Param" -I"C:\ardupilot\libraries\AP_GPS" -I"C:\ardupilot\libraries\AP_ADC" -I"C:\ardupilot\libraries\AP_ADC_AnalogSource" -I"C:\ardupilot\libraries\AP_Baro" -I"C:\ardupilot\libraries\AP_Compass" -I"C:\ardupilot\libraries\AP_Math" -I"C:\ardupilot\libraries\AP_InertialSensor" -I"C:\ardupilot\libraries\AP_AHRS" -I"C:\ardupilot\libraries\PID" -I"C:\ardupilot\libraries\RC_Channel" -I"C:\ardupilot\libraries\AP_RangeFinder" -I"C:\ardupilot\libraries\Filter" -I"C:\ardupilot\libraries\AP_Buffer" -I"C:\ardupilot\libraries\AP_Relay" -I"C:\ardupilot\libraries\AP_Mount" -I"C:\ardupilot\libraries\GCS_MAVLink" -I"C:\ardupilot\libraries\AP_Airspeed" -I"C:\ardupilot\libraries\memcheck" -I"C:\ardupilot\libraries\DataFlash" -I"C:\ardupilot\libraries\SITL" -I"C:\ardupilot\libraries\AP_HAL_AVR" -I"C:\ardupilot\libraries\AP_HAL_AVR_SITL" -I"C:\ardupilot\libraries\AP_HAL_PX4" -I"C:\ardupilot\libraries\AP_HAL_Empty" -I"C:\ardupilot\libraries\AP_Declination" "C:\Users\Greg Brill\AppData\Local\VMicro\Arduino\Builds\APMrover2\SITL\APMrover2.cpp" -o "C:\Users\Greg Brill\AppData\Local\VMicro\Arduino\Builds\APMrover2\SITL\APMrover2.cpp.o"
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino-style projects with other Toolchains
Reply #12 - Apr 22nd, 2013 at 9:57pm
 
Hi Greg,

The APMrover2.cpp does exist but in the temp build folder. This is how an arduino compile happens, all of the .pde files are combined into [sketchname].cpp in the temp folder.

fyi: It is the .cpp that is actually compiled and explains why we can declare variables/methods in one .pde (without making them public/external) yet reference them in another .pde.

I think the exception is because it can't find g++.exe or that we are missing something that is passed to g++.exe

If you think we are missing a setting for g++.exe then you can use the following exe to see what another program does when it calls g++.exe

http://www.visualmicro.com/downloads/vm_exe_args_explorer.zip

The zip contains an exe that does nothing other than pop up a box showing the arguments that were passed to it when called.

Use it as follows:-

Rename the g++.exe in the original location that is used by a compiler that works.
Copy the .exe in the zip above to the same location as the renamed g++.exe
Rename the exe from the zip to g++.exe
Run a compile using the compiler that calls g++ correctly

Result

The program that normally compiles okay will raise a dialog with the arguments passed to g++.exe then the compile will fail. At which point you might want to rename the original g++.exe back again Cheesy
Back to top
« Last Edit: Apr 22nd, 2013 at 10:31pm by Visual Micro »  
WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino-style projects with other Toolchains
Reply #13 - Apr 22nd, 2013 at 10:08pm
 
ps: Remember that the option[n]=define= don't work so well in your version so it's best to use the project level defines. You don't need both and might save some test time without the boards properties.
Back to top
 
WWW  
IP Logged
 
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Re: Arduino-style projects with other Toolchains
Reply #14 - Apr 22nd, 2013 at 10:24pm
 
I can just run the make files and see what is being passed to g++ by looking at the output.

But we are sure it is finding the .cpp?  Could this error be the result of an unrecognized parameter?  Because there are a ton of parameters it would not recognize...but it is saying "can't find the file" so that is the puzzling thing.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino-style projects with other Toolchains
Reply #15 - Apr 22nd, 2013 at 10:29pm
 
Doh! good point about the makefiles.

Generally I would expect the cpp to be there because it is created before everything starts during the pre-build and all arduino compiles need it.

Based on your earlier report it should exist in this folder:-

Code:
C:\Users\Greg Brill\AppData\Local\VMicro\Arduino\Builds\APMrover2\SITL 



If you often want to inspect the temp build folder you can switch on "Tools>Compiler>Always show build path". This gives a hyperlink to the folder in the build output each time you build. CTRL+Click to open the folder.

ps: i got confused earlier when i said I should split this post. thanks for making this a new post. great to keep things clean!
Back to top
« Last Edit: Apr 22nd, 2013 at 10:33pm by Visual Micro »  
WWW  
IP Logged
 
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Re: Arduino-style projects with other Toolchains
Reply #16 - Apr 23rd, 2013 at 8:15pm
 
ok, I have looked at the output of the make file (thank you 'remake' make fork for the debugging info).  What we have for command options are:

{
1: '-g',
2: '-D_GNU_SOURCE',
3: '-DF_CPU=',
4: '-DSKETCH="APMrover2"',
5: '',
6: '',
7: '-DCONFIG_HAL_BOARD=HAL_BOARD_AVR_SITL',
8: '-Wa,-adhlns=/tmp/APMrover2.build/APMrover2.lst',
9: '-O0',
10: '-g',
11: '-Wformat',
12: '-Wall',
13: '-Wshadow',
14: '-Wpointer-arith',
15: '-Wcast-align',
16: '-Wwrite-strings',
17: '-Wformat=2',
18: '-Wno-reorder',
19: '-MD',
20: '-MT',
21: '/tmp/APMrover2.build/APMrover2.o',
22: '-ffunction-sections',
23: '-fdata-sections',
24: '-fno-exceptions',
25: '-fsigned-char',
26: '-c',
27: '-o',
28: '/tmp/APMrover2.build/APMrover2.o'

But we'll have difficulty putting some of these in option[n]= values. 

Trouble is, 8 and 21.  Here we have generated strings who's values need to reflect the name of the file being compiled.  Any way we can accomplish this?  I don't suppose you have any $(TARGET) type global vars or anything....this may be a show stopper?
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10395
United Kingdom
Re: Arduino-style projects with other Toolchains
Reply #17 - Apr 23rd, 2013 at 8:58pm
 
Yes I've been looking at it but it is useful to see these things clearly in your post thanks. It also requires some standard options being ommitted

It would be easy to add some extra items such as $TARGET but I want to re-look at what arduino 1.5 does. It has a flexible recipe system that allows these things to be specified in the way we need. There is no reason why we don't adopt similar syntax but using our own board properties. I think this will be more widely accepted.

Having said that if it's easy to add some quick fixes I will. Where can I download all the source for this?
Back to top
« Last Edit: Apr 23rd, 2013 at 8:59pm by Visual Micro »  
WWW  
IP Logged
 
Gregory
Junior Member
Developer
**
Offline



Posts: 18
Re: Arduino-style projects with other Toolchains
Reply #18 - Apr 23rd, 2013 at 9:06pm
 
The source project is at:

https://github.com/diydrones/ardupilot.git

All our stuff is here: https://github.com/diydrones.git

To compile, just go into APMrover2, and:
make configure
make sitl

or

make APM2

But in the latter case you need the arduino environ installed and in your configure.mk file.

I like "remake" clone of make, because with the -n option, you can see all the commands the make file will try to issue. Helps you see exactly what is going on.
Back to top
« Last Edit: Apr 24th, 2013 at 2:02pm by Gregory »  
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print