Building MultiWii in Eclipse

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
clough42
Posts: 70
Joined: Sat Dec 08, 2012 6:10 pm
Location: Boise, Idaho

Building MultiWii in Eclipse

Post by clough42 »

Now that MultiWii has been converted to .cpp/.h files, I have put together a prototype of a turnkey Eclipse workspace. This is based on casquad's fine work on the CppMigration branch. It would not have been possible without his help.

Here are the requirements, as I see them:
  • Have a set of Eclipse projects checked into SVN to make it easy to set up and maintain a working development environment.
  • Keep the Eclipse project files separate from the source code, so MultiWii can continue to exist independent of any IDE. (from Alex)
  • Maintain the ability to simply open MultiWii.ino in the Arduino IDE and build. (from Alex)
  • Organize the files so it is easy to set up similar environments for other IDEs.

To this end, I have a prototype on a branch: https://multiwii.googlecode.com/svn/branches/clough42/ide/eclipse-2013-07-05

This is just a branch of trunk with one new top-level directory: "Eclipse":

  • Eclipse
    • Arduino
      • Eclipse project files
      • Arduino core library sources and includes.
    • MultiWii
      • Eclipse project files
      • src
        • MultiWii - An svn:externals reference to the MultiWii_shared folder at the root of the repository
  • MultiWii_shared - included using svn:externals, above
  • ...

For those of you unfamiliar with svn:externals, it's just an attribute on the Eclipse/MultiWii/src folder that references the top-level MultiWii_shared directory and indicates that it should be checked out as "MultiWii" inside the "src" directory. This allows the code to be checked out inside the Eclipse workspace/project folders on a developer's system, but there's still only one copy of the code in the repository, SVN updates it automatically and any changes to the files in the folder are automatically committed to the right place in the repository. Developers who don't want to use the Eclipse workspace can continue checking out MultiWii_shared however they're used to doing it.

You don't have to do anything special to get svn:externals to work. If you check out the Eclipse folder, you get everything you need automatically.

One other note: since the code is checked out under a directory called "MultiWii" the Arduino IDE will work properly if you just open the MultiWii.ino file.

To get up and running quickly in Eclipse:

  • Set up your Eclipse toolchain (AVR Plugin, favorite SVN plugin, etc.)
  • Check out the branch (above)
  • Switch your workspace to the "Eclipse" folder
  • Import the two projects ("Arduino" and "MultiWii")
  • Build the appropriate configurations of "Arduino"
  • Edit and build MultiWii

Detailed setup instructions will be coming soon.

If folks are generally supportive of this approach, I'll move the Eclipse folder over to trunk. Maybe it should be in an IDE folder, to make a natural place to check in similar efforts for other IDEs.

User avatar
clough42
Posts: 70
Joined: Sat Dec 08, 2012 6:10 pm
Location: Boise, Idaho

Re: Building MultiWii in Eclipse

Post by clough42 »

I went ahead and moved the Eclipse workspace under an IDEs folder in the branch, to make room for other IDEs in the future.

User avatar
clough42
Posts: 70
Joined: Sat Dec 08, 2012 6:10 pm
Location: Boise, Idaho

Re: Building MultiWii in Eclipse

Post by clough42 »

This is now on trunk, under IDEs/Eclipse.

Documentation is forthcoming.

User avatar
clough42
Posts: 70
Joined: Sat Dec 08, 2012 6:10 pm
Location: Boise, Idaho

Re: Building MultiWii in Eclipse

Post by clough42 »

As promised, documentation for setting up Eclipse is now in the Wiki:

http://www.multiwii.com/wiki/index.php?title=Developing_in_Eclipse

felixrising
Posts: 244
Joined: Sat Mar 23, 2013 12:34 am
Location: Australia

Re: Building MultiWii in Eclipse

Post by felixrising »

^^ Someone buy that guy a beer!

User avatar
NikTheGreek
Posts: 348
Joined: Thu Dec 08, 2011 4:17 pm
Location: Greece
Contact:

Re: Building MultiWii in Eclipse

Post by NikTheGreek »

felixrising wrote:^^ Someone buy that guy a beer!


+10000000
Thank you !!! :D

