Microcontroller Embedded C Programming Lecture 11| Importing course projects in to workspace

 

Importing projects into STM32CubeIDE workspace

 

 

 

In the previous article, we installed STM32CubeIDE. And in this article, let’s download all the source codes and import all the projects into the STM32CubeIDE.

This is a very important step; I would suggest you follow this. 

First, create a folder called Embedded C. In your machine, you can create it anywhere you prefer. And in that Embedded C folder, create three more folders. 

  1. Instructor:  Here you are going to save the source codes given by the Instructor.
  2. My_workspace: Where you are going to develop your applications as you make progress in this article.
  3. Downloads:  Where you are going to keep all the downloaded files or whatever you download software or whatever you download from the web, you keep that in downloads.
Embedded C folder
Figure 1. Embedded C folder

 

After that, you go inside the instructor folder and create two more empty folders called ‘host’ and ‘target.’ The reason for this is that we are going to keep all the projects which we write for our host machine, we are going to keep in the host folder. And whatever the projects we are going to write for our Embedded target, we will keep them in the target folder. So, create two more folders, ‘host’ and ‘target.’

You should create the same folders under My_workspace also. 

 

After that, you have to launch your STM32CubeIDE. Let’s launch it.

Here you can see that(Figure 2) it asks you to select a directory as workspace.

STM32CubeIDE Launcher
Figure 2. STM32CubeIDE Launcher

 

So, what you have to do is, you have to go to your Embedded-C folder, go inside the instructor, go inside the host, and select the path, as shown in Figure 3.

Then come to STM32CubeIDE Launcher and paste that path. And click on Launch.

 Host folder Path
Figure 3. Host folder Path

 

Now you created an eclipse workspace called Host, which is under an instructor.  Here, you will keep all the projects that the instructor writes for the Host.  

Figure 4. Eclipse workspace
Figure 4. Eclipse workspace

 

You go to file and click on Import. Then, go to General, and here go to Existing Projects into Workspace. Click Next, as shown in Figure 5.

Figure 5. Import projects
Figure 5. Import projects

 

Here you have to select the root directory. 

Figure 6. Import projects
Figure 6. Import projects

 

For that, go to the Embedded-C folder → downloads →  go to Embedded-C-master → All_source_codes → host.  You copy that root directory path.(Figure 7).

Figure 7. Embedded C root directory path
Figure 7. Embedded C root directory path

 

After that, we paste that path and then click Browse, as shown in Figure 8. It will automatically select all the projects. And also you Click this option ‘Copy projects into workspace,’ and then click on Finish

Figure 8. Import Projects
Figure 8. Import Projects

 

After that, click on the Restore Icon.

Figure 9. Click on Restore Icon
Figure 9. Click on Restore Icon

 

We can see that all the instructor projects are imported into your local machine. 

Figure 10. Imported all the instructor projects
Figure 10. Imported all the instructor projects

 

Here, you can close the information center and also close the Build Analyzer, and close that Static_stack, so you can close everything.  

 

If you see Red cross marks for all the projects, then don’t worry. That means some path settings are missing. So, you can do like this. Go to windows and go to preferences (shown in Figure 11).

Figure 11. STM32CubeIDE
Figure 11. host- STM32CubeIDE

 

This is only if you see Red cross marks for all the projects. Otherwise, you need not do it. You can directly compile.

 

For example, I can select this array_passing project, right-click, and build the project.

Figure 12. Build the project array_passing
Figure 12. Build the project array_passing

 

You can see that the project has been built.

Figure 13. Arrays_passing project has built
Figure 13. Arrays_passing project has built

 

You can see that the ‘gcc’ compiler is invoked, and the project is compiled successfully. 

 

Sometimes you may see the Red cross marks for all the projects, and it may say ‘gcc’ is unrecognized. 

Then you can go to Windows→   Preferences(Figure 11). Expand this C/C++, and go to Build, Environment (Figure 14).

And here, you have to add one variable; the variable name is MINGW_HOME. And the value is the path where the MinGW binaries are present. You have to copy that path and paste it into the value field. 

