12 Replies Latest reply on Jan 4, 2015 9:17 AM by KurtE

    Using Eclipse to build and debug projects for Edison.

    KurtE

      Sorry I know that a lot of this is covered in other places, but I am thinking of trying to make a version of my Hexapod code base to be build-able and can be debugged using Eclipse.  Started to play and lots of start-up questions come to mind.  (I have a version that runs using makefiles and also an Arduino version)

       

      1. Install Eclipse - found downloads and tutorial... Getting Started for C/C++ (Eclipse) - Galileo & Edison

       

      2. How to configure for use with Edison.  My first pass through, I assume I use the Galileo settings in the Remote system...  Are there options to set up specific to Edison, different optimizations...

       

      3. How to create a new Project, without all of the Example code? I know I saw a thread here.  Need to find.

      Maybe this one: How do you properly create a new project in Eclipse for Iotdk?

       

      4. MRAA - Keep in sync.  I know I saw a thread: Updating Eclipse to stay in sync with IoT

      Can I debug MRAA through this (Step in/over)?  Is there a debug version?  If I build debug version on Edison, how setup PC side to know and use it?

       

      5. Multiple projects that depend on each other:  Using linux make files, I have a library project that I build my own library that does stuff like emulate some Arduino capabilities.  My makefiles for other projects that depend on this automatically build this when needed.  Hard to do similar with Eclipse?

       

      6. Third party libraries - Like Asoundlib, or Espeak.  I can now opkg install this including the dev libraries and header files on Edison (Thanks!)  How to install these on PC side such that Eclipse can link?

      I did see the thread: How to add 3rd party libraries to cross compile toolchain ?

      But I think it only partially answered the question, that is how to add an option to the linker.

       

      7. ???  - Will probably have more questions when I get going with this.

       

      Again sorry if this is maybe just a rehash, but just trying to figure out a reasonable plan of approach for how to migrate code over to Eclipse.

       

      Thanks

        • 1. Re: Using Eclipse to build and debug projects for Edison.
          CMata_Intel

          Hi Kurt;

           

          1. That is the recommended tutorial

          2. Setting up Eclipse. Step 6 enters how to choose between them and states: "The “galileo” entry is just a nomenclature and will not affect the environment if you have an Edison board".

          3. Have you tried with this Running a Sample Application ?

          This is another thread related to how to create successfully a new project.

          4. Did that suggestion worked for you? Have you tried to upgrade the library in your board and pass the source code in the PC?

          5. I've never tried something similar, so I can't tell how hard it could be.

          6. Take a look at these links:

          FAQ How do I add an extra library to my project's classpath? - Eclipsepedia

          Adding an External Library to an Eclipse Project Folder | The Oxford Math Center

          Take a look at the properties too:

          7. Don't hesitate in ask

          Let me know if this is useful for you.

           

          Best Regards;

          CMata

          • 2. Re: Using Eclipse to build and debug projects for Edison.
            KurtE

            thanks,

            I am just starting to play.

             

            3. I did the copy/Paste method for creating projects.  Would be nice to have a completely different project groups, where I can only see my main projects.

            4. I have used the thread to update the MRAA stuff on my development machine.  Note: when you download the zip file and then copy it into the location within your devkit.  You will still have the previous versions of the library still in that folder.  That is I have libmraa.so, libmraa.so.4, libmraa.so.0.4.5, libmraa.so.0.5.0, libmraa.so.0.5.2

            I have not tried the debug stuff yet.

             

            5. I will try to experiment with this.  The first issue may be, how to setup the target to be a library and not an executable. Note: I am not trying to do a shared library, just a simple one....

             

            6.  The links you gave were mainly for Java... But my guess is that i should, copy the necessary associated header files and libraries. and either put them into standard location like: C:\Users\Kurt\iotdk-ide-win\devkit-x86\sysroots\i586-poky-linux\usr\lib

            Or create a new set of directories and add the directory to the appropriate search paths.

             

            Thanks again

            • 3. Re: Using Eclipse to build and debug projects for Edison.
              Thror

              Hi KurtE,

               

              3. Intel has just published a useful guide on this https://communities.intel.com/docs/DOC-23642. Before this guide I usually do this steps:

              • Export path & symbols from an examples
              • Create a New C++ project with this parameters:
                • Cross GCC
                • cross compiler prefix: i586-poky-linux-
                • cross compiler path : ...\devkit-x86\sysroots\i586-poky-linux
              • Import previous path & symbols in the new project.
              • Go to preference of the project--->C/C++ Build
                • --->Builder Settings select Bulider Type=Internal Builder
                • --->Tool Chain Editor set Current Toolchain=Cross GCC and Current builder=CDT Internal Builder
                • -->Settings--->Tool Settings--->Cross G++ Linker --->Miscellaneous set Linker flags=${LDFLAGS} -lmraa
              • Build the project
              • Run the project as remote application

              4. I simple upgrade libmraa in the board and then copy the new .so file in the PC usr/lib/ directory and delete the previous so.0.version_old

               

              I hope it is useful information.

               

              Regards,

               

              Thror

              • 4. Re: Using Eclipse to build and debug projects for Edison.
                KurtE

                Thanks for the link!

                 

                Looks like it should have most of the information I am looking for

                 

                Edit: One note on this.  This document appears to be mainly for developing on a Linux Ubuntu setup, which I can do on my secondary machine.  It will be interesting to see how much of the information applies to using Edison under windows...

                 

                Thanks again!

                • 5. Re: Using Eclipse to build and debug projects for Edison.
                  KurtE

                  I am making some progress today I built a project that generated a library that contained all of my standard Arduino replacement functions and the like.

                  It now generates an appropriate library.  It still shows a couple of errors in the problems window about gcc and g++ not found in path, but things compiled and linked.

                   

                  I also tried some quick and dirty source level debugging. I was able to step into some of my library functions.  I did notice that it complained about not being able to debug into 7 shared libraries.  Next up will see if these are some special tricks to build things like mraa in debug mode such that it can also debug into these files as well.

                   

                  But making progress.

                  • 6. Re: Using Eclipse to build and debug projects for Edison.
                    KurtE

                    mmaking more progress.  Have main app working, can do source level debugging. 

                     

                    next wondering about being able to debug into things like mraa.  Wonder if any secrets on how to enable remote debugging of this...

                    • 7. Re: Using Eclipse to build and debug projects for Edison.
                      mhahn

                      You'd obviously require a debug version of mraa on the target and the sources on the host

                      • 8. Re: Using Eclipse to build and debug projects for Edison.
                        KurtE

                        Thanks, I think I did that.  That is I used the debug option in the cmake on the edison, then did a make and a make install,

                         

                        I then copied the headers and libs back over to PC, to use in build.  I am enlisted in the mraa github project, so I have the sources.  I guess the question is maybe how to get the debugger to know or prompt for location of MRAA sources.  Do I maybe have to add the MRAA source tree somewhat into the eclipse work space... Will experiment more in the next day or so.

                         

                        Thanks again

                        • 9. Re: Using Eclipse to build and debug projects for Edison.
                          KurtE

                          I was posting some stuff up on Trossen Robotics forum about doing stuff with Eclipse, so thought I would put some of it here as well, in case anyone can find anything useful in it:

                           

                          Things like:

                          I created a new workspace, which only has my projects in it. I want it to support the stuff in the one they setup. So I copied all of the preferences into it. I think I did this, by going to the File->Export select general then preferences and export all to a file. Then switch to new workspace (I think I created using File->Switch workspace and choose other...). Then I imported the preferences.

                           

                          I added my own projects to this workspace.

                          File->Import Existing project... In some cases I had it copy the project into my workspace...

                           

                          I added remote connections to talk to my two Edisons. In original workspace, I went to the Galileo remote object and exported it to a file, switched to my new workspace and did an import of the connection. I did this twice and call one Edison and the other Edison Mini. Each has the IP address of the two different Edisons.

                           

                          In order to allow me to choose which workspace I want to start up, I edited the windows batch file that is used to launch it. And I removed the place where it hard codes the workspace... ie change the command from:

                          START %DEVKIT_HOME%\eclipse-win\eclipse.exe -data %DEVKIT_HOME%\iot-devkit\workspace

                          to:

                          START %DEVKIT_HOME%\eclipse-win\eclipse.exe

                           

                          Note: Eclipse will then come up with a dialog asking you to choose. You can choose and then tell it not to ask anymore...

                           

                          In my workspace, I now have some projects for executables as well as some projects that generate libraries. 

                           

                          It took me a few attempts to get libraries to build properly. I should probably go through this again and figure out, what steps I did to get it to create the archive properly using the correct cross compiler. I now just copy and paste new libraries.

                           

                          For an executable project, I also often copy/paste, but I believe the way to make s semi clean one is to:

                          File->new Choose Project. In dialog choose C++ project, under it choose GNU Autotools and then the Hello world... (This is covered in one of the current intel docs...)

                           

                          The above hopefully set up everything to build using the standard cross compiler headers and libraries. If you wish to use some additional headers and libraries. you can add those, through the Project->Properties command. to to C/C++ item, expand and choose Settings: Then you can add your includes to Cross GCC compiler section and/or Cross G++ compiler section.

                           

                          Likewise if you are using new libraries, you go to the Libraries secion of the Cross G++ linker and add in the Search path to point to your new library and your library to the libraries section. 

                           

                          Note: Some of my programs wish to use other libraries that you can install on your Edison that is not part of the Eclipse download, so you may need to copy those to your PC to build with. What I have done with my new workspace is to go into the workspace and do:

                          New->Folder command, that I created a directory Edison_Incs_Libs and then under it created an: include folder and likewise a lib folder, which I then uploaded the appropriate files from my Edison. This currently includes files for Espeak, Asound, ... I also currently have MRAA files here as well. I then added these folders into the Include and library sections for each project. Note: I put them as one of the first ones in the search as to allow me to experiment with things like MRAA and have it choose my current ones instead of the ones that are in the standard Eclipse install.

                           

                          Note: when using the standard updates for MRAA on your Edison, I also update the MRAA includes and libraries in the Eclipse folders...

                           

                          Once I have a program that builds properly and you wish to try it out on the Edison and you have not run this program before, you need to set up a run configuration or if you want to update the current configuration. I do this by right clicking on the project in the workspace window and choose the: Run As -> Run configurations menu item

                          This brings up a Run Configurations dialog. If you have already done this for this program it will show the appropriate item under the C/C++ Remote Application. If not, Double click on the C/C++ Remote Application item and it will generate a new one. In this dialog choose the appropiate connection to get to your Edison. Also Choose your application. Currently I am only building Debug, so one example I have: Debug\EdisonConsole

                           

                          Then you need to chose where to install the program on your Edison. The sample programs all go to the /tmp directory, I am currently installing them in /home/root/Eclipse as to keep them (tmp directory is RAM, so they are gone if you reboot).

                          So in the above case I have: /home/root/Eclipse/EdisonConsole.

                           

                          In the Commands to execute before Application I have:

                          chmod 755 /home/root/Eclipse/EdisonConsole.

                           

                          Once you save this away you should be able to run this program remotely. Since the Run As was a debug configuration, so far it appears like it is also setup properly for Debug As... But if not can setup same way.

                           

                          You can then use the appriate Run or Debug command buttons to hopefully run your program. As for what commands Eclipse uses to download and run and Debug, not sure... I know with Intel Edison Arduino I have a hacked up version to allow downloading over wifi and I use plink and pscp to do this (Part of Putty and WinScp). 

                          • 10. Re: Using Eclipse to build and debug projects for Edison.
                            mhahn

                            I think the ideal way to add libs would be to have opkg package manager running within Eclipse as well allowing to install/update packages to cross environment. Any thoughts? (It's still close to Christmas so dreams may come true ;-))

                            • 12. Re: Using Eclipse to build and debug projects for Edison.
                              KurtE

                              Update: I have been playing around using Eclipse now for awhile and do enjoy having all of the sources in one place, plus it pre-checking things for me and hardware debugging support.

                               

                              So I created my own Workspace for my PhantomX (Hexapod and probably Arm as well) projects, which has all of my sources, including libraries for the Adafruit display, Arduino Support library, AX serial support.  Also top level Hexapod program.  Actually two version, Fixed point math version which is working, and floating point version still debugging.  Also I have the start of simple console app, that allows me to launch a few programs. Also has scrolling text region so those programs can display text...  Mostly out of topic here...

                               

                              But, now suppose I wish to share this, between machines?  Also allow others to take a look at and use parts of it if they wish?

                               

                              So I push the sources up to github.  Example in this case: https://github.com/KurtE/Edison_Eclipse

                              Currently I have excluded stuff out of these directories, like the generated programs and libraries, as well as the stuff I copy from my Edison (sound and speak libraries and headers).

                               

                              But currently I have also excluded the .metadata directory as this is now maybe something like 19-20mb of stuff.  My guess is you don't need most of it.  However without any of this, the project does not show up properly on a different machine.

                               

                              That is yesterday, I followed some of my above steps and installed Eclipse on my portable and then went up to github and downloaded the project to this machine (used github for windows).

                              I tried to switch workspaces to this and it showed the welcome and getting started layout...  I tried to do a export preferences out on my main machine and import it on my portable and it still did not show up the different projects and the like.  I then coppied over the complete .metadata and it works.

                               

                              So question is, what subset of this is needed to export this to show up as a valid workspace, which has the projects in it.  Optionally also show up the remote connections, although one can do that easily enough on each machine, by exporting the Galileo one from the workspace that comes with the IOTDK, and then import it into new workspace.  I actually imported a couple of times so have different ones for my Arduino board and my Mini breakout board.

                               

                              Thanks