Go Down

Topic: Arduino Eclipse Plugin <Update> (Read 73286 times) previous topic - next topic

Trump211

Aug 26, 2011, 07:15 pm Last Edit: Oct 02, 2011, 06:16 pm by Trump211 Reason: 1
I really like the eclipse IDE's abilities as a program editor,  It has many features features that the Arduino IDE does not (function browser,  navigator, etc).  However it is missing one very important feature!!  It cant build straight arduino projects without complicated makefiles, and the AVR Plugin which further requires one to make a full install of AVR GCC. 

So, I decided to make a plugin for eclipse that would add this ability.
The source to the plugin as well as a more in depth readme can be found at https://github.com/Trump211/ArduinoEclipsePlugin

I have tested this with the bare minimum code, as well as the sketches that use various arduino libraries. All that I have tested compile completely and to the same size as the arduino ide compiles them to.  It even works with complex sketches like Multi_Wii (http://code.google.com/p/multiwii/source/browse/#svn%2Ftags).

Is anyone interested in something like this, or does anyone have any suggestions?


Abilities:
Create new projects that are 100% compatible with the Arduino environment,
Build the projects to a bin directory within the project folder (none of that temporary folder crap).
Only rebuilds the core.a file if it is not already present (still have option to clean)
Users can also set extra settings like the optimization level for the compiler.
Predefined boards are read from arduino's boards.txt file
Update: Compile and project settings are now saved between sessions
Update: Settings on new project default to settings used on last project (don't have to re find everything)
Update2: Code highlighting for arduino keywords, comments, and preprocessors.
Update2 Upload to arduino (using bootloader only)(windows 64 bit only)

Future Abilities:
-Code completion in pde files
-Highlighting of library keywords

Bugs:
-For now the only way to edit settings after the project is created, or to upload the correct project is to only have one arduino project in the workspace.  Eventually i will allow the user to choose which project in a pop-up, but for now it is just the first project listed that has the arduinoProject nature.






RobertBerger

Hi,


Update2 Upload to arduino (using bootloader only)(windows 64 bit only)


Why shouldn't this work on Linux as well?

Regards,

Robert

--
Robert Berger
Embedded Software Specialist

Reliable Embedded Systems
Consulting Training Engineering
URL: http://www.reliableembeddedsy

Jantje

Hi Trump211
I have been doing the same thing for a while; based on the AVR plugin. I have the same arguments like you to prefer eclipse to the IDE for experienced developers or big projects.
I'm not bothered by having to install the avr dude (it is installed as part of the arduino IDE as well, you know)
I'm more concerned with setting the compile and upload options correctly to create a environment that is ready to play as quick as possible.
My current environment allows me to have multiple projects in the same eclipse environment. I do this by having the core Arduino source code as a separate project. I'm not experienced in writing eclipse plugins so I'm seriously fighting that more than Arduino.


My main technical problems right now are:
How can I create a page to request the arduino path (so I can link in the arduino source code)
How can I copy/link the arduino code
What are the exact AVR setting: As far as I understand I need the upload baut rate and the pic clock speed and pic type. for the Arduino duemilanova with ATMEGA328 that is 57600; 1000000; ATMEGA328P. But what is it for the others?

Questions I have as well are:
Is the IDE always using the same compile options? (It took me a long time to find the correct options and get them correctly set in Eclipse)
Why is the IDE using the define ARDUINO=22 (I find no references to this define in the code) Will this define change in the future?

I'll have a good look at your source code. Maybe it is a good idea to join forces on this one. Anyone else wants to join in?

Jantje

PS
You should be carefull with your class path.

PSS
Following are the IDE supported platforms for which I need bautrates; cpu types and cpu speeds
Arduino duemilanova with ATMEGA328
Arduino nano with ATMEGA328
Arduino Mega 2560
Arduino Mega ATMEGA1280
Arduino Uno
Arduino LilyPad with ATMEGA328
Arduino Fio
Arduino Pro with ATMEGA328
Arduino BT with ATMEGA328
Arduino Mini
Arduino Pro Mini with ATMEGA328

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

kiwidude

The Arduino IDE is superbly good for getting going fast when starting at nothing. After a while it becomes a drag and you start looking for something better. My enthusiasm for eclipse has been dampened somewhat by the bugs in AVR/CDT plugins and the exorbitant time needed to get anything working. Instructions are notably absent. A professional system has debugging capabilities too - something Arduino doesn't even bother with. I worked out it must be possible, but it's a loooong way. Not good. Pretty bloody *&*&!*@($#@ actually.

As for the plugin suggested here my comments are:

1) A default or optional and -easy-to-load configuration compatible with the Arduino IDE would be very useful. It helps transition and allows to move existing projects forward.

2) Modify and improve the existing AVR plugin instead. It's not well supported currently (at least it still works - the ARM plugin is just 100% bitrot, doesn't even produce any output and screws up the whole eclipse). It's also a long way there already.

