Author Topic: STM32 Gotchas  (Read 2947 times)

0 Members and 1 Guest are viewing this topic.

Offline UnixonTopic starter

  • Frequent Contributor
  • **
  • Posts: 623
STM32 Gotchas
« on: March 10, 2026, 07:16:42 pm »
Found this few days ago, looks like something worth keeping. Other sections are also interesting.
http://www.efton.sk/STM32/gotcha/
 
The following users thanked this post: oPossum, AndyC_772, mikerj, neil555, tooki, MT, GromBeestje, I wanted a rude username, macafeeje

Online peter-h

  • Super Contributor
  • ***
  • Posts: 5819
  • Country: gb
  • Doing electronics since the 1960s...
Re: STM32 Gotchas
« Reply #1 on: March 10, 2026, 09:26:17 pm »
Yes, this excellent site is written by wek who drops in here occassionally. Very few people know more than he does about this stuff.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 
The following users thanked this post: Unixon, mikerj, tooki, macafeeje

Offline jnk0le

  • Regular Contributor
  • *
  • Posts: 189
  • Country: pl
Re: STM32 Gotchas
« Reply #2 on: March 10, 2026, 11:12:27 pm »
Missed one thing. Peripherals that were not mapped to GPIO are non functional and all regs read 0 (at least through debugger).
« Last Edit: March 11, 2026, 07:03:08 pm by jnk0le »
 

Online peter-h

  • Super Contributor
  • ***
  • Posts: 5819
  • Country: gb
  • Doing electronics since the 1960s...
Re: STM32 Gotchas
« Reply #3 on: March 11, 2026, 03:27:50 am »
Non functional when?
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 12321
  • Country: nz
