Skip to main content
BRodr.3
Associate
April 26, 2021
Question

Import from Keil MDK into STMCubeIDE

  • April 26, 2021
  • 6 replies
  • 14637 views

Hello,

I have been trying to import an already-existing project into CubeIDE. This project was created on Keil MDK. So, when I import the project, CubeIDE does not recognize the drivers for the board I am program, nor the source files. How can I use the project on CubeIDE?

Any insight is appreciated

Thank you.

This topic has been closed for replies.

6 replies

Cartu38 OpenDev
Graduate II
April 26, 2021

Is your Keil project based on STM32CubeMX (.ioc file) ?

BRodr.3
BRodr.3Author
Associate
April 26, 2021

Hi,

No, it has no .ioc file. I have all .h and .c files, which include drivers and middlewares. Is there a way of importing?

Thanks

Cartu38 OpenDev
Graduate II
April 26, 2021

If no .ioc move to STM32CubeIDE is fully doable but will require you to invest a bit.

I foresee various options:

1) Let's create a brand new STM32CubeIDE so called "Empty": File > New > STM32Cube Project

0693W00000AMZf8QAH.jpgThen up to you to copy / paste your .c/.h files and add proper setups to get a build running (defines, includes, ...) based on project properties

0693W00000AMZfDQAX.jpg 

Or have a ty to import a "pre"-set project you can get from FW pack. File > Open Project From File System

0693W00000AMZgBQAX.jpgNote: Select your serie and board you need

Then still up to you to copy / paste your .c/.h files and add proper setups to get a build running (defines, includes, ...) based on project properties BUT already all drivers dependencies and setup should be available to you

BRodr.3
BRodr.3Author
Associate
May 8, 2021

Hi @Cartu38 OpenDev​,

I have been trying to create my new project on STMCubeIDE from an empty project as suggested (copy-paste of source files) but it looks like some files are not recognizable by STMCubeIDE or even missing (the files do exist actually in the folder). Moreover, I am not working with commercial board.

Do you know if there is any way to use the existing uvprojx and uvoptx files into STMCudeIDE?

Thanks for your help

Regards.

Pavel A.
May 8, 2021

If I remember correctly, Keil can create sort of makefile for MDK projects.

CubeIDE then can import a makefile-based project.

You'll need to provide assembly startup file , linker script and some C library stub files instead of Keil-specific files.

If this sounds complicated, find a consultant/contractor to help.

--pa

BRodr.3
BRodr.3Author
Associate
August 19, 2021

Hello,

I have some questions. I have been reading on how the projects are structured on both STM32CubeIDE and Keil MDK.

I believe that I have found a manner to deal with the importing process from Keil MDK to STMCubeIDE, which is:

On Keil MDK, the *.uvprojx file contains the project structure in XML format; such a file also contains the compilation/linking flags and these are IDE-dependent. So, what is useful for me are the source files. Furthermore, since I have the scatter file *.sct (this describes the memory layout; STM32CubeIDE does not support such files) created on Keil, I can use it to write a linker file *.ld on STM32CubeIDE.

In addition, I have the startup code written in assembler *.s and it is my understanding that I have to modify it according to my project since this is IDE-dependent. STM32CubeIDE is capable of creating the makefile automatically. However, I also must work on it; specifically, I have to modify the compilation and linking flags.

I already have the linker script *.ld describing the memory layout.

These points are not clear to me:

  1. STM32CubeIDE is equipped with GNU ARM Embedded and GNU for STM32 toolchains, which one should I use to then? When I work on the makefile, the compilation and linking flags, and target and debugger configuration should follow such a toolchain
  2. Can I avoid having a *.ioc file and still have a working project?
  3. I can start off a empty project, but I do not see how its structure should be, which folder should contain what?
  4. I have all object files created on Keil. So can I use them to first have a working linker script? I am not sure if these are compatible with STM32CubeIDE.

Thank you for your support.

Regards.

Tesla DeLorean
Guru
August 19, 2021

Cube provides for different startup.s files under the CMSIS\Device trees

Keil's linker creates a scatter list for the content that needs initializing and the scatter loader is called via __main, with SystemInit called first to bring up external memories, clocks, etc.

ST's GNU implementation has a far cruder initialization method using a bodge of symbols to convey source/destination locations and sizes.

Perhaps look towards how Arduino did this as they build a tabular initialization method closer to that used by Keil.

