Skip to main content
eBirdman
Senior
July 10, 2018
Question

The best way to convert non-CubeMX project to STM32CubeMX ?

  • July 10, 2018
  • 1 reply
  • 1561 views
Posted on July 10, 2018 at 19:25

Hello, can somebody share the most efficient steps to convert non-MX project to a STM32CubeMX structured one? Most (or all?) of the Cube examples are not MX-generated hence they are not structured accordingly. So far my procedure has been : start from generating my board configuration main template, then manually bringing the code which I need from Cube examples. After the imported code works I test it in terms of ability to reconfigure in CubeMX and it breaks the compilation quite often . This requires painstakingly go through the code yet again making changes, sometimes even in the driver files.

Is there any documentation or a post on the best practice to convert a working code to STM32CubeMX generated project?

#stm32cubemx #code-migration
This topic has been closed for replies.

1 reply

Bogdan Golab
Lead
July 10, 2018
Posted on July 10, 2018 at 20:59

Everytime I buy new nucleo shield or discovery board I face the same problem: need to integrate the BSP drivers / examples manually:

https://community.st.com/0D50X00009XkYoaSAF

 

However the latest CubeMX version is able to pre-initialize MCU resources required by the particular ST board.

I tested this feature on several boards and mostly works fine (some older STM32L1 Discovery boards are wrongly pre-initialized and there are some resource conflicts). So you only needs to focus on the APP call flow (the drivers are pre-initialized by the CubeMX).

Once you select ST board you can accept the question about the board pre-initialization...

eBirdman
eBirdmanAuthor
Senior
July 11, 2018
Posted on July 11, 2018 at 05:09

Thank you Bogdan for your input. Following your post link I see that after configuring a new project for your MCU, you manually added new BSP drivers *.c and *.h to the project files and added them to the build configuration, then you add functions to the main().  I did similar steps for simple examples and it works but it was slow process. I&39ll need many functions to be added to a custom STM32 board.  Did you try to follow the 

Joly.Jeanne

recommendation to use the &39import&39 feature to import all the code from another example into your CubeMX pre-configured project (assuming that CubeMX generated all initialization routines for IOs and drivers you have chosen) ? I get errors. 

RomainR.
ST Employee
July 11, 2018
Posted on July 11, 2018 at 11:27

Hi Vlad,

Take a look to my tutorial that explains the concept of build variable and linked ressources under Eclipse environment (SW4STM32 or Atollic TrueStudio)

In order to not repeat the process for each project and save time, I use the following method:

I have a template project including BSP librarie even DSP lib if needed for a STM32 board (ex F7/F4 Discovery).

As all project files are linked on my local repo CubeMX except my source codes. I can then make a copy of my template project and implement the new code specific to my application.

https://community.st.com/0D50X00009bMM6aSAG

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.