Re: STM32 Gotchas
« Reply #4 on: March 11, 2026, 04:25:47 am »
Another one is that CAN and USB can't be used together in STM32F042 but can be in STM32F072.
It's not very obvious when reading the datasheets.
(It's to do with a shared RAM area on STM32F042)
Greek letter 'Psi' (not Pounds per Square Inch)
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17528
  • Country: fr
Re: STM32 Gotchas
« Reply #5 on: March 11, 2026, 05:37:28 pm »
Missed one thing. Peripherals that were not mapped to GPIO are non functional and all regs read 0 (at least through debugger).

Never saw that.
 

Offline jnk0le

  • Regular Contributor
  • *
  • Posts: 189
  • Country: pl
Re: STM32 Gotchas
« Reply #6 on: March 11, 2026, 07:02:53 pm »
ok, false positive. Must have been a breakpoint before RCC was initialized. But still remember that someone was talking that F103 spi can't be used for CRC without one GPIO mapped.
 

Online AndyC_772

  • Super Contributor
  • ***
  • Posts: 4545
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: STM32 Gotchas
« Reply #7 on: March 11, 2026, 08:05:43 pm »
Useful list, I've hit a few of these over the years.

My "favourite" ended up being:
On STM32F7, when QSPI and the Icache are both enabled, the core issues speculative fetches over QSPI on exit from interrupts, even when QSPI is not in memory mapped mode.

That was fun to track down.

I reported it on the ST forum and, IIRC, the ultimate resolution ended up being along the lines of "yeah, the cache is broken, don't use it"... !
 
The following users thanked this post: mikerj, MT

Online peter-h

  • Super Contributor
  • ***
  • Posts: 5819
  • Country: gb
  • Doing electronics since the 1960s...
Re: STM32 Gotchas
« Reply #8 on: March 11, 2026, 08:20:53 pm »
Quote
But still remember that someone was talking that F103 spi can't be used for CRC without one GPIO mapped.

Can you please explain what you mean, explicitly?

All (?) peripherals in 32F4 I am using are memory mapped.

Do you mean SPI does not work unless you beforehand configure at least one GPIO pin?
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline jnk0le

  • Regular Contributor
  • *
  • Posts: 189
  • Country: pl
Re: STM32 Gotchas
« Reply #9 on: March 11, 2026, 10:29:03 pm »
Do you mean SPI does not work unless you beforehand configure at least one GPIO pin?
as an alternate function for given peripheral.
 

Online peter-h

  • Super Contributor
  • ***
  • Posts: 5819
  • Country: gb
  • Doing electronics since the 1960s...
Re: STM32 Gotchas
« Reply #10 on: March 12, 2026, 07:11:49 am »
Do you mean e.g. SPI registers are not readable until you have assigned a GPIO pin for the SPI?
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline jnk0le

  • Regular Contributor
  • *
  • Posts: 189
  • Country: pl
Re: STM32 Gotchas
« Reply #11 on: March 12, 2026, 11:42:58 pm »
something like "SPI can't be abused for its CRC until one of MOSI/MISO/SCK was mapped to a gpio". That was long time ago though.
 

Offline rf-fil

  • Regular Contributor
  • *
  • Posts: 115
  • Country: au
    • VK2ZJ at QRZ
Re: STM32 Gotchas
« Reply #12 on: March 13, 2026, 01:33:21 am »
Another one: WKUP pins require external pull-up / pull-down resistors. The WKUP / GPIO multiplexer is ahead of the GPIO peripheral, so none of the GPIO "settings", including internal pull-up/down resistors, apply when a pin is configured in WKUP mode.

(Also, only certain pins can be configured to wake-up mode, but that's not really a gotcha.)
« Last Edit: June 15, 2026, 12:25:43 am by rf-fil »
-VK2ZJ
 
The following users thanked this post: voltsandjolts, mikerj

Online peter-h

  • Super Contributor
  • ***
  • Posts: 5819
  • Country: gb
  • Doing electronics since the 1960s...
Re: STM32 Gotchas
« Reply #13 on: March 13, 2026, 12:13:27 pm »
Quote
"SPI can't be abused for its CRC until one of MOSI/MISO/SCK was mapped to a gpio".

If this is a real bug then I don't expect many to have come across it because SPI with CRC is extremely rare.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline Geofrey

  • Contributor
  • Posts: 16
  • Country: fr
Re: STM32 Gotchas
« Reply #14 on: March 14, 2026, 09:07:17 pm »
Another one: WKUP pins require external pull-up / pull-down resistors. The WKUP / GPIO multiplexer is ahead of the GPIO peripheral, so none of the GPIO "settings", including internal pull-up/down resistors, apply when a pin is configured in WKUP mode.

(Also, only certain pins can be configured to wake-up mode, but that's not really a gotcha.)
From my own experience, not on C0s and G0s. Though the regular GPIO pull-up/down is indeed not working, there is a dedicated setting in the PWR registers. Probably the same for other series
 
The following users thanked this post: rf-fil

Offline wek

  • Frequent Contributor
  • **
  • Posts: 591
  • Country: sk
Re: STM32 Gotchas
« Reply #15 on: March 22, 2026, 10:34:30 am »
Thanks all for the kind words :-)

In the past few weeks, I heard mentions of the list from several unrelated sides. Maybe related to AI - I see frantic scraping in the logs. One of the mentions characterized the site as incredibly ugly - I understand that but I am also not going to change that.

And thanks for the additional gotchas. Some of them are already in the pipeline. The schedule is one gotcha per week; some of them are still waiting since the beginning as I tend to work on those I like at the moment...  Also, some are personal experiences and of course I prioritize those even if they don't have a wide appeal. There are one or two which were in fact written by others (credited of course), sent in by e-mail usually, I tend to push them forward, too.

Then there are some which are related to a wider range of problems (e.g. pins affected by bootloader, mainly in relationship with the "pristine chip goes to bootloader" property of some families; gotchas (and outright bugs) related to the insane complexity of speculative fetch/execution, caches, "security" features of the newer ARM cores, etc.) and I may need to do some research to avoid misinformation (yes there are many and I try to correct them as I learn about them). Time and energy is limited, though. I have work to do to pay the checks.

> something like "SPI can't be abused for its CRC until one of MOSI/MISO/SCK was mapped to a gpio"

This is probably consequence of "there's no Rx without clock being actually brought out to pin, even if master". Example of one which is in the pipeline since beginning. It's probably SPIv1-specific (i.e. 'F0/'L1/'F2/'F4), I haven't tried above and haven't seen anybody reporting.

> WKUP pins require external pull-up / pull-down resistors

I believe there are several different arrangements for this in the various STM32 families. Low-power-related issues are generally surprisingly complicated and I have little personal experience with them so I tend to avoid writing about them, although there appear to be a wealth of gotchas in that area, too.

JW
 
The following users thanked this post: peter-h, mikerj, newbrain, I wanted a rude username, harerod, jnk0le, macafeeje

Offline UnixonTopic starter

  • Frequent Contributor
  • **
  • Posts: 623
Re: STM32 Gotchas
« Reply #16 on: March 22, 2026, 08:07:32 pm »
Thanks all for the kind words :-)
In the past few weeks, I heard mentions of the list from several unrelated sides. Maybe related to AI - I see frantic scraping in the logs.
One of these scrapers was probably me backing up the entire thing ;D
Your site it a treasure and it must be preserved.  :-+
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 15544
  • Country: ch
Re: STM32 Gotchas
« Reply #17 on: March 22, 2026, 10:55:21 pm »
Thanks all for the kind words :-)

In the past few weeks, I heard mentions of the list from several unrelated sides. Maybe related to AI - I see frantic scraping in the logs. One of the mentions characterized the site as incredibly ugly - I understand that but I am also not going to change that.
But it’s highly functional and fast. I much prefer that to some modern, slow site that uses 90% of the screen for white space.
 

Offline az1

  • Contributor
  • Posts: 44
  • Country: us
Re: STM32 Gotchas
« Reply #18 on: March 22, 2026, 11:50:04 pm »
Thanks all for the kind words :-)
In the past few weeks, I heard mentions of the list from several unrelated sides. Maybe related to AI - I see frantic scraping in the logs.
One of these scrapers was probably me backing up the entire thing ;D
Your site it a treasure and it must be preserved.  :-+

That's what the Internet Archive is for, and unlike AI slop scrapers it's well behaved.
 

Offline eTobey

  • Super Contributor
  • ***
  • Posts: 1573
  • Country: de
  • Virtual Features for the SDS800XHD -> My website
    • Virtual feature script
