GigaDevice GD32W5 Option Bytes Programming

From SEGGER Knowledge Base
Jump to navigation Jump to search

GigaDevice GD32W5 option bytes programming and SPC locking/unlocking features are implemented in the PCode_DevPro_GigaDevice_GD32W5.pex script file.

Important notes

  1. For the correct operation, the nRESET signal must be connected.
  2. Performing SPC level 1 unlocking starts regression sequence. Flash memory is completely erased in this case.
  3. After option bytes write operation, the target device must be power-cycled.

Usage

DevPro -operation [operation_name] -if SWD -speed 4000 [parameter_name=value] -ScriptFile PCode_DevPro_GigaDevice_GD32W5.pex
Operation Parameters Values Description
ReadOptionBytes OptionName FMC_OBR Read Option byte register.
FMC_OBUSER Read Option byte user register.
FMC_SECMCFG0 Read Secure mark configuration register 0.
FMC_SECMCFG1 Read Secure mark configuration register 1.
FMC_DMP0 Read Secure dedicated mark protection register 0.
FMC_DMP1 Read Secure dedicated mark protection register 1.
FMC_OBWRP0 Read Option byte write protection area register 0.
FMC_OBWRP1 Read Option byte write protection area register 1.
WriteOptionBytes OptionName FMC_OBR Write Option byte register.
FMC_OBUSER Write Option byte user register.
FMC_SECMCFG0 Write Secure mark configuration register 0.
FMC_SECMCFG1 Write Secure mark configuration register 1.
FMC_DMP0 Write Secure dedicated mark protection register 0.
FMC_DMP1 Write Secure dedicated mark protection register 1.
FMC_OBWRP0 Write Option byte write protection area register 0.
FMC_OBWRP1 Write Option byte write protection area register 1.
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 FMC_OBR register is used to lock device. The SPC[7:0] bits represent device locking level:
Value 0xAA - Device not locked
Value 0x55 when TZEN bit is 1 - Level 0.5 protection
Other value except 0xAA when TZEN bit is 0 and other value except 0xAA and 0x55 when TZEN bit is 1 - Level 1 protection

Examples

Reading option bytes register:

DevPro -operation ReadOptionBytes -if SWD -speed 4000 -SetConfigVal "OptionName=FMC_OBR" -ScriptFile "PCode_DevPro_GigaDevice_GD32W5.pex"
SEGGER Device Provisioner V7.96l
Compiled Jun 12 2024 18:55:19

'q' to quit '?' for help

Command line: -operation ReadOptionBytes -if SWD -speed 4000 -SetConfigVal OptionName=FMC_OBR -ScriptFile PCode_DevPro_GigaDevice_GD32W5.pex
Opened script file: 'PCode_DevPro_GigaDevice_GD32W5.pex'
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: FMC_OBR value:                                  0x000000AA
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: Security Protection code SPC[7:0]:              0x000000AA
J-Link log: |-> No security protection
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: SRAM1 reset enable:                             0x00000000
J-Link log: |-> No effect
J-Link log: -----------------------------------------------------------------------------------------------
J-Link log: Trust zone enable:                              0x00000000
J-Link log: |-> Disable Trust zone function

Writing option bytes register (setting SPC level 1 protection):

DevPro -operation WriteOptionBytes -if SWD -speed 4000 -SetConfigVal "OptionName=FMC_OBR" -SetConfigVal "Value=0x000000BB"-ScriptFile "PCode_DevPro_GigaDevice_GD32W5.pex"
SEGGER Device Provisioner V7.96l
Compiled Jun 12 2024 18:55:19

'q' to quit '?' for help

Command line: -operation WriteOptionBytes -if SWD -speed 4000 -SetConfigVal OptionName=FMC_OBR -SetConfigVal Value=0x000000BB -ScriptFile PCode_DevPro_GigaDevice_GD32W5.pex
Opened script file: 'PCode_DevPro_GigaDevice_GD32W5.pex'
J-Link log: Option bytes programmed successfully