Embedded
Documentation

Version Latest

STM32 option bytes, bootloader and external flash

Reading and writing STM32 option bytes behind a confirmation, programming a sealed unit through the STM32 system bootloader over UART or USB DFU, and writing external QSPI or OSPI flash with STM32CubeProgrammer external loaders.

These functions replace the STM32CubeProgrammer window for daily work. They drive STM32CubeProgrammer's command line, STM32_Programmer_CLI, from your installation.

Verification state: no option byte read or write, bootloader programming or external flash programming of this module has run on a board. The parsers and command lines are unit-tested; the stm32cubeprogrammer kit (which only reads option bytes, never writes them) waits for its first report.

Option bytes

Read Option Bytes opens the Option Bytes editor with the connected STM32's read-out protection (RDP), write protection per sector, brown-out level and user options. Change a value in the editor, then run Write Option Bytes: a confirmation states the consequence of each change, such as raising read-out protection, and nothing is written until you accept it.

BackendReadWrite
STM32CubeProgrammer (first)-ob displ-ob NAME=value
OpenOCD's stm32f2x driver (second), for STM32F2, F4 and F7FLASH_OPTCR through mdw, options_readoptions_write, lock, unlock, flash protect

Field layouts come from the tool's listing and the device's SVD file. A field the SVD file does not describe stays read-only. Other devices and probes say "not supported for this device".

State: parsers tested on STM32CubeProgrammer listings and write results published by ST's community and Blues (STM32L4R5, STM32H7, STM32WL, STM32L5), and the OpenOCD read on output composed from OpenOCD's format strings. Kit shipped for reads (stm32cubeprogrammer); writes modelled. No read or write on a board.

Program through the STM32 system bootloader

Program Through STM32 Bootloader (UART or USB DFU)... updates a sealed unit through its service port, without SWD access:

  1. Choose the bootloader port: a serial port (-c port=COMn br=<baud>) or a USB DFU device (port=usbN). The baud rate is neuralInverse.embedded.stm32Bootloader.baudRate (default 115200).
  2. The device is identified through the bootloader.
  3. A confirmation names the port, the device and the image with its SHA-256.
  4. The image is programmed. An image that changed after the confirmation is refused. Option bytes are not written.

The confirmation before programming through the STM32 system bootloader over UART, with the port, device, image and SHA-256.The confirmation before programming through the STM32 system bootloader over UART, with the port, device, image and SHA-256.

State: command lines, confirmations and the image-change refusal unit-tested; the dialogs used in the running app with a stand-in CLI. Kit shipped (stm32cubeprogrammer). Not yet run against STM32CubeProgrammer, an ST-LINK or a board; br= and the bootloader's output are unverified.

Program external flash

Program External Flash (STM32CubeProgrammer External Loader)... writes an image into external flash, such as the QSPI flash holding a motor's tables, with STM32CubeProgrammer's -el <loader>.stldr:

  1. Choose the external loader. Loaders in the project and in STM32CubeProgrammer's ExternalLoader folder are listed; neuralInverse.embedded.stm32Programmer.externalLoader names the one listed first.
  2. Choose the image.
  3. A confirmation names the external memory and its address range (read from the loader's own memory description), the loader, the probe, the image and its SHA-256, and what STM32CubeProgrammer will do.
  4. An image outside the loader's memory range is refused, as is an image that changed after the confirmation.

Choosing the STM32CubeProgrammer external loader for the external flash, from the project and the ExternalLoader folder.Choosing the STM32CubeProgrammer external loader for the external flash, from the project and the ExternalLoader folder.

State: command lines, confirmations and the range check unit-tested; loader memory descriptions read from files laid out by arm-none-eabi-gcc 13.2.1. Kit shipped (stm32cubeprogrammer). Not yet run against STM32CubeProgrammer, an ST-LINK or a board.

Agents

Agents can list bootloader ports and external loaders, read a loader, identify an STM32 through the bootloader, and program through the bootloader or into external flash. Every programming step runs only after the same confirmation.

Last reviewed 18 October 2026View as Markdown

STM32 option bytes, bootloader and external flash · Docs · Neural Inverse