Home / Study Guide Comments

1 Creating programs

1.1 Using the editor

1.2 Adding a program-file to a chapter's folder

1.2.1 Create a new configuration

1.2.2 Set-up the new configuration

1.2.3 For the new configuration, add a new C-file

1.2.4 Update the other configurations

1.3 How to create a new project

2 Troubleshooting  build-problems

2.1 Build problems from adding a C-file, e.g., "No rule to make target"

2.2 How to enable make's debug messages

2.3 How to run "Build All", and check for build errors

2.4 Build's clean fails, e.g., "No rule to make target 'clean'"

 

STM32CubeIDE: creating programs, and build troubleshooting

 

This web-page provides info on using STM32CubeIDE, for working-through the book Hands-On RTOS with

Microcontrollers.  The info here does not appear to be in the book, and it is needed to create programs and troubleshoot build-problems. 

 

This web-page's sections are listed in the table-of-contents.

1  Creating programs

1.1  Using the editor

      Word completion, e.g., for variable names

o      Ctrl+space

1.2  Adding a program-file to a chapter's folder

To gain skill with FreeRTOS, it's helpful to write programs based on the code and features presented in the book.  This section describes how to create an empty program-file (e.g., a C-file).  It can then be coded and built using STM32CubeIDE. 

 

The book's programs are stored in a GitHub repo.  In the repo, there is a chapter-folder for each chapter in the book, e.g., /Chapter_8.  This section describes how to add a new program-file to a chapter-folder. 

 

It appears that each chapter-folders is a STM32CubeIDE project.  Each chapter-folder has a folder Src, which contains the chapter's example-programs, e.g., /Chapter_8/Src.  Each project has multiple configurations, typically one for each example program. A configuration has its own build-scripts for its example program.

 

For a project configuration, it appears that the build-scripts are constructed automatically, for the configuration's example-program, e.g., Chapter_8/Src/mainSoftwareTimers.c.  Just adding a program-file (e.g., a C-file) to the Src folder is likely to result in corrupted build-scripts for the configurations. (How to fix that problem is described in a trouble-shooting section, below.)

 

Instead, when adding a new program-file, a new configuration should first be added for the project.  And, the new program-file should then be added for use by the new configuration.  The following sections describe how to do this.

 

1.2.1  Create a new configuration

      In the Project Explorer, right-click on the chapter-folder, and select:

o      "Build Configurations" : "Manage..."

 

Graphical user interface, application

Description automatically generated

 

      In the next GUI, select "New"

 

      The "Create New Configuration" GUI is shown below

o      At "Existing configuration", select a configuration to copy

      Here, the mutexExample configuration is being copied

o      Provide a "Name" and "Description"

o      Click "OK"

 

Graphical user interface, text, application, email

Description automatically generated

 

1.2.2  Set-up the new configuration

      In the Project Explorer, right-click on the chapter-folder, and select:

o      Properties : "C/C++ Build" : Settings

 

      Select the "Build Artifact" tab

      In the Configuration box, select the new configuration.

      Set the "Artifact name" box,

o      For example, to Chapter8_mutexPrototype (the figure mistakenly shows a different name)

 

Graphical user interface, text, application, email

Description automatically generated

 

      In the Properties GUI, select

o      "C/C++ General" : "Paths and Symbols"

 

      In the "Paths and Symbols" window:

o      Select the new Configuration

o      Click on the tab "Source Location".

o      Then, click on the button "Edit Filter..."

 

Graphical user interface, text, application

Description automatically generated

 

      Update the list of C-files to exclude for the new configuration

o      For the configuration that was copied, add its C-file to the ""Exclusion patterns"

o      In this example, the copied configuration was mutexExample. It's C-file is  Src/mainMutexExample.c.  So that C-file is added to the exclusion patterns.

o      Click on "Apply and close" to save

 

Graphical user interface, text, application

Description automatically generated

 

1.2.3  For the new configuration, add a new C-file

      Next, add a new C-file to the Src folder, for the new configuration

o      Click on  File : New : Source File

 

Graphical user interface, application, Word

Description automatically generated

 

      In the GUI "Source File"

o      Set the entry "Source folder" to the chapter-folder and its "Src" folder

o      Set the entry "Source file" to a name for the new-configuration's C-file

      The file-name needs the ".c" extension, which isn't shown below, mistakenly

 

Graphical user interface, text, application

Description automatically generated

 

1.2.4  Update the other configurations

      For the chapter's project, a new configuration was added.  The other configuration are the "older-configurations".

      Update the older-configurations to exclude the new C-file.  Each older-configuration has to be updated separately.  Use an Exclusion Pattern, as shown earlier.  This is very time-consuming, and there may be a better way to handle this.

 