3) I have absolutely no time for crap that only works on Mickeysoft. I find it hard to believe someone could be stupid enough to castrate eclipse that way.

4) So you program a new plugin just because installing the Arduino IDE is asking too much? Hello? The IDE itself is not much of the total, you still need the compiler suite, the Arduino core software and the Arduino libraries. Installing the IDE is extremely trivial - download, unpack in convenient directory, add bin directory to $PATH. Dito eclipse. Couldn't be easier. For comparison, the PIC32 people did a nice job with adding the PIC32 stuff and keeping the AVR stuff going - except they stuffed it up and it doesn't work, but at least they tried. Probably an easy fix. The two should be merged permanently, except that Microchip has obnoxious licenses in their libc of gcc. The ARM maple Arduino IDE is just somewhere between braindead and incompetent (as well as years out of date).

Trump211

#4
Oct 30, 2011, 05:41 pm Last Edit: Oct 30, 2011, 06:04 pm by Trump211 Reason: 1
Sorry Guys, I thought I'd get an email or something if anyone posted on this thread...

Anyways:
@RobertBerger and kiwidude
--The reason I said uploading was for Windows 64 bit only was because at the time I hadn't added the native libraries for RXTX.  I believe that It should work now for most OS's, unless there is a different file structure for the Arduino install.  I don't have access to any computers other than my PC to test this on

@Jantje:
- To create a page requesting for the arduino path take a look at ArduinoSettingsPageLayout.java... the draw function adds a field for this in the Environment options part of the code
- For the AVR settings go to your arduino install folder and navigate to arduino-0022\hardware\arduino  all the settings are listed in boards.txt
- I'm not quite sure what you mean by copy and link the arduino code, but if you mean how do you compile the users code with the arduino libraries, you must send the correct commands to the avr-gcc compiler and linker to see code that does this look at Compiler.java note that this expects the the .pde files to have already been preprocessed into a large cpp file locoted in the build folder.  Arduino does this behind the scenes in the temp build folder
-The arduino IDE does use the same compile options every time.  The only commands that change are the f_cpu=<cpu frequency> and the MCU=<mcu type> these are both selected depending on what board you have selected in settings.   (again you can look at this in the compile.java
-The official arduino ide uses the Arduino=22, I assume so that its possible to find what version of Arduino the program was built with, other than that I honestly have no Idea.  In the eclipse plugin I completly removed that command and everything still compiles and works corrctly (same size and everything)
     - In the plugin I also added the ability to choose the optimization option

-I think joining forces would be a good idea on this

@ kiwidude
1) this has already been implemented, The user is able to choose any board the arduino environment recognizes, and the rest is filled out automatically.  Or the user can choose a custom board and specify each option (MCU, frequency, etc)

2)I started out doing this, but in the end I decided against it mainly because I don't really understand how makefiles work nor how to write them etc.  I thought it would be easier just to look at the arduino IDE source and modify it to work with eclipse IDE.

3)See above, I belive it will work for other OS's now, but I don't have any way to test this.

4)No, I made a new plugin because I think the arduino IDE is very limited and I would like to develop something that is more customizable for advanced users, and easy to use for the beginers.  For this plugin to even work, the arduino Ide must be installed, because it uses the arduino's avr-gcc as well as the core sources, and the boards.txt.

Sorry it took so long to respond again.

kiwidude

Trump211,