Re: STM32 Gotchas
« Reply #19 on: March 31, 2026, 06:15:15 pm »
...
One of the mentions characterized the site as incredibly ugly...
The best thing about this ugliness:
Nothing is faster. And you can read it with a 25 year old browser! Or even older...
"Sometimes, after talking with a person, you want to pet a dog, wave at a monkey, and take off your hat to an elephant."(Maxim Gorki)

Siglent SDS800X HD bugs/issues/workarounds (Partially updated 3. Mar 2026)
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 591
  • Country: sk
Re: STM32 Gotchas
« Reply #20 on: June 13, 2026, 08:53:07 am »
Another one: WKUP pins require external pull-up / pull-down resistors. The WKUP / GPIO multiplexer is ahead of the GPIO peripheral, so none of the GPIO "settings", including internal pull-up/down resistors, apply when a pin is configured in WKUP mode.

(Also, only certain pins can be configured to wake-up mode, but that's not really a gotcha.)
In which STM32?

I just went through a bunch of RMs, and found that
- in older models ('Fxx, 'L0) enabling the WKUP pins in PWR_CSR.EWUPx results in forced in input pull down configuration
- in 'L4, 'Uxx, 'Gxx, 'C0, all pins' pullups and pulldowns can be set independently from GPIO by PWR_PUCRx/PWR_PDCRx (where x=A, B, C...), if PWR_CR3.APC is set; these settings are valid also for Standby and Shutdown, see Functionalities depending on the working mode table
- in 'H5 and 'H7, there is a register (called inexplicably differently, in 'H5 it's PWR_WUCR and in 'H7 PWR_WKUPEPR) which contain the WKUP enable, polarity and pullup-pulldown setting bits

I may have overlooked something, and also I haven't tried all of these, so maybe there is some model where WKUP pins do need externall pullups; please tell what was your setup.

JW
 

Offline rf-fil

  • Regular Contributor
  • *
  • Posts: 115
  • Country: au
    • VK2ZJ at QRZ
Re: STM32 Gotchas
« Reply #21 on: June 15, 2026, 12:27:11 am »
Another one: WKUP pins require external pull-up / pull-down resistors. The WKUP / GPIO multiplexer is ahead of the GPIO peripheral, so none of the GPIO "settings", including internal pull-up/down resistors, apply when a pin is configured in WKUP mode.

(Also, only certain pins can be configured to wake-up mode, but that's not really a gotcha.)
In which STM32?

I just went through a bunch of RMs, and found that
- in older models ('Fxx, 'L0) enabling the WKUP pins in PWR_CSR.EWUPx results in forced in input pull down configuration
- in 'L4, 'Uxx, 'Gxx, 'C0, all pins' pullups and pulldowns can be set independently from GPIO by PWR_PUCRx/PWR_PDCRx (where x=A, B, C...), if PWR_CR3.APC is set; these settings are valid also for Standby and Shutdown, see Functionalities depending on the working mode table
- in 'H5 and 'H7, there is a register (called inexplicably differently, in 'H5 it's PWR_WUCR and in 'H7 PWR_WKUPEPR) which contain the WKUP enable, polarity and pullup-pulldown setting bits

I may have overlooked something, and also I haven't tried all of these, so maybe there is some model where WKUP pins do need externall pullups; please tell what was your setup.

JW

You guys are right.. I guess the underlying gotcha is "RTFM".. which is about 5000 pages long...
-VK2ZJ
 
The following users thanked this post: wek

Offline wek

  • Frequent Contributor
  • **
  • Posts: 591
  • Country: sk
Re: STM32 Gotchas
« Reply #22 on: June 16, 2026, 09:33:43 am »
Thanks for the explanation.

I am painfully aware of the fact that it's 5000 pages, and quite often not even as a single document at a single website.
 

Offline Ground_Loop

  • Frequent Contributor
  • **
  • Posts: 710
  • Country: us
Re: STM32 Gotchas
« Reply #23 on: June 18, 2026, 03:21:56 am »
I didn't read through the whole list, but boot0 tied me up for a couple days on a recent STM project.
There's no point getting old if you don't have stories.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17528
  • Country: fr
Re: STM32 Gotchas
« Reply #24 on: June 18, 2026, 12:45:00 pm »
I never ran into this BOOT0 thing (requiring also BOOT1 to be pulled down too) as I haven't used the affected families, but I've run into another obvious BOOT0 issue not long ago on a STM32U5.

Not a gotcha, an obvious mistake in retrospect, but just something you should be careful with: I forgot to pull down the BOOT0 pin (mostly due to the fact this is a shared pin on the package I was using and BOOT0 didn't appear on the schematic symbol I used, so I just forgot about it). If left floating, it may boot to the internal bootloader randomly. In my case, it was doing it systematically. Since I didn't plan to use the internal bootloader at all, I just flashed options bytes to force booting to flash.

Just a silly mistake but be careful when using ready-made symbols, when special-function pins are not explicitely marked, they become easy to miss.
 
The following users thanked this post: Dazed_N_Confused


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf