Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Keil][STM32CubeIDE] Keil integration into STM32CubeIDE

The background:
I have to use Keil in my job and honestly - I don't like it much.
The debug is great, but the editor is lacking in many features compared to other IDEs.

I was trying to find a working extension to STM32CubeIDE to integrate Keil's toolchain (build/rebuild/clean) and parse all errors/warnings/infos into STM32CubeIDE.
I couldn't find a sufficient solution, so I decided to make it by myself!
The main purpose of this blog entry is to make the STM32CubeIDE to be a front-end for the Keil's toolchain.

The solution:
I assume that you already have STM32CubeIDE project created from Keil's project source files - if not, check out this two blog entries:
If you are interested in VSCode front-end for the Keil's toolchain, see this blog entry.

NOTE: It is assumed that UV4.exe and fromelf.exe (both are in Keil's folders) are in the PATH of your Windows.

Let's start with adding an error parser (i. e. RegEx patterns) to a general build settings of your version of Eclipse/STM32CubeIDE:
00.png
1621286488247.png

Copy/paste content:
Error: (.*)\((\d*)\):\s*.rror:\s*(.*)
Warning: (.*)\((\d*)\):\s*.arning:\s*(.*)
Info: (.*)\((\d*)\):\s*.nfo:\s*(.*)
Info: (.*)\((\d*)\):\s*.ote:\s*(.*)
File: $1
Line: $2
Description: $3

Error: ^(.*):\s*Error:\s*(.*)$
File: $1
Line:
Linker: $2

Now link just created error parser with your project:
02.png
03.png

So far so good - since now every error/warning/info from building log will be detected and utilised by the Eclipse IDE in a natural way.

Next step is to update build settings of your project to use Keil's toolchain:
1621467789169.png

Copy/paste content:
Build directory:
${workspace_loc:/${ProjName}}/../..

05.png

1621465072907.png

Copy/paste content:
Build:
build TARGET=${ConfigName}

Clean:
ALL_clean
You can then create problem filters to have problems only from Keil's build:
1621286596032.png

1621286601242.png

1621286606441.png


Now we can also add Build Targets:
1621465124188.png

1621465130031.png

1621465136131.png
1621465142003.png
1621465146596.png
1621465149894.png
and so on...
Copy/paste content:
build TARGET=${ConfigName}
ALL_build
[DBG]_ALL_build
[REL]_ALL_build

rebuild TARGET=${ConfigName}
ALL_rebuild
[DBG]_ALL_rebuild
[REL]_ALL_rebuild

ALL_clean

program_flash TARGET=${ConfigName}

Create the following generalised makefile with the TARGET as an argument:
1621553787427.png

The content of the TARGET is set to actual Eclipse's configuration name by selecting "build" or "rebuild" from Eclipse's Build Target list.
From now on the build command in Eclipse runs "build" task from above makefile.
It is the same with the clean command - it runs "ALL_clean" task from above makefile.
The rest tasks can be lunched from Build Target entries - IMHO most handful is a rebuild task (which is unfortunately missing in Eclipse).

Scripts and makefile needed for this solution are on gitlab:

There is a bunch of scripts that integrates Keil's toolchain.
It builds project and parses errors/warnings/infos into VSCode - that is what I wanted.

Usage:
1. Copy .vscode and Scripts folders from that repo into the root folder of your Keil's project (with Src, Inc and perhaps MDK-ARM subfolders);
2. Open root folder of your Keil's project by Open with Code context menu;
1621467519855.png


NOTE: If you are missing Open with Code option in Context Menu, then reinstall VSCode and make sure that you have checked these options:
1638921361777-png.173228


In VSCode:
3. Navigate to your Keil's project file (.uvproj or .uvprojx) and open it;
4. Hit F1 and start typing Run Build Task... Hit Enter and choose from the list Import settings from Keil's v4 or v5 project - that will import includes, defines and output paths for all project's targets from opened project file;
VSCode should look similar to the example below:
1638919803161-png.173218


After executing Import settings from Keil's v4 or v5 project task, terminal tab should look like as follows:
1638920109855-png.173220


Get back to STM32CubeIDE and build a project. You should get similar results as follows:
1621468157109.png

1621468133304.png


From that point if you prefer VSCode, it will also work.
1638920478154-png.173223


NOTE: It works because I prepared ".vscode/tasks.json" in a way that it calls proper scripts and parses build log for errors/warnings/infos - check out tasks.json file if you like.
1638920755277-png.173224

1638920872287-png.173225



Available features:
1638919342512-png.173217


Init:
  • Import settings from Keil's v4 or v5 project - imports includes, defines and output paths for all project's targets

Building:
  • Build by Keil - builds Keil's project for a chosen target
  • ALL build by Keil - builds Keil's project for all targets (make sure that all targets have different output paths in Keil's project)
  • [DBG] ALL build by Keil - builds Keil's project for all targets that name starts with "[DBG]..."
  • [REL] ALL build by Keil - builds Keil's project for all targets that name starts with "[REL]..."

Rebuilding:
  • Rebuild by Keil - rebuilds Keil's project for a chosen target
  • [DBG] ALL rebuild by Keil - rebuilds Keil's project for all targets that name starts with "[DBG]..."
  • [REL] ALL rebuild by Keil - rebuilds Keil's project for all targets that name starts with "[REL]..."
  • ALL rebuild by Keil - rebuilds Keil's project for all targets (make sure that all targets have different output paths in Keil's project)

Cleaning:
  • ALL clean by Keil - cleans Keil's output files for all targets

Programming:
  • Program Flash by Keil - downloads the application to Flash using Keil's settings of a chosen target and available programming device

Opening in Keil:
  • Open project in Keil - opens Keil's project in native IDE


Customisable summary in Python:

customisable_summary.png


Now the STM32CubeIDE project has the Keil's toolchain. You can also add a debug configuration, if you like.
For a debug configuration steps, see this blog entry.

I hope it was helpful for someone there.

------------------------------------------------------
Is this blog entry helpful or does it need an improvement?
Please leave the comment below.

Comments

There are no comments to display.

Part and Inventory Search

Blog entry information

Author
niciki
Read time
4 min read
Views
6,264
Last update

More entries in Uncategorized

More entries from niciki

Share this entry

Back
Top