Thanks. The rxtx is only used for two things really by the Arduino IDE as far as I am aware: reset the target before upload, and the terminal window. The upload is handled by avrdude, eclipse will need to do the same. Use the correct option with avrdude and it'll do the reset, and don't bother with the terminal in eclipse, at least for starters.

Makefiles are not optional if you want to be professional. I understand they're generated by the eclipse CDT plugin, you only have to set a few variables there that specify the compiler, linker, paths etc., but I may be wrong. In any case the AVR and CDT plugins create them, you'd just need to copy that.

Your reason for creating another AVR plugin makes no sense.

Jantje

Hi Trump
Thanks for the input. I had already figured most of that out given your source code. (I also wasn't aware you are not updated on new messages on this forum :smiley-fat:
I tried your plugin but it didn't work for me. I found that the natures were not set. I'm not sure what is wrong here.
I have successfully created a plugin that is working on my "development machine". I'm working on a update site right now to be able to test on other locations.
I used some of your code  :D
With the copy or link I'm referring to eclipse being able to copy code into the workspace or to link to the code somewhere on your system. I have by now concluded that having a project with the Arduino code (on for each used MCU) linking to the code in the IDE install is the best way to do it.
I do not agree that the IDE uses the same options all the time. The C code has other options than the C++.   I think it wouldn't hurt to use  -fno-exceptions in C compile but it is a difference. Also the Arduino code is compiled as a library and then linked in. You have to do it this way ore the size of your sketch will be to big (no optimization of global variables)
As to installing WinAVR: As I mentioned before the IDE already contains WinAVR. I have just modified the Arduino playground eclipse page to explain how you can use the WinAVR included in the IDE. That is another step towards using avr-eclipse  :smiley-roll-sweat:
As to joining forces: I still think this is the best way forward. I'm however unsure on how to do it given the different architectural approach.
Best regards
Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Jantje

All
I released my first version of the Arduino eclipse plugin. You can install it on the install site http://www.baeyens.it/eclipse/update site/
It currently supports following actions:
Creation of an Arduino sketch
Change the Arduino board
Change the com port

You can use this plugin without installing avr-eclipse and win avr. Basically avr-eclipse is in the plugin and I use win avr installed with the IDE.
To get it to work:
Install the arduino IDE
Install eclipse (indigo or any other with the C/C++ feature)
install the plugin from my update site (Help ->install new software)
Configure the plugin (windows -> preferences)
first fill in arduino->paths with references to the IDE folders

The tell avrdude to take the ide config

Following setting are not needed but advised:
Set the auto save before build on to avoid different version between uploaded and visible code.

Disable the heuristic something for includes (sometimes this setting makes the gui not to find defines)


Now you can create a new Arduino project with the plugin
Do file -> new -> project
Select the Arduino sketch and then next


Provide a name for the sketch and press next (note that in the image below the finish is enabled because I already created a sketch)


Provide the arduino information and select finish (note that all this information will be stored so you will not need to reenter when you create a new sketch)


Now the plugin will create 2 projects. one for the arduino library and one for the sketch. The image below holds more projects but the new ones are highlighted.

In the image above I opened the my sketch.cpp file.
Pressing the hammer (marked in the image above) will compile the project.
Pressing the AVR button (marked above) will upload the project to your arduino board.

To change the board or com port right click on the project and select properties
you get the same dialog box where you can change the board and  com port.

After you pressed finish you get a new arduino core project for the mcu if needed.


As this is the first release it has only been quickly tested on windows xp and windows 7. I noticed that sometimes some eclipse restarts are needed before it works all fine.
Please feel free to download, test and comment.

Best regards
Jantje

PS
Things to come
Insert Library
Select com port via combo in gui



Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Trump211

Hey Jantje,
Loooked really Quick at your plugin.  It looks really good so far.  I have a couple questions/suggestions. 

-Where in the filesystem is the output? (.hex, .epp etc)
-What is your reasoning for importing the core arduino files into a new project for each board type used. 
      You can give the compiler the paths of the core files so that it can make the correct output files. That way each project will have its own core.a
      Nevermind, I'm assuming your doing this because the thought is people will have multiple proojects for the same board type, and because they all use the same core.a, they can just share the one?
-I assume that the project is no longer compatible with the arduino IDE?  (wrong file extension etc)  If not, how can you import into the arduino ide.

Suggestions:
- I think that Having a custom board option would be neat.  aka running a mega at a different frequency etc.
- Once you have the arduino install location from the new project wizard, the plugin should be able to set the AVRDude paths and other settings correctly.

Will you be releasing the source? If so do have a repository with the source anywhere? I'd really like to see how you implemented some of these things.

Awesome work Again
-Trump211





Jantje

Trump
Thanks

-Where in the filesystem is the output? (.hex, .epp etc)
The output files are located in a subfolder of the project wit the configuration name. It however only appears after the compile has been executed. This is the standard C/C++ eclipse indigo behavior.

-What is your reasoning for importing the core Arduino files into a new project for each board type used. 
There is a long history on the core with the MCU extension. I'm happy you asked it.
I started with a library called arduino_core. That worked fine until I had 2 boards with a different MCU.
So I changed the approach to adding the Arduino code to the source code. I already shouted I'm done to notice that the sketch size was far bigger than the Arduino IDE. This is cause by the fact that the linker can not remove unused global variables when directly linked in.
So I went to arduino_<MCU_name> this worked great because avr_eclipse changes the environment variable MCU_name and you can use environment variables to reference folders. So I only had to create the arduino core project and the references are immediately change.
Later on I realized that it is possible to use the configuration to only have one arduino_core for all configurations (avr_eclipse allows multiple configurations)
When I looked at how to do it I failed to do this with environment variables and the change implied some code tat I didn't feel like doing so I consider the current solution good enough. But this is on the list of improvements.
Note that a similar problem exists with the programmer. I have only one board type so i couldn't test this but I think that if you have 2 board with a different upload frequency there will be a little bug.

-I assume that the project is no longer compatible with the Arduino IDE?  (wrong file extension etc)  If not, how can you import into the arduino ide.
You know I asked you to work together. This is one of the things I was thinking of :-)
Basically the IDE can handle pde files. a pde file is a standard c/c++ file but the ide makes that you can relax the C C++ language constraints.
For instance you do not have to declare functions before you can use them. If we add in the toolchain a pde to C++ tool before the C++ compiler we can have Arduino IDE compatibility.

