Skip to main content
SHobb.1
Associate III
May 18, 2022
Question

What is the best IDE / tool chain for an STM32 rookie?

  • May 18, 2022
  • 15 replies
  • 9814 views

My background is in hardware, but I have extensive experience writing "bare metal" code (C) for 8-bit MCUs, mostly for AVRs. In the past, I have used AVR Studio (now Microchip Studio), starting with version 4.18 down to present versions. Tool chain was avr-gcc, followed by whatever Atmel eventually wrote and integrated into their later IDEs. I am starting a few new projects built around STM32G071 chips. While waiting for hardware, I am trying to come up to speed with software creation using a NUCLEO-F103RB. My end application (for now) requires interfacing to another MCU and controlling a BLDC motor.

This is my first foray into 32 bit MCUs and ARM. What is the best IDE/tool chain for me to use? My head is currently spinning with options. I have looked at STM32CubeIDE, but have read horror stories online about deleted code, etc. I have also read about Keil and IAR. I am reasonably familiar with makefiles, but would like to avoid a pure command line/script/text editor approach, and would prefer a more integrated solution (something similar to Atmel Studio with editably makefiles). Due to my hardware background, my coding style is to be as close to the hardware as possible (configuring peripherals by manually setting registers, etc.). Does this impact my choice? Should I use CMSIS or HAL (not sure how...)?

Any advice would be greatly appreciated.

This topic has been closed for replies.

15 replies

TSosi.1
Associate III
May 18, 2022

We use IAR 9.20. Our hardware engineer is ok with it too. The CubeMx, from ST, output compiles without any problem. Make sure you check out CubeMx. The code generated is used for board setup and clock configuration.

Tesla DeLorean
Guru
May 18, 2022

From a just works perspective perhaps Keil. IAR seems to be a moving target.

Cube can be an issue if you keep using the auto-gen tools, and then modify/add code, or changing versions and the .IOC format changes, evolves, or fixes bugs in ways that aren't tolerant or backward compatible..

CMSIS directs how things are done in a consistent manner across platforms. HAL honestly is a bit bloated and awkward. You can use things interchangeably, so you can uses register level code, or replace HAL implementations you don't care for. To get things working quickly use the libraries, once you have the mechanics down, refactor things that bog down the CPU.

ARM architectures tend to favour structures for peripherals as they tend to have duplicative instances, and these live sparsely within the normal addressable memory space of the processor. If you're comfortable with register level code, and willing to put the time in on the reference manuals, go for it.

A lot of register level code people post here tends to be very inefficient, the compiler will NOT fold repeated RMW interactions on volatile memory. Speed and efficiency is achieved by writing the code properly, and code size by using subroutines and loops to do repetitive tasks.

Using GNU/GCC and Make is certainly possible.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Nikita91
Lead II
May 18, 2022

Few years ago I was a STM32 rookie... Here is my opinion:

STM32CubeIDE is a reliable tool and works well. What is less reliable is CubeMX.

You don't have to use CubeMX. You can create a native Eclipse project with CubeIDE. What I appreciate is that there is never any need to worry about makefile (I know, some would say it's bad...)

STM32CubeIDE is generic, and does not require the use of CMSIS, HAL or anything else. What I often do is start from a CubeMX project (mainly to get the clock configuration code), then never regenerate it. Once a CubeMX project works, it is not guaranteed that rebuilding with 1 or 2 versions of Cube Mx later will not introduce bugs. That's certainly what you're referring to.

If you're comfortable using registers, that's best. Create your own library adapted to your specific needs. But the STM32 is much more complicated than an AVR, expect to read the reference manual and the datasheet several times! And reading the LL or HAL code in informative.

