What library or project generator to use for a first STM32F3 project?

2.1k Views Asked by At

I'm about to start my first STM32 project. (I have previously used atmega MCUs, and have decades of experience with C, mostly server-side.)

There seem to be three choices, given that I want to develop on the command-line in Linux, using make.

  1. an STM32CubeMX generated makefile project,
  2. an STM32CubeMX generated makefile project, including FreeRTOS, or
  3. a makefile project using libopencm3.

The application will process and send messages on 4 or more serial ports, using different protocols. Occasionally GPIOs will be set or cleared.

My questions are:

  • Why does libopencm3 exist? Why would someone choose it over an STM32CubeMX-generated makefile project.
  • Is learning FreeRTOS worthwhile for such a project?
2

There are 2 best solutions below

3
On BEST ANSWER

There are no good free project generation tools that I know. I worked mostly with STM32CubeMX and I can tell you that it's surely useful (expecially for novices) but long from being something you can trust on. I found lots of bugs in it in the years, some has been fixed, others are still in there. IMHO, in general, you should use code generator tool with care better as a training instrument maybe taking snippets of code out of them.

I've used FreeRTOS a lot and I can tell you I feel good with it. Maybe it's not good as as a commercial grade product but surely it's well documented and easy to handle. Haven't had any problem with it.

3
On

libopencm3 is an alternative to the STM32 HAL and CMSIS (discontinued). I have no experience with it but the HAL is quite useful.

FreeRTOS is great for creating programs with multiple processes which need to share resources in a time critical manner. It isn't necessary always but could be used in less demanding situations.

STM32CubeMX is, as damiano noted, useful but not something to depend on. It is best in my experience to create a base project in STM32CubeMX and then to disconnect it from the project. You then further add the HAL libraries you need manually and keep most of the real initialization and configuration in your own hands. I will however use it to create examples of how to initialize certain peripherals and libraries to then port it over to my own project.