Skip to main content
Brian H
Senior
January 27, 2025
Solved

Recommended Practice for Programming Option Bits in Production

  • January 27, 2025
  • 1 reply
  • 1010 views

I have a project that uses the nBOOT pin for GPIO output and cannot pull it in any direction during POR.  Therefore, the nSWBOOT0 bit needs to be programmed to 0 (its default is 1) before the code will function properly.

What is the recommended practice for programming option bits in a production environment?

I can't rely on, e.g., someone digging through menus in CubeProgrammer for each unit.

I could have my code test for the proper bits at startup and program them if needed (the accepted answer to this similar question), but that does not strike me as an ideal solution because:

  1. It's wasteful (permanent code in the firmware that only operates once in the device's lifetime)
  2. With nBOOT floating at boot, device behavior is unpredictable before nSWBOOT0 is programmed

Is there perhaps some sort of automation available in CubeProgrammer that would require minimal user interaction?

This topic has been closed for replies.
Best answer by TDK

Use a script that runs STM32CubeProgrammer CLI to change the option bytes, program the device, and verify in a single statement.

1 reply

TDK
TDKBest answer
January 27, 2025

Use a script that runs STM32CubeProgrammer CLI to change the option bytes, program the device, and verify in a single statement.

"If you feel a post has answered your question, please click ""Accept as Solution""."