For this part of the tutorial, we will be adding the Eclipse IDE to our toolchain. For this project, I will be using GNU Make to build my source code. When using Makefiles, there isn’t much set up to do in the IDE since most of that effort is spent on the Makefile. The Eclipse IDE is a very powerful IDE. You won’t have to use it long to find that it isn’t perfect, but even with its imperfections, I feel that it is far better than any paid IDE that I’ve used. This is a credit to the developers who are always making great improvements to this very useful IDE.
Download Eclipse CDT
Follow the link below and download the latest version of Eclipse CDT for your version of Windows. I am using Eclipse CDT Kepler v8.2.1 for 32-bit windows.
Once the download completes, extract the zip file. The result should be a folder simply named eclipse. Move the eclipse folder to your ARMTC folder. The image below shows the current status of the folder tree that makes up my toolchain.
Create a Project Folder
Now we need to set up a project folder. I like to keep my code in a separate folder on the C: drive named projects. In the C: drive, create a folder named Projects. Inside the Projects folder, create another folder named E407Blinker. This folder will be the workspace folder. Navigate to the OlimexODS examples folder used in the previous tutorial, and copy the entire STM32-E407_blink_FLASH folder in to the newly created E407Blinker workspace folder.
Navigate to the eclipse folder within your arm toolchain folder, and start eclipse by running the eclipse.exe file. You will then be prompted to designate a workspace. Select the E407Blinker folder as your workspace folder and click the Ok button.
Import the Project
Now we will need to import our project files and set up our project within eclipse. Start by clicking File and Import as shown below.
In the Import dialog, under the General tab, highlight Existing Projects into Workspace, and click Next.
In the Import Projects dialog, click the Browse button and navigate to the STM32-E407_blink_FLASH folder. Eclipse should then detect the project information within the folder. The project can then be selected for import. Make sure that the project is selected, and push the Finish button.
Now you should be able to see the project in the project explorer.
Initially, I had an error saying that there was no gcc in the PATH. This is because eclipse is looking for a toolchain. To get rid of this, right click on the project name, and select properties. Expand the C/C++ Build section and click on the Tool Chain Editor. Click the Current toolchain dropdown menu, and select No ToolChain.
Add Include Paths for Indexer
Open the main.c file from the project explorer by double clicking it. Also, open the problems window. If it is not already open, open it by clicking the window tab, then show view, and Problems. The indexer should automatically populate the problems window with all of the references that it couldn’t find. This is because it doesn’t know where all of the include files are.
To add the include paths, right click on the project in the project explorer, and click on properties. Expand the C/C++ General category. Click on Paths and Symbols. You should see something similar to what is shown below. To add the include paths, start by clicking the Add button.
Add checks next to Add to all configurations and Add to all languages. Click the Variables button.
Click the ProjDirPath variable. This will prepend the include path with a path to your project directory. Click the OK button.
You can then see the path variable automatically added to the Directory text box. Add the lib and inc folders to the path as shown below. Click ok when you are done.
Follow the same procedure two more times leaving off the inc and then the lib folders. You should see something similar to the image below. When you are done, click OK.
Eclipse will then prompt you to rebuild the index. This gives the indexer the opportunity to parse your source code with the include paths that you have just added.
As you continue coding on your project, you will notice that you have to manually tell the indexer to parse your code. To do this, right click on the project in the project explorer, click Index and then Freshen All Files.
Clean and Build
To clean the project, right click on the project name, and select Clean Project.
You can see in the output it is trying to delete a file that ends in .dmp and .lss that are not there. This is creating an error.
To get rid of this error, we need to delete these from the Makefile. Expand the project in the Project Explorer and double click the Makefile to open it in the editor. It would be a good idea to read over this file, and become familiar with this Makefile so that you have a better idea of the build process for this project. Scroll to the very last line in the Makefile. The previous line should be the clean label. When the make clean command is entered, this line ex executed. You can see the .lss and .bss parts that need to be deleted. Delete the $(BIN)/*.dmp and $(BIN)/*.lss entries from the line. To see the results of this, you will need to compile to generate the files again, then execute the clean command again.
Finally to build the project, right click on the project in the Project Explorer, and click Build Project.
If you click the file below, the image should open, and you should be able see the output from the build process.
More Errors to Clean Up
At this point, if I look at my problems window, I now have almost 6 thousand errors. When I look at the first one, I can see that it doesn’t even recognize the standard integer definition. Also, if you look at the source code file that is open in the image below, you can see that Eclipse’s indexer cant find the stdint.h file. This is because we haven’t told the indexer where to find the c library.
Once again, go to the project properties window, by right clicking on the project and selecting properties. While we are in here, start by going to the C/C++ General tab, then under the Code Analysis tab, click on the Launching category. Here, ensure that check boxes are added before both Run with build and Run as you type. This will ensure that you will be warned of errors as soon as possible.
No go back and click on the Code Analysis category. Here you can select what types of errors, warnings, and info that the indexer will warn you of. At one point, I was all excited, because I thought I had eliminated all of my errors when really I had just removed the check next to Syntax and Semantic Errors. As I got to looking at these, I decided that it would be nice to be warned of these, so now I leave it checked.
Finally to allow the indexer to see our C library, we have to tell it where to find it. Click on the Paths and Symbols category. Under the Includes tab, add a path to the C library in your ARMGCC folder. This is done the same way as we did above for the project include paths. Start by clicking the Add button, then make sure that the Add to all configurations and the Add to all languages boxes are checked. For the path, we will once again be using relative paths. Relative paths can save so much headache later when trying to share or modify your project later. Start by adding the eclipse_home variable. Next, add a backslash and two periods. This will move you to your toolchain directory. From there, start with another backslash, and enter the path to your ARM GCC include directory. The path that i ended up with is shown below.
When you are done, click Ok on both windows.
Now that the indexer should know of the C library, do another clean and build. Here I was still left with a few errors. These errors were from unresolved types in the arm_common_tables.h file. I did a search for these, and found that nothing was using these, so I decided to just delete the file at this point.
Once the file was deleted, I compiled again, and this time had no problems listed.
Now you should have a functioning IDE. Once you get it all set up, Eclipse can be a very powerful IDE.