Figure 14. Adding the Environment variable
Figure 14. Adding the Environment variable

 

And click Apply, Apply and Close. 

Importing projects into STM32CubeIDE workspace
Figure 15. Applying the Environment variable to set

 

Let’s take the first project, ASCII. Right-click on that project and try to build that project. So, this is called compiling.

Check the console here. So, you can see that it builds successfully. The ‘gcc’ is invoked, the project has been built successfully, and you got the binary. So, you should not get any errors here. 

Importing projects into STM32CubeIDE workspace
Figure 16. GCC is invoked and get the Binary

 

If you want to clean this project, click on Clean Project. It should clean up your project. That means the binary which is generated got deleted. At least these two activities you should be able to do.

Importing projects into STM32CubeIDE workspace
Figure 17. Clean the project

 

Now you imported all the host projects written by the instructor of this article. Now, let’s import all the Embedded target projects written by the instructor. 

For that, go to file, go to Switch Workspace, and click on Other option. Here, instead of the host, you mention the target.

Or you can go to your Embedded-C folder, and there you go inside the instructor, go under the target, copy that target path and go to your eclipse and paste that path. Click on Launch.

Importing projects into STM32CubeIDE workspace
Figure 18. Import Embedded target projects

 

Figure 19 shows the new workspace of Target, where we are going to keep all the projects of the Embedded target. 

Importing projects into STM32CubeIDE workspace
Figure 19. Target workspace

 

Again the same procedure. 

  1. Go to File and Click on Import.
  2. General→ Existing projects→ click Next. Paste the root directory path of the target. 
  3. Or go to Downloads, Embedded-C-master, All_source_codes, go-to target, and go to stm32f407_disc. Copy the path.
  4. And then go to Eclipse and paste that path and click on Browse. And click on Copy projects into workspace option and then Finish. 
Importing projects into STM32CubeIDE workspace
Figure 20. Importing all Embedded C target projects

 

And then click on Restore, and then close the information center, close the Build analyzer. 

 

Here we can see that these are the projects written for the Embedded target, as shown in Figure 21. There are more projects to come, so for I have just uploaded these projects into the repository.

Importing projects into STM32CubeIDE workspace
Figure 21. Target projects

 

Let’s try compiling. Now let’s select one project and then right-click on that and click on Build.

Importing projects into STM32CubeIDE workspace
Figure 22. Build the project

 

And go to the console here. And here, the project is cross-compiled. Now the compiler invoked is arm-none-eabi-gcc, so that’s a cross compiler. Now the code is built for the target. Don’t worry about all these things you will learn when creating the project.

Importing projects into STM32CubeIDE workspace
Figure 23. Console

 

The build was successful, and now try to clean that—Right-click on the project and select Clean project. You see, the console,  the clean was also successful. ( Figure 24) . The binary got deleted.

Importing projects into STM32CubeIDE workspace
Figure 24. Clean the project

 

You just imported all the projects created by the instructor. So, now the instructor folder has all host projects and target projects. Do not change any code in the instructor folder because it is given by the instructor. This is for your reference. If you have any issues while working on the project, then you can come back to this folder and check the code or launch the workspace and build the code. But do not try to change the projects.

 

You create your own project in the My_workspace folder. So, here you create the project for the host and the project for the target as instructed in this article. For that, let’s create two more workspaces under host and target. 

For that, you have to go to the Eclipse and again switch the workspace. Let’s click on the Other option. And instead of the instructor, now you give My_workspace. That’s it. Or go to the My_worspace folder→  host, and copy that path. Paste that path in the Eclipse and click on Launch.

Importing projects into STM32CubeIDE workspace
Figure 25. Launch the My_workspace

 

Importing projects into STM32CubeIDE workspace
Figure 26. My_worspace for the host

 

This is our workspace for the host(Figure 26). Whenever you want to create a project, you create it here. So, that will be taught in the article.

And after that, let’s again create one more workspace for My_workspace\target. Whatever the project you want to create for your target, you create it here as taught in the article. 

In the following article, let’s see how to create a project.

 

FastBit Embedded Brain Academy Courses

Click here: https://fastbitlab.com/course1

 

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.