Skip to main content
Visitor II
June 14, 2025
Question

Cannot program option bytes on STM32L562 (STM32L562E-DK)

  • June 14, 2025
  • 2 replies
  • 470 views

I am trying to run the Secure Boot examples from STM32CubeL5 and have everything built, but on step 2 where I run `TFM_SBSFU_Boot\STM32CubeIDE\regression.sh` I am having an error where I cannot program the option bytes.(Another similar thread was with someone who bought a counterfeit part so I'll also mention that I bought the kit from ST.)

This is the script output

 

$ ./regression.sh 
regression script started
Regression to RDP 0, enable tz
 -------------------------------------------------------------------
 STM32CubeProgrammer v2.19.0 
 -------------------------------------------------------------------

ST-LINK SN : 004600313137510B33333639
ST-LINK FW : V3J13M4
Board : STM32L562E-DK
Voltage : 3.29V
SWD freq : 8000 KHz
Connect mode: Hot Plug
Reset mode : Software reset
Device ID : 0x472
Revision ID : Rev Z
Device name : STM32L5xx
Flash size : 512 KBytes (default)
Device type : MCU
Device CPU : Cortex-M33
BL Version : --


UPLOADING OPTION BYTES DATA ...

 Bank : 0x00
 Address : 0x50022040
 Size : 40 Bytes

[==================================================] 100% 

 Bank : 0x01
 Address : 0x50022060
 Size : 16 Bytes

[==================================================] 100% 


PROGRAMMING OPTION BYTES AREA ...
Warning: Option Byte: rdp, value: 0xAA, was not modified.
Warning: Option Byte: tzen, value: 0x1, was not modified.

Warning: Option Bytes are unchanged, Data won't be downloaded
Time elapsed during option Bytes configuration: 00:00:00.003
Remove bank1 protection
 -------------------------------------------------------------------
 STM32CubeProgrammer v2.19.0 
 -------------------------------------------------------------------

ST-LINK SN : 004600313137510B33333639
ST-LINK FW : V3J13M4
Board : STM32L562E-DK
Voltage : 3.29V
SWD freq : 8000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x472
Revision ID : Rev Z
Device name : STM32L5xx
Flash size : 512 KBytes (default)
Device type : MCU
Device CPU : Cortex-M33
BL Version : --


Hard reset is performed

UPLOADING OPTION BYTES DATA ...

 Bank : 0x00
 Address : 0x50022040
 Size : 40 Bytes

[==================================================] 100% 

 Bank : 0x01
 Address : 0x50022060
 Size : 16 Bytes

[==================================================] 100% 


PROGRAMMING OPTION BYTES AREA ...
Warning: Option Byte: secwm1_pend, value: 0x0, was not modified.
Warning: Option Byte: wrp1a_pend, value: 0x0, was not modified.
Warning: Option Byte: wrp1b_pend, value: 0x0, was not modified.

 Bank : 0x00
 Address : 0x50022040
 Size : 40 Bytes



Reconnecting...
Reconnected !


UPLOADING OPTION BYTES DATA ...

 Bank : 0x00
 Address : 0x50022040
 Size : 40 Bytes

[==================================================] 100% 

 Bank : 0x01
 Address : 0x50022060
 Size : 16 Bytes

[==================================================] 100% 

OPTION BYTE PROGRAMMING VERIFICATION:

Error: Expected value for Option Byte "secwm1_pend": 0x0, found: 0x75
Error: Expected value for Option Byte "secwm1_pstrt": 0x7F, found: 0x0
Error: Expected value for Option Byte "wrp1a_pend": 0x0, found: 0x23
Error: Expected value for Option Byte "wrp1a_pstrt": 0x7F, found: 0x4
Error: Option Byte Programming failed Or modified by application after OB_LAUNCH

Time elapsed during option Bytes configuration: 00:00:02.122
regression script failed, press a key

 

If I open STM32CubeProrammer and edit the fields manually I get the same errors.

 

12:35:55 : UPLOADING OPTION BYTES DATA ...
12:35:55 : Bank : 0x00
12:35:55 : Address : 0x50022040
12:35:55 : Size : 40 Bytes
12:35:55 : Bank : 0x01
12:35:55 : Address : 0x50022060
12:35:55 : Size : 16 Bytes
12:35:55 : OPTION BYTE PROGRAMMING VERIFICATION:
12:35:55 : Error: Expected value for Option Byte "SECWM1_PEND": 0x0, found: 0x75
12:35:55 : Error: Expected value for Option Byte "WRP1A_PEND": 0x0, found: 0x23
12:35:55 : Error: Option Byte Programming failed Or modified by application after OB_LAUNCH
12:35:55 : Time elapsed during option Bytes configuration: 00:00:02.124
12:40:06 : Disconnected from device.

 

I'm not sure where to go from here to debug this. I have tried this on Windows and Linux with the exact same results so I don't think its a problem with my host tools.

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    June 15, 2025

    Hello @dberliner ,

    Perform a Full chip erase under the "Erase & Programming" tab. Then, reset the board and try running the code again. How to program STM32 Option Bytes with the HAL API - STMicroelectronics Community

    dberlinerAuthor
    Visitor II
    June 18, 2025

    When I try to run a full chip erase I get:

    15:07:08 : MASS ERASE ... 
    15:07:08 : Error: failed to erase memory
    15:07:08 : Error: Mass erase operation failed.Please verify flash protection

    Same results when I try connecting under reset.

    Technical Moderator
    June 23, 2025

     

    Check the power supply and that the target voltage is stable.

    dberlinerAuthor
    Visitor II
    June 23, 2025

    I'm using the USB port and have tried several cables directly plugged into the USB ports on my PC. I need to find some wires for my bench supply so I'll update with that when I'm able. I dont have anything more complex than a multimeter to verify voltage but short of a hardware defect this shouldn't be an issue.