I've implemented a faster way to automatically import a CubeMX project into an Eclipse tool-chain based on the GNU ARM Plugin. It's a bare-bone python script that simply "translates" a CubeMX project for the SW4STM32 (aka AC6 - OpenSTM32.org) tool-chain in a project generated with the GNU ARM Eclipse plugin. The script can be downloaded from my github account. Let's see how this works.
First of all, we have to generate a new Eclipse project using the GNU ARM Plugin. Go to File->New->C Project and select "Hello World ARM Cortex-M C/C++ project". You can choose the project name you want. Click on “Next“. Here we assume "test1" as Eclipse project name.
In the next step you have to configure your microcontroller. For example, for a STM32-F4 you have to choose Cortex-M4 core, while for a STM32-F0 you have to choose Cortex-M0. The Clock, Flash size and RAM parameters depend on your MCU. For example, for a STM32F401RE you can use the same values shown in the following picture. Set the other options according your needs.If you are using a Nucleo, this table shows the right values for all Nucleo boards.
In the next step leave all parameters unchanged except for the last one: Vendor CMSIS name. Change it from DEVICE to stm32f4xx if you have a STM32F4 based board, or stm32f1xx for F1 boards, and so on. Please, be sure to use this pattern, otherwise the script simply doesn't work.
Click on “Next“. You can leave the default parameters in the next steps. After a while, Eclipse will generate a new project for you. Now, click on the project root in the Project Explorer view and click on "Close Project" entry.
Now, use the STM32CubeMX tool to configure your MCU according your needs. When finished, click on the Project->Generate code menu. In the Project Settings dialog give the name you want to the project and select an output directory where store the project. Here we assume that the CubeMX project name is "mymcu". Choose SW4STM32 as Toolchain/IDE (this is really important, to not skip this step) and generate the code.
Finally, to use the tool I've made, you can easily type the following command at terminal prompt:
$ python cubemximporter.py <path-to-eclipse-workspace>/test1 <path-to-cubemx-out>/mymcu
When finished, open the project "test1" in Eclipse, click with the right mouse button on the project root and choose "Refresh" (this will force the scan of the source tree, since it has been changed while the Eclipse project was closed). Finished. Don't forget to update the file mem.ld, changing the FLASH origin address from 0x00000000 to 0x08000000.
The script now supports also the import of Middleware libraries (FatFS, FreeRTOS, LwIP).
The script is designed to work both in Python 2.7 and 3.x. It requires the lxml library.
Windows users can download a pre-compiled lxml package directly from here:
Linux and MacOS X users can install lxml using pip:
$ pip install lxml
Please, let me know if it worked for you.