ST STM32C0 Option Bytes Programming
Jump to navigation
Jump to search
STM32C0 Option bytes programming and RDP locking/unlocking features are implemented in the PCode_DevPro_ST_STM32C0.pex script file.
Important notes
- Performing RDP level 1 unlocking starts regression sequence. Flash memory is completely erased in this case.
- Setting RDP to level 2 permanently locks the device. No unlock/regression possible.
Usage
DevPro -operation [operation_name] -if SWD -speed 4000 [parameter_name=value] -ScriptFile PCode_DevPro_ST_STM32C0.pex
| Operation | Parameters | Values | Description |
|---|---|---|---|
| ReadOptionBytes | OptionName | FLASH_OPTR | Read FLASH option register. |
| FLASH_PCROP1ASR | Read FLASH PCROP area A start address register. | ||
| FLASH_PCROP1AER | Read FLASH PCROP area A end address register. | ||
| FLASH_WRP1AR | Read FLASH WRP area A address register. | ||
| FLASH_WRP1BR | Read FLASH WRP area B address register. | ||
| FLASH_PCROP1BSR | Read FLASH PCROP area B start address register. | ||
| FLASH_PCROP1BER | Read FLASH PCROP area B end address register. | ||
| FLASH_SECR | Read FLASH security register. | ||
| WriteOptionBytes | OptionName | FLASH_OPTR | Write FLASH option register. |
| FLASH_PCROP1ASR | Write FLASH PCROP area A start address register. | ||
| FLASH_PCROP1AER | Write FLASH PCROP area A end address register. | ||
| FLASH_WRP1AR | Write FLASH WRP area A address register. | ||
| FLASH_WRP1BR | Write FLASH WRP area B address register. | ||
| FLASH_PCROP1BSR | Write FLASH PCROP area B start address register. | ||
| FLASH_PCROP1BER | Write FLASH PCROP area B end address register. | ||
| FLASH_SECR | Write FLASH security register. | ||
| Value | 0xXXXXXXXX | 32-bit value to be written to the register specified in "OptionName" parameter. |
Detailed description
ReadOptionBytes
- Reads and prints out description of the selected option-byte register.
WriteOptionBytes
- Writes selected option-byte register. Using hex value is recommended.
Note:
Writing FLASH_OPTR register is used to lock device. The least 8-bits represent device locking level:
Value 0xAA - Device not locked
Value 0xBB or other than 0xAA or 0xCC - Level 1 protection
Value 0xCC - Level 2 protection
- Unlocking device is performed by programming FLASH_OPTR register with value 0xXXXXXXAA, where X is don't care.
Examples
Reading option bytes register
Example
DevPro -operation ReadOptionBytes -if SWD -speed 4000 -SetConfigVal "OptionName=FLASH_OPTR" -ScriptFile PCode_DevPro_ST_STM32C0.pex
SEGGER Device Provisioner V8.80
Compiled Oct 22 2025 12:00:41
Command line: -operation ReadOptionBytes -if SWD -speed 4000 -SetConfigVal OptionName=FLASH_OPTR -ScriptFile PCode_DevPro_ST_STM32C0.pex
Firmware: J-Link V12 compiled Nov 10 2025 13:42:51
S/N: 602000001
J-Link log: Version: V1.00.0
J-Link log: STM32C091xx/92xx device found, ID: 0x0000044D
J-Link log: ===============================================================================================
J-Link log: FLASH_OPTR
J-Link log: Value: 0xFFFFFEAA
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: RDP
J-Link log: Value: 0x000000AA
J-Link log: Level 0, read protection not active
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: BOR_EN
J-Link log: Value: 0x00000000
J-Link log: |-> Configurable brown out reset disabled, power-on reset defined by POR/PDR levels
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: BORR_LEV
J-Link log: Value: 0x00000003
J-Link log: BOR rising level 4 with threshold around 2.9 V
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: BORF_LEV
J-Link log: Value: 0x00000003
J-Link log: BOR falling level 4 with threshold around 2.8 V
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: NRST_STOP
J-Link log: Value: 0x00000001
J-Link log: |-> Reset not generated
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: NRST_STDBY
J-Link log: Value: 0x00000001
J-Link log: |-> Reset not generated
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: NRST_SHDW
J-Link log: Value: 0x00000001
J-Link log: |-> Reset not generated
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: IWDG_SW
J-Link log: Value: 0x00000001
J-Link log: |-> Software independent watchdog
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: IWDG_STOP
J-Link log: Value: 0x00000001
J-Link log: |-> Independent watchdog counter is running in Stop mode
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: IWDG_STDBY
J-Link log: Value: 0x00000001
J-Link log: |-> Independent watchdog counter is running in Standby mode
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: WWDG_SW
J-Link log: Value: 0x00000001
J-Link log: |-> Software window watchdog
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: HSE_NOT_REMAPPED
J-Link log: Value: 0x00000001
J-Link log: |-> Disable
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: RAM_PARITY_CHECK
J-Link log: Value: 0x00000001
J-Link log: |-> Disable
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: SECURE_MUXING_EN
J-Link log: Value: 0x00000001
J-Link log: |-> Enable
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: NBOOT_SEL
J-Link log: Value: 0x00000001
J-Link log: |-> NBOOT0 option bit
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: NBOOT1
J-Link log: Value: 0x00000001
J-Link log: |-> NBOOT1 = 1
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: NBOOT0
J-Link log: Value: 0x00000001
J-Link log: |-> NBOOT0 = 1
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: NRST_MODE
J-Link log: Value: 0x00000003
J-Link log: Reserved
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: IRHEN
J-Link log: Value: 0x00000001
J-Link log: |-> Internal resets drives NRST pin low until it is seen as low level
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: FDCAN_BL_CK
J-Link log: Value: 0x00000003
J-Link log: HSE crystal - 48 MHz
J-Link log: ===============================================================================================
Writing option bytes register (setting RDP level 1 protection)
Example
DevPro -operation WriteOptionBytes -if SWD -speed 4000 -SetConfigVal "OptionName=FLASH_OPTR" -SetConfigVal "Value=0xFFFFFEBB" -ScriptFile PCode_DevPro_ST_STM32C0.pex
SEGGER Device Provisioner V8.80
Compiled Oct 22 2025 12:00:41
Command line: -operation WriteOptionBytes -if SWD -speed 4000 -SetConfigVal OptionName=FLASH_OPTR -SetConfigVal Value=0xFFFFFEBB -ScriptFile PCode_DevPro_ST_STM32C0.pex
Firmware: J-Link V12 compiled Nov 10 2025 13:42:51
S/N: 602000001
J-Link log: Version: V1.00.0
J-Link log: STM32C091xx/92xx device found, ID: 0x0000044D
J-Link log: Option bytes programmed successfully