Skip to main content
Visitor II
July 16, 2026
Question

STM32U5G9 Single .hex Containing Firmware and Option Bytes

  • July 16, 2026
  • 0 replies
  • 20 views

Hello!

I would like to generate a single HEX file containing both the application firmware and the Option Bytes required to change the device from RDP Level 0 to Level 1. The goal is to have a single file that can be used during production programming.

To do this, I exported the Option Bytes using the Export MCU Memory Map feature and appended the exported HEX content to the end of the application HEX file:
:020000044002B8
:20204000DCF8EF1F7F0000087F00F90B000000000000000000000000FFFF00FFFFFF00FF9A
:102060000000000000000000FFFF00FFFFFF00FF76
:020000044002B8
:08207000000000000000000068
:020000044002B8
:08207800000000000000000060
:00000001FF
 

Then I programmed the resulting file using:

STM32_Programmer_CLI.exe" -c port=swd mode=UR reset=HWrst -d zephyr.hex

The programming reaches 100%, but the CLI output does not display the usual "File download complete" message:

Memory Programming ...
  File          : zephyr.hex
  Size          : 29.21 KB
  Address       : 0x08000000

Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 3]
Erasing memory corresponding to segment 1:
Download in Progress:
██████████████████████████████████████████████████ 100%

If I program the same file using the STM32CubeProgrammer GUI, the programming completes, but the following message is displayed:

Warning: The core is locked up
 

In both cases, the firmware is programmed correctly and the device is successfully configured to RDP Level 1. However, the application does not start immediately.

After performing a complete power cycle (removing and restoring VDD), the application runs normally and RDP Level 1 remains active.

Is there a recommended way to program a single HEX file containing both the firmware and the Option Bytes (RDP0 → RDP1) without requiring a power cycle after programming?
Regards