- I think that Having a custom board option would be neat.  aka running a mega at a different frequency etc.
Basically I only put a layer on avr-eclipse and the C/C++ cdt. The create "new Arduino sketch wizard" just sets all the options correctly. The property page allows to change some properties and only changes those. In the Arduino property page you see the all the properties (how they are set when you open it, and how they will be set after you changed the board type) except for the programmer that is used (look at project properties-> arduino->avrdude->programmer tab  to understand what I mean; click edit for better understanding.
I'm not sure what it would be good for but avr eclipse supports this. I consider this advanced usage and I would advice advanced users who want to do this to use the avr-eclipse functionality directly or by using the Arduino-eclipse plugin.

- Once you have the Arduino install location from the new project wizard, the plugin should be able to set the AVRDude paths and other settings correctly.
I fully agree. This should be a preference page with a option like "use Arduino IDE for avrDude and GNU compiler"

-Will you be releasing the source?
I worked on that yesterday all day. Never worked with Git nor github but I succeeded in uploading. Please feel free to join in. I know you have the code to make a combo box to select the com port on windows. Not sure what the consequences are from adding this code for linux users and that is why I didn't use it. The code is at : https://github.com/jantje/arduino-eclipse-plugin
I'm currently working on a library import function. This should import the code in the main folder and add a include and source reference.

Best regards
Jan
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Trump211

Thanks Jan,
I cloned a copy of the repository to my local drive to take a look around.  I've been trying to find functions in the AVR-Eclipse plugin source to be able to set the path variables.  However, all I can find are functions to set the paths to the defaults (given in the registry if avr tool-chain is installed separately) 

-Also, when I try to build any projects that I make with the plugin I get an error
Code: [Select]

**** Build of configuration Release for project arduino_atmega328p ****
make all
Error: Cannot run program "make" (in directory "<Workspace>\arduino_atmega328p\Release"): CreateProcess error=2, The system cannot find the file specified
**** Build Finished ****

It seems like it either can't find the GNUMake, or it can't find the makefile.

Jantje

Trump
I have not seen this error before.
From how I understand the error message eclipse is looking for make in your release folder.
Have you checked the GNU path settings? in window-> preferences?

Have you restarted eclipse?

Jantje
Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Trump211

#12
Nov 08, 2011, 06:42 pm Last Edit: Nov 08, 2011, 08:29 pm by Trump211 Reason: 1
Jan,
I've checked the path settings and all are correct.  I also tried adding the paths to my system PATH setting to see if that would do anything, but i get the same results.  If i try to build the plugin myself,  get a few warnings for the managed builder that "an API baseline has not been set for the current workspace".

EDIT:
If I manually run the command make in the release directory I get the following output
Code: [Select]

C:\Users\Dan\Workspaces\CPPEclipse\ArduinoAvr\MyProject\Release>c:\users\dan\applications\arduino-00
22\hardware\tools\avr\utils\bin\make
'Building file: ../MyProject.cpp'
'Invoking: AVR C++ Compiler'
avr-g++ -I"C:\Users\Dan\Applications\arduino-0022\hardware\arduino\cores\arduino" -I"C:\Users\Dan\Workspaces\CPPEclipse\ArduinoAvr\MyProject" -D__IN_ECLIPSE__=1 -DARDUINO=22 -Wall -Os -ffunction-sections -fdata-sections -fno-exceptions -g -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"MyProject.d" -MT"MyProject.d" -c -o "MyProject.o" "../MyProject.cpp"
'avr-g++' is not recognized as an internal or external command,operable program or batch file.
make: *** [MyProject.o] Error 1


which makes me think that it is an error in the makefile.  as if it is calling avr-g++ rather than <pathToAvrG++>/avr-g++

EDIT2:
This exactly the case.  I went in and manually edited the Makefile to so that "avr-g++" now reads "<arduino dir>\hardware\tools\avr\utils\bin\avr-g++" and it now gets past that part.  However, when it gets to the next step (calling the linker) it has a problem finding the core project.
It seems like the makefile is being incorrectly (the tools are called, but the path to the tools are never given).  I have the paths set within the plugin, so the only thing i can think of as to why it builds on your system and not on mine is that you have your system PATH set up so that it either points to the arduino tools, or a separate install of the tool-chain (and when you build it isn't using the arduino provided tools, but the separately installed tool-chains)?

Jantje

Trump
I'm sure I use the Arduino IDE makefile. As far as I know I have no other makefiles or toolchain stuff on my systems (2 to be precise). I just tested it this way: Renamed "makefile.exe" to "weg makefile.exe" and ran the clean command
The result is:
Quote
**** Clean-only build of configuration Release for project blink2 ****

make clean

Cannot run program "make": Launching failed
Error: Program "make" is not found in PATH

PATH=[C:\arduino-0022\arduino-0022\hardware\tools\avr\bin;C:\arduino-0022\arduino-0022\hardware\tools\avr\utils\bin; ..<my PATH environment variable content is here>...]

**** Build Finished ****

It is another error than you get.
You see that the path has been extended by the tool to contain the folders provided with the settings.
You can try the same rename trick to find out which makefile is being used and how it is called.
Have you both avreclipse and Arduino eclipse installed? I ask because this setup is not supported/tested. avreclipse is included in the arduino eclipse but in a modified version using different names/locations/.... It is very likely there will be conflicts
Can you also open the error view and look for clues what is going wrong? (windows-> show view->other ->general->error log)
If all of this doesn't work would you be so kind to install the latest version of eclipse indigo + the Arduino eclipse to test whether you have the same problems?

About compiling the plugin warning "an API baseline has not been set for the current workspace"
Note that the managed builder is avr eclipse code. The warning itself is not a great deal (it is checking of the eclipse baseline) This article explains on how to get rid of it https://teambruegge.in.tum.de/groups/unicase/wiki/5b324/Remove_API_baseline_warning.html

Best regards
Jantje

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Trump211

Installing a new copy of eclipse and then a new copy of the plugin seems to have fixed it.

Go Up