GigaDevice GD32F5 Option Bytes Programming
Jump to navigation
Jump to search
GigaDevice GD32F5 option bytes programming and SPC locking/unlocking features are implemented in the PCode_DevPro_GigaDevice_GD32F5.pex script file.
Important notes
- For the correct operation, the nRESET signal must be connected.
- Performing SPC level 1 unlocking starts regression sequence. Flash memory is completely erased in this case.
- Setting SPC to level 2 permanently locks the device. No unlock/regression possible.
- 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_GD32F5.pex
Operation | Parameters | Values | Description |
---|---|---|---|
ReadOptionBytes | OptionName | FMC_OBCTL0 | Read Option byte control register 0. |
FMC_OBCTL1 | Read Option byte control register 1. | ||
WriteOptionBytes | OptionName | FMC_OBCTL0 | Write Option byte control register 0. |
FMC_OBCTL1 | Write Option byte control 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_OBCTL0 register is used to lock device. The SPC[7:0] 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
Writing FMC_OBCTL0 register is used to lock device. The SPC[7:0] 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
Examples
Reading option bytes register:
DevPro -operation ReadOptionBytes -if SWD -speed 4000 -SetConfigVal "OptionName=FMC_OBCTL0" -ScriptFile "PCode_DevPro_GigaDevice_GD32F5.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_OBCTL0 -ScriptFile PCode_DevPro_GigaDevice_GD32F5.pex Opened script file: 'PCode_DevPro_GigaDevice_GD32F5.pex' J-Link log: ----------------------------------------------------------------------------------------------- J-Link log: FMC_OBCTL0 value: 0x2FFFAAED J-Link log: ----------------------------------------------------------------------------------------------- J-Link log: BOR threshold value BOR_TH[1:0]: 0x00000003 J-Link log: |-> No BOR function J-Link log: ----------------------------------------------------------------------------------------------- J-Link log: Boot bank value BB: 0x00000000 J-Link log: |-> Boot from bank0 J-Link log: ----------------------------------------------------------------------------------------------- J-Link log: Watchdog value nWDG_HW: 0x00000001 J-Link log: |-> Software free watchdog J-Link log: ----------------------------------------------------------------------------------------------- J-Link log: Deepsleep reset value nRST_DPSLP: 0x00000001 J-Link log: |-> No reset when entering Deep-sleep mode J-Link log: ----------------------------------------------------------------------------------------------- J-Link log: Standby reset value nRST_STDBY: 0x00000001 J-Link log: |-> No reset when entering standby mode 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: Erase/program protection of each sector WP0[11:0]: 0x00000FFF J-Link log: ----------------------------------------------------------------------------------------------- J-Link log: Select no waiting time area: 0x00000001 J-Link log: |-> Bank0 J-Link log: ----------------------------------------------------------------------------------------------- J-Link log: ECC enable: 0x00000000 J-Link log: |-> Disable ECC J-Link log: ----------------------------------------------------------------------------------------------- J-Link log: CBUS data read protection: 0x00000000 J-Link log: |-> The WPx bits used as erase/program protection of each sector
Writing option bytes register (setting SPC level 1 protection):
DevPro -operation WriteOptionBytes -if SWD -speed 4000 -SetConfigVal "OptionName=FMC_OBCTL0" -SetConfigVal "Value=0x2FFFBBED"-ScriptFile "PCode_DevPro_GigaDevice_GD32F5.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_OBCTL0 -SetConfigVal Value=0x2FFFBBED -ScriptFile PCode_DevPro_GigaDevice_GD32F5.pex Opened script file: 'PCode_DevPro_GigaDevice_GD32F5.pex' J-Link log: Option bytes programmed successfully