1.3  How to create a new project

      The link below is for a tutorial on how to create a new project, and configurations for it.  (I haven't used the tutorial, but it looks good.)

o      px-lib: 7.5 How to get started with STM32CubeIDE

      https://piconomix.com/px-fwlib/_h_o_w_t_o__s_t_m32_c_u_b_e_i_d_e.html

 

2  Troubleshooting  build-problems

2.1  Build problems from adding a C-file, e.g., "No rule to make target"

This section describes how to fix build problems caused by incorrectly adding a program-file (e.g., a C-file) to a  STM32CubeIDE project.  The build problems may include the error message, "No rule to make target".   (The error message "No rule to make target 'clean'" has a different cause, and it's described in a later section.)

 

How to add a program-file to a project was described in an earlier section.  The section's introduction describes STM32CubeIDE's use of projects and configurations.  The introduction also describes how the book's example programs are organized by chapter-folders, and how each configuration's build-scripts are generated automatically.  The following instructions assume familiarity with the concepts described in that introduction.

For a chapter-folder, when a C-file is added to its Src folder, the chapter-folder's configurations must be set-up properly.  If the C-file is simply added to the Src folder, and the configurations are not set-up, it can cause build problems.  The next configuration that is built will incorporate that new file in its generated build-scripts.  This can corrupt the build-scripts, and the problem can be difficult to fix.

 

Below is an example of the problem, and how I fixed it.  The description is based on my recollection, which may be inaccurate.  A screen-shot shows the project used (Chapter_8).

      I copied an existing C-file in the project's source-code directory, to make a back-up of the file, e.g.,

o      Chapter_8\Src\mainSemPriorityInversion.c was copied, and

o      the copy was named Chapter_8\Src\mainSemPriorityInversion-backup.c

      The copy's source-file is part of a configuration named "semaphorePriorityInversion".

      I ran build for that configuration, but as I recall, I got build errors related to mainSemPriorityInversion-backup.c.

      I deleted mainSemPriorityInversion-backup.c, but still got build errors, e.g., "No rule to make target". The build errors were from a build-script that expected a file mainSemPriorityInversion-backup.o, which didn't exist.

      I fixed that problem by deleting the folder Chapter_8\semaphorePriorityInversion.  It has the build scripts and build artifacts for the configuration. On the next build, the folder and its contents will be automatically generated, correctly.

 

Text

Description automatically generated with low confidence

 

2.2  How to enable make's debug messages

      Turning on debug messages in make:

o      Goto Project : Properties : C/C++ Build

o      Select Configuration, e.g., all configurations or a particular configuration

o      For the make command, add a debug parameter as in the example below, e.g., "--debug=b"

o      Makefile debug-parameters:

      https://stackoverflow.com/questions/1745939/debugging-gnu-make

 

Graphical user interface, text, application

Description automatically generated

 

      Debug messages go to the console and log-file, both of which can be configured

 

Graphical user interface, application

Description automatically generated

 

2.3  How to run "Build All", and check for build errors

      How to build all of the projects for a book-chapter, e.g., Chapter_8:

o      Right-click on the chapter's folder and select "Build Configurations",

o      Then select "Clean All" or "Build All"

 

Graphical user interface, text, application, email

Description automatically generated

 

      When running Build All, here's a way to check for build errors:

o      Set the console to the "CDT Global Build Console"

      To select it, click on the console icon's dropdown  button:

 

Graphical user interface, text, application, Word

Description automatically generated

 

o      Before running Build All, clear the console (right-click and select "Clear")

o      After running Build All, check the console messages for errors.

      In the console, search for "errors" to check the projects were built correctly

      Right-click and select "Find/Replace"

 

2.4  Build's clean fails, e.g., "No rule to make target 'clean'"

      Problem:

o      In STM32CubeIDE, when using build or clean, the following error may be encountered:

      "make: *** No rule to make target 'clean'.  Stop."

o      This error can be ignored

 

Graphical user interface, text, application

Description automatically generated

 

      Additional information:

o      Build and clean are implemented with make.

o      The problem is encountered when clean is run twice in a row, without a build between the cleans

      This includes using "Clean All", or "Clean" for the active project-configuration

      It also includes the clean used in "Build All", or "Build" for the active project-configuration

o      The problem is due to clean deleting the project-configuration's make-file.

      For a subsequent clean (e.g., "make -j8 clean"), there's no make-file, and thus the error message.

      The error message "No rule to make target 'clean'" is misleading here.  It incorrectly implies there is a make-file, with a missing target.

o      For each project-configuration, it's make-file is created when build is run.

      The make-file is placed in the project-configuration's build directory, e.g.,

      C:\projects\packtBookRTOS\Chapter_8\mutexExample

      Clean deletes everything in the build directory, including the make-file