A note about using F103 while waiting for a G071. The F103 is very old (it's the 1st STM32!), while the G071 is recent. Most peripherals are different, so you won't be able to recover much at the registry level.

Pavel A.
May 18, 2022

@SHobb.1​ If you are used to the modern Microchip Studio (based on Microsoft Visual Studio), consider Visual GDB.

If you are familiar with Eclipse-based IDEs, then CubeIDE can be good for you.

Remember that debugger is the most important part of the IDE. There are a lot of editors, but a good debugger makes your day (and bad debugger ruins the day).

Keil's debugger is a good one, the rest of it is so-so.

SHobb.1
SHobb.1Author
Associate III
May 18, 2022

Thanks for the responses. A few follow-ups:

  1. What is the distinction between STM32CubeIDE and CubeMX?
  2. Why is clock configuration / reset code tricky to write (i.e., why generate it with an extra tool)?
  3. Will Visual GDB run with Visual Studio Community (Free)?
Tesla DeLorean
Guru
May 18, 2022

Micro-Xplorer was the original pin fitter and initialization code tool

CubeMX is/was the auto-gen code generator across platforms.

CubeIDE is ST's vision on an IDE where the generation has been more tightly integrated with the compiler, debugger, editor, etc.

At least that's my understanding of it.

If you're comfortable with registers, you're probably not in the "monkey flips the switch" crowd.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Piranha
Principal III
May 18, 2022
waclawek.jan
Super User
May 19, 2022

@SHobb.1​ ,

using the prechewed material and clicking is a rapid path to a few selected applications. Learning proper programming takes somewhat more effort and time, which more than pays off in the long term, if you mean programming seriously.

There are many which stuck halfway through, giving up to the calling of the easy way initially, and then unable to get rid of it after they found out it's a trap.

Unfortunately, ST refuses to make proper examples, so that's one half-valid reason for going the "libraries" and clicky way.

I despise also the IDEs because IMO the added complexity does not return enough value, and they work hard to lock you in. OTOH, getting a debugger (by which I mean a tool which allows to to stop, single-step and observe internal registers and memories) working makes all the difference; question is, whether the extra fluff with comes with this in IDEs is worth it. I personally struggle with any other than my personally preferred editor, so I went the extra mile (honestly, it was more like extra 30 yards) to learn to use naked gdb.

YMMV.

But start with reading the RM - RM0008 even has a guideline which chapters are the necessary ones, generally up to interrupts - and ask here if you got stuck. As mentioned, 'F103 are ancient and the GPIO there is very different from other families' and honestly it's a PITA, so try to spend as little attention to it as possible. Then write your first program, a loopdelay blinky, again ask here if stuck. Then try to proceed towards more complex stuff.

@Nikita91​ ,

> I don't think a beginner can configure an STM32 from scratch thinking about all the subtleties:

> FLASH latency, setting Range Boost Mode

None of this is a prerequisite for a beginner to start programming a blinky. There are other things, though, e.g. that clock has to be enabled for almost each module, but those he needs to learn anyway (unless he desires to remain in the clicking domain forever).

> intermediate system frequency when the target frequency is over 80 MHz, etc.

Where is that one needed? (This is a honestly curious question - I am constantly seeking material for my gotchas.) If so, isn't it described clearly enough in RM? Isn't reading RM the BASIC prerequisite for anything but the clicking?

> None of this is intuitive.

Depending on the definition of "intuitive", nothing, absolutely nothing of mcu programming is intuitive.

JW

Nikita91
Lead II
May 19, 2022

@Community member​ 

The sysclock switching with transition state is explained in G4 RM0440 in the chapter "7.2.7 System clock (SYSCLK) selection"

What intrigues me in this explanation is that ST says "it is recommended to use a transition state". If it's not mandatory why mention it?

When in doubt I do...

I agree reading RM is the basic prerequisite even for a "clicker". But in my opinion it is still common to forget to write a detail, even for someone experienced.

waclawek.jan
Super User
May 19, 2022

> The sysclock switching with transition state is explained in G4 RM0440 in the chapter "7.2.7 System clock (SYSCLK) selection"

Thanks.

Jan

waclawek.jan
Super User
May 19, 2022

> But in my opinion it is still common to forget to write a detail, even for someone experienced.

Yes it is. This is why appnotes and examples are important. There are no decent examples from ST and appnotes are very scarce and not very good. ST believes in selling "solutions" rather than decent chips with decent support, and that will be their demise in the long term.

That is still no excuse for using the clicky and "libraries", though. You always can read the "libraries" and use it as inspiration (positively or negatively). In particular, the clock setup routine was a disaster throughout the SPL era and quite a few years of Cube/HAL, too. It still does nonsense like rewriting the RC oscillators' trims, and we've complained here a lot.

It's your leg. It hurts the same whether the shooter was you or somebody else; but the latter is IMO psychologically more devastating.

JW

SHobb.1
SHobb.1Author
Associate III
May 19, 2022

Thank you for all the advice/comments. I think I will start with Visual Studio with Visual GDB, and try to go the straight register route. Coming from an FPGA background, I hope my familiarity with setting up clock domains, plls, etc. will translate somewhat to enable me to do the register approach. I really would like to avoid the "clicky solutions". Look for future posts from me as I try to work through some Hello World and blinky LED projects.

Also: thanks for the heads up on the age of the MCU on the Nucleo I have. I found some NUCLEO-G071RB in stock at Mouser, and ordered one for developing on. No need to make things harder than they need to be...