CubeMX generated code

Hello, I recently started working with CubeMX, it’s very fancy tool to work with but Platform IO doesn’t like it that much. When I generate project using CubeMX, structure of project is a bit diffrent than usual PIO project. Actually it’s just one folder that make whole mess. When I complie genrerated code I get message that xxx.h and xxx.c etc. can’t be found. That’s because they’re in /Inc folder, when I throw everything to /src build process works perfect, seems that build process don’t look there. Any ideas how to solve such problem? I found something about custom build flags but I didn’t succeed.

1 Like

@LocoMatt you can manually convert project structure to match PlatformIO standards – see this topic. Or you can use my small Python3 utility to automate such process.

P.S. Actually, @ivankravets, can we somehow integrate this tool in PlatformIO CLI and/or IDE or give it a mention in docs? I don’t mean any self-promotion but people occasionally asks about CubeMX-PIO integration, so it might ease their work a little bit.

So actually I’m doing it like in first topic. Problem is when I modify CubeMX project and have to generate again my code. I have to play with dragin’ and dropin’ files between folders. I’d like to avoid such situations, especialy when project is done by many people. There should be some unification.

I’d love to see some kind of solution to work with PlatformIO and CubeMX, seems that’s not a big deal to make it real, but would do a good job.

You don’t have to actually use platformio infrastructure. When I use TouchGFX, I have to use the CubeMX, That’s what it generates.

Anyway, tell CubeMX to generate for GNU Makefile. It puts all the right directories in the include and link files. Open a command prompt and just type make. You will have to either copy the output to the micro-controller drive or use the st-link utility to upload it.

I’m not sure if you need to separately install the gcc for stm and make utility, as I do have them installed for other reasons. But they are freely available if the ones from platformio are not easily in your path.

I then just use the rest of the GUI to manage/edit the project.

Maybe the platformio people should take this approach (use the generated Makefile) when dealing with the CubeMX projects. it would make life a whole lot easier on people that are stuck maintaining CubeMX projects.

I solved my problem easy way. I just modify .ini file with (finally found out how to use build flags :P)

build_flags = -I Inc

So my .ini file looks like this

[env:env_name]
platform = ststm32
board = board_name
framework = stm32cube
build_flags = -I Inc