Niclas Hedlund
Posts: 16
Joined: Wed Sep 14, 2011 7:00 am
Location: Sweden

Re: Building MultiWii in Eclipse

Post by Niclas Hedlund »

Great guide! Feels good to leave the Arduino IDE. :)
But it only compiles the first .cpp file in both projects (Arduino and Multiwii) when I hit build. So malloc.cpp and Alarms.cpp get compiled but nothing else.
Feels like something is wrong in the make file? (I'm not that familiar with make files)
(I have all the .cpp files in the src folder, and no compile errors)
Any quick solution?

Edit: The solution/problem was that WinAVR was installed in c:\Program Files (x86)\WinAVR\. The parenthesize, "()" creates this trouble.
See: http://www.avrfreaks.net/index.php?name ... ic&t=64657

I moved it to c:\Program files\WinAVR\ and everything is fine! (also edited the path variables in windows pointing to Program Files(x86)\WinAVR)
Last edited by Niclas Hedlund on Fri Jul 12, 2013 7:52 am, edited 1 time in total.

User avatar
alll
Posts: 220
Joined: Fri Dec 07, 2012 9:53 am

Re: Building MultiWii in Eclipse

Post by alll »

Thanks Clough42!, i can't try it out now, will do it soon.
manu

sorg
Posts: 34
Joined: Mon Apr 08, 2013 2:49 pm

Re: Building MultiWii in Eclipse

Post by sorg »

I have followed the Wiki tutorial: It's perfect.

I don't now eclipse at all and I have a question.

How can i create several variant of multiwii (to keep sperated my patches while developping ) ? What i would need is to create a branch , but a local one, not on the multiwii repo .

I tried to copy / paste the src/multiwii folder, but I can't compile after that because some variable are declared twice... It seems that eclipse try to comple both folders at the same time...

Sebbi
Posts: 478
Joined: Sun Jul 08, 2012 1:08 am
Location: Germany
Contact:

Re: Building MultiWii in Eclipse

Post by Sebbi »

Has anyone got the upload via avrdude on a Mega2560 working? While the "Arduino" configuration resets the Mega, the upload doesn't work ... the Arduino IDE uses stk500v2 and 115200 baud to upload, but that doesn't reset the Mega :/

Edit:
Ok, figured it out ... you have to switch the DTR circuit to on (Windows 7) before uploading. If you do this, avrdude is able to reset the Mega2560 when using stk500v2.

'mode comX dtr=on' on the commandline does that (replace X by the comport number)

sorg
Posts: 34
Joined: Mon Apr 08, 2013 2:49 pm

Re: Building MultiWii in Eclipse

Post by sorg »

Multiwii (latest multiwii shared) does not compile if i uncomment one of the sonar (for example # define srf02)


Code: Select all

../src/MultiWii/MultiWii.cpp:1106: error: 'Sonar_update' was not declared in this scope

User avatar
clough42
Posts: 70
Joined: Sat Dec 08, 2012 6:10 pm
Location: Boise, Idaho

Re: Building MultiWii in Eclipse

Post by clough42 »

Niclas Hedlund wrote:Great guide! Feels good to leave the Arduino IDE. :)
But it only compiles the first .cpp file in both projects (Arduino and Multiwii) when I hit build. So malloc.cpp and Alarms.cpp get compiled but nothing else.
Feels like something is wrong in the make file? (I'm not that familiar with make files)
(I have all the .cpp files in the src folder, and no compile errors)
Any quick solution?

Edit: The solution/problem was that WinAVR was installed in c:\Program Files (x86)\WinAVR\. The parenthesize, "()" creates this trouble.
See: http://www.avrfreaks.net/index.php?name ... ic&t=64657

I moved it to c:\Program files\WinAVR\ and everything is fine! (also edited the path variables in windows pointing to Program Files(x86)\WinAVR)


Thanks for the reminder. I have added a note to the instructions to avoid paths with parenthesis.

User avatar
err888
Posts: 16
Joined: Mon Jul 22, 2013 9:31 am

Re: Building MultiWii in Eclipse

Post by err888 »

sorg wrote:Multiwii (latest multiwii shared) does not compile if i uncomment one of the sonar (for example # define srf02)


Code: Select all

../src/MultiWii/MultiWii.cpp:1106: error: 'Sonar_update' was not declared in this scope


Hi, I have this issue as well. MultiWii doesn't even compile under Arduino too when one of the sonar is uncommented, and I receives this message:

Code: Select all

GPS.cpp: In function 'void GPS_NewData()':
GPS.cpp:431: error: 'sonarAlt' was not declared in this scope


If I declare it under MultiWii.h then I see the Sonar_update was not declared message. These likely starts happening to me since the MultiWii port to cpp. :cry:

User avatar
alll
Posts: 220
Joined: Fri Dec 07, 2012 9:53 am

Re: Building MultiWii in Eclipse

Post by alll »

add

Code: Select all

extern int16_t  sonarAlt; //to think about the unit
in MultiWii.h
and

Code: Select all

void Sonar_update();
in Sensors.h

manu

User avatar
err888
Posts: 16
Joined: Mon Jul 22, 2013 9:31 am

Re: Building MultiWii in Eclipse

Post by err888 »

alll wrote:add

Code: Select all

extern int16_t  sonarAlt; //to think about the unit
in MultiWii.h
and

Code: Select all

void Sonar_update();
in Sensors.h

manu


Just tried, now I get this:

Code: Select all

E:\Multiwii\EclipseWorkspace\MultiWii\Standard/../src/MultiWii/MultiWii.cpp:1106: undefined reference to `Sonar_update()'
make: *** [MultiWii.elf] Error 1

User avatar
alll
Posts: 220
Joined: Fri Dec 07, 2012 9:53 am

Re: Building MultiWii in Eclipse

Post by alll »

Mmm, i am not a "hardcore" developer, but if you can't solve these kind of compilation errors, i can't always help you, sorry.

User avatar
err888
Posts: 16
Joined: Mon Jul 22, 2013 9:31 am

Re: Building MultiWii in Eclipse

Post by err888 »

Thanks alll, never mind.

I'm a beginner of C++ and even greener at Eclipse. When I learnt the port away from Arduino has happened I was a bit lost, but still believes this is the correct way for MultiWii so I'm learning to live with it. Thanks clough42 for the wonderful Eclipse guide, I (mostly) successfully setup my Eclipse environment and start building the project from the repository.

About the last build error I met:

Code: Select all

E:\Multiwii\EclipseWorkspace\MultiWii\Standard/../src/MultiWii/MultiWii.cpp:1106: undefined reference to `Sonar_update()'
make: *** [MultiWii.elf] Error 1


I have tried a few things in the code and found that by changing line 1715 in Sensors.cpp from:

Code: Select all

inline void Sonar_update() {}

to:

Code: Select all

void Sonar_update() {}

, I can compile the project successfully.

My question is whether both code are equivalent in terms of functionality?

Kenny

Mis
Posts: 203
Joined: Fri Apr 01, 2011 12:23 am

Re: Building MultiWii in Eclipse

Post by Mis »

Simple add

Code: Select all

void Sonar_update();

line to sensors.h file before "void initSensors();" line.

And one more for others...
Please dont use conditional macros (#if defined....) in header files. Forward definitions of non existing functions not generate any warnings or errors, nor affect the result code. Only increase count of "#ifdef" shit.

timecop
Posts: 1880
Joined: Fri Sep 02, 2011 4:48 pm

Re: Building MultiWii in Eclipse

Post by timecop »

Mis wrote:Only increase count of "#ifdef" shit.

I thought that was the whole purpose of this project? :)

User avatar
err888
Posts: 16
Joined: Mon Jul 22, 2013 9:31 am

Re: Building MultiWii in Eclipse

Post by err888 »

Hi Mis,

Mis wrote:Simple add

Code: Select all

void Sonar_update();

line to sensors.h file before "void initSensors();" line.


I gave this a quick try, but it doesn't seems changing the error message when build.

I have deleted some dumb questions, sorry for my noobness :oops:

After some searching I seems got that calling an inline function from another cpp file is not possible, i.e. calling the inline function Sonar_Update() in Sonar.cpp from the main loop in Multiwii.cpp will cause build error, but calling the inline function Sonar_Init() within Sonar.cpp itself works. Is that correct?

Kenny

picstart
Posts: 10
Joined: Fri Aug 09, 2013 9:30 pm
Location: Florida USA

Re: Building MultiWii in Eclipse

Post by picstart »

Thank you thank you thank you Danka Danka Danka! Sebbi ..I spent several hours trying to chase down a solution to a win7 64 pro and Eclipse that would not upload multiwii to a atmel 2560. Ardruino on the same PC would upload so it seemed to be an Eclipse issue. Turns out using the Windows7 command prompt with mode com9 dtr=on fixed it ( my specific comport was 9 ).
Eclipse is for me almost essential for Multiwii. Multiwii has an enormous number of nested #if..#endif blocks. Eclipse is code aware so if the # icon is selected Eclipse will gray out the code blocks that are inactive due to various #defines. This is very nice to avoid active inactive code confusion.
I thought the upload answer to my issue would be in passing parameters to the avrdude invoke in Project>>Properties>>AVR>>AVRdude within Eclipse....anyway the Arduino IDE must do the dtr=on within its own code. Your solution needs to get added to the otherwise excellent tutorial on creating an Arduino environment within Eclipse.
Again
Danka Sebbi

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: Building MultiWii in Eclipse

Post by doughboy »

with the current eclipse project setup, how do I checkout files from an earlier revision?

the svn:externals link to src directory is hardcoded to get the head revision on MultiWii_shared. I want to build an earlier revision so I need to check out based on a specific revision number.

thanks

User avatar
clough42
Posts: 70
Joined: Sat Dec 08, 2012 6:10 pm
Location: Boise, Idaho

Re: Building MultiWii in Eclipse

Post by clough42 »

This is an unfortunate feature/deficiency of Subversion. The svn:externals reference uses a relative path to point to the MultiWii_shared directory, and it doesn't specify any particular version. This means that SVN will automatically pick up the right HEAD version for the branch but it doesn't traverse external references when you manually update to a specific revision.

As far as I can tell, this is just the way SVN works.

If you just want to build a specific earlier version, first update your source tree to the revision you want, and then update IDEs\Eclipse\MultiWii\src\MultiWii to that revision as well. If you later do an update at the root of the tree, it will update the external reference back to HEAD.

If you need to be able to repeat builds at a particular revision over and over for some reason, it's possible to do some things with branches, but it doesn't sound like that's what you're after.

electron6
Posts: 5
Joined: Tue Mar 12, 2013 6:26 pm

Re: Building MultiWii in Eclipse

Post by electron6 »

Hello
I'm trying to change to eclipse IDE. I am able to compile my multiwii project successfully, but I have problems with programming the device.
I have a Nanowii Board (atmega32u4). I made the AVRDude settings as recommended in wiki (Programmer: Arduino, Baud:57600).

I receive the following error message:

Launching C:\WinAVR-20100110\bin\avrdude -pm32u4 -carduino -P8 -b57600 -Uflash:w:MultiWii.hex:a
Output:
avrdude: ser_open(): can't open device "8": Das System kann die angegebene Datei nicht finden.


What is my problem? COM8 is NOT blocked by another program.

Greetings
Markus

User avatar
Zapphoid
Posts: 9
Joined: Tue Dec 18, 2012 11:19 am

Building MultiWii in Eclipse

Post by Zapphoid »

Go into the Windows device manager an check what port you are running on, it can sometimes change when plugged into another USB port.

User avatar
NikTheGreek
Posts: 348
Joined: Thu Dec 08, 2011 4:17 pm
Location: Greece
Contact:

Re: Building MultiWii in Eclipse

Post by NikTheGreek »

electron6 wrote:I receive the following error message:

Launching C:\WinAVR-20100110\bin\avrdude -pm32u4 -carduino -P8 -b57600 -Uflash:w:MultiWii.hex:a
Output:
avrdude: ser_open(): can't open device "8": Das System kann die angegebene Datei nicht finden.


What is my problem? COM8 is NOT blocked by another program.

Greetings
Markus


Type COM8 in the field..and NOT 8

Post Reply