The .ELF/.AXF/.O/.A are all sufficiently similar that they might bind, but more often than not it is other dependencies or libraries, or intrinsics (memcpy, memset, floating point, etc) that break the linker. In porting objects you might need some "wedge" functions that map the differences, either pointing at the right symbol, or implementing enough functionality to allow it to work. This can be further complicated by floating point methods and hard/soft FPU ABI choices and flagging within the objects. Sometimes it's worth the bother, others it is not. When it gets to the "impossible, but necessary" stage there are often other approaches.

It's a pretty sad indictment of a tool vendor that they can't import from a text or XML based project file of a competitive product directly.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Pavel A.
August 19, 2021

> I have the startup code written in assembler *.s and it is my understanding that I have to modify it according to my project since this is IDE-dependent. 

Correct

> STM32CubeIDE is capable of creating the makefile automatically.

Yes, the latest version 1.7 can create a makefile-type project from existing files.

To your questions:

1 - start with the STM32 toolchain, unless you must use generic ARM toolchain.

2 - yes

3 - Create a minimal project or import an example, then delete all unneeded files.

For a single-core processor (most of the models) all sources can just be in one flat directory.

4 - no

--pa

BRodr.3
BRodr.3Author
Associate
August 27, 2021

Hi,

After struggling a bit with importing my project from MDK Keil, I have been able to load and compile it into STM32CubeIDE. Now, I am debugging my code but I get the following error:

STMicroelectronics ST-LINK GDB server. Version 5.8.0

Copyright (c) 2020, STMicroelectronics. All rights reserved.

Starting server with the following options:

    Persistent Mode      : Disabled

    Logging Level       : 1

    Listen Port Number     : 61234

    Status Refresh Delay    : 15s

    Verbose Mode        : Disabled

    SWD Debug         : Enabled

    InitWhile         : Enabled

Waiting for debugger connection...

Debugger connected

   -------------------------------------------------------------------

            STM32CubeProgrammer v2.7.0-RC1          

   -------------------------------------------------------------------

ST-LINK SN : 36FF6C064D59303630542543

ST-LINK FW : V2J37S7

Board    : --

Voltage   : 3.24V

SWD freq  : 4000 KHz

Connect mode: Under Reset

Reset mode : Hardware reset

Device ID  : 0x436

Revision ID : Rev X

Device name : STM32L15xxD/STM32L162xD

Flash size : 128 KBytes (default)

Device type : MCU

Device CPU : Cortex-M3

Memory Programming ...

Opening and parsing file: ST-LINK_GDB_server_Ou8nm0.srec

 File     : ST-LINK_GDB_server_Ou8nm0.srec

 Size     : 203541 Bytes

 Address    : 0x08000000 

Erasing memory corresponding to segment 0:

Error: Operation exceeds memory limits

Error: failed to erase memory

Encountered Error when opening /opt/st/stm32cubeide_1.6.1_2/plugins/com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.linux64_1.6.0.202101291314/tools/bin/STM32_Programmer_CLI

Error in STM32CubeProgrammer

Debugger connection lost.

Shutting down...

According to the datasheet, the flash memory is 348 KB (such a value is also in the linker file) but the STM32CubeProgrammer states that the Flash size is 128KB. I have already updated the St-link v2 debugger.

Does anybody know how I can fix this? The micro-controller I am working with belongs to the family STM32L152xD (precisely STM32L152VDT6)

Thank you for your help.

Regards.

LaurentL
ST Employee
August 30, 2021

Hi,

Give a try with STM32CubeIde 1.7.0, it has the latest STM32CubeProgrammer (v2.8.0) hopefully fixing this issue.

Rgds,

Laurent

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
BRodr.3
BRodr.3Author
Associate
August 30, 2021

Hi @LaurentL​ ,

I have updated STM32CubeIDe to 1.7.0 and STM32CubeProgrammer to v2.8.0 but the same problem remains. I have tried using different reset behaviors with no success. Furthermore, I checked the linker script and there is is stated that:

MEMORY

{

 RAM  (xrw)  : ORIGIN = 0x20000000,  LENGTH = 48K

 FLASH  (rx)  : ORIGIN = 0x8000000,  LENGTH = 384K

}

Any insight on how I can work this out? Can this problem be related to the initialization files too?

Thank you.

Regards.

LaurentL
ST Employee
August 30, 2021

It seems to be an STM32CubeProgrammer issue.

Try with Openocd gdb server (in debugger tab of Debug config), it doesn't use STM32CubeProgrammer.

Rgds,

Laurent

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.