Skip to main content
Senior
Nov 21, 2023 6:22 PM UTC
Solved

Specify option bits in source code file

I am about to release firmware to production and would like to include the proper options bits in the firmware so that production can simply program the .elf file at the same time as updating the option bits.  I realize that there are several option bits that have to changed on a new MCU before my firmware will work.  But maybe the option bits would automatically get programmed first.

What is recommended way to handle initial programming of an MCU?

This topic has been closed for replies.
TDK
TDKBest answer
Nov 21, 2023 8:52 PM UTC

You can set option bytes and program the ELF in one go using the stm32cubeprogrammer CLI.

 

There's no way to tie them into your ELF directly, as far as I know.

You can check/set them within your program at startup, which has the same effect as long as the program gets run. Depends which option bytes you need, in particular.

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

4 replies

TDK
TDKBest answer
Nov 21, 2023 8:52 PM UTC

You can set option bytes and program the ELF in one go using the stm32cubeprogrammer CLI.

 

There's no way to tie them into your ELF directly, as far as I know.

You can check/set them within your program at startup, which has the same effect as long as the program gets run. Depends which option bytes you need, in particular.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Senior
Nov 21, 2023 9:37 PM UTC

My code requires use of the entire flash and the default option bits only allow 1/2 to be used, so I need to program the fuses before programming the code.  Is that possible from the stm32cubeprogrammer?

TDK
Nov 21, 2023 9:42 PM UTC

What chip are you using and what option byte needs set in order to use all of the flash? Only thing I can think of is STM32WB but there's good reason you can't use all of the flash there.

> Is that possible from the stm32cubeprogrammer?

Yes.

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