GigaDevice GD32

From SEGGER Wiki
Jump to: navigation, search

The GD32 contains several families of devices by GigaDevice Semiconductor Inc.
The following article contains information which applies to all members of the product family (e.g. readout protection).
Information which is more specific to the respective sub-family(e.g. QSPI programming) is provided in family specific articles.

A list of all GigaDevice devices supported by SEGGER can be found here.
For further information regarding the product family, please refer to the website and documentation by GigaDevice.

Connect under reset

In case that J-Link fails to connect to the device (usually caused by a low-power state of the MCU), J-Link will try to connect to the device under reset to make debugging possible.

MCU Security

GD32 devices can have up to 3 different protection level:

Level Description OB_SPC value
None Full access to flash, OTP, data flash, EEPROM and option byte from the debugger. 0xA5
Low No access to flash, OTP, data flash and EEPROM from the debugger.
Only option byte is accessible.
Any value except
0xA5 or 0xCC
High No access to flash, OTP, data flash, EEPROM and option byte from the debugger.
This state is not recoverable.
This Level is not present on all devices.

OB_SPC_N has to be set to the complement value of OB_SPC.

Disabling readout protection

J-Link Commander and J-Flash

J-Link Commander and J-Flash automatically detects secured GD32 devices and ask the user if it should be unlocked on connect.
This is called native unlock.
GD32 unlock dialog.png

  • It is possible to disable device access completely, by setting protection level to high. A connect will not be possible anymore afterwards and the security cannot be reset.
  • Unsecuring the device causes a mass erase of the flash.
  • It is possible to save the selection of the unlock dialog. To reset this, please refer to: Reset unlock message box.

Flasher standalone mode

In order to unlock a GD32 device in stand-alone mode, the unlock sequence is executed automatically if a secured device is detected.

Enabling readout protection

J-Link Commander

The below provided J-Link Commander command files set the protection level low (OB_SPC = 0x11 / OB_SPC_N = 0xEE).
On certain devices this is called "Under protection" in the reference manual.

J-Flash and Flasher standalone mode

There are two different ways, depending on the sub-family:

  • Use the *.mot hex files below for J-Flash and append to your application hex file.
    Take care of the adjustment of the other settings in option byte 0 area for your hardware.
  • Use the prepared .jflash project files which will lock the device after flashing the application (when using "F7" Production Programming).

All settings set protection level low.

How to set protection level high

In order to set protection level high, the value "0x11" needs to be changed to "0xCC" and "0xEE" to "0x33".
Please note that protection level high is permanent and can neither be reverted by SEGGER nor by GigaDevice.

Device Table

GD32 series overview
Sub-Family Core Protection Levels J-Link Commander and J-Flash:
native Unlock support
J-Link Commander:
Lock via command file
J-Flash Settings:
Lock via hex file
Lock via exit steps
GigaDevice_GD32A5 Cortex-M33 None/Low/High YES.png GD32A5_Lock.jlink GD32A5_Lock.mot
GigaDevice_GD32C1 Cortex-M4 None/Low YES.png GD32C1_Lock.jlink GD32C1_Lock.mot
GigaDevice_GD32E1 Cortex-M4 None/Low YES.png GD32E1_Lock.jlink GD32E1_Lock.mot
GigaDevice_GD32E2 Cortex-M4 None/Low/High YES.png GD32E2_Lock.jlink GD32E2_Lock.mot
GigaDevice_GD32E5 Cortex-M33 None/Low/High YES.png GD32E5_Lock.jlink GD32E5_Lock.mot
GigaDevice_GD32F1 Cortex-M3 None/Low/High YES.png GD32F1_Lock.jlink GD32F1_Lock.mot
GigaDevice_GD32F2 Cortex-M3 None/Low YES.png GD32F2_Lock.jlink GD32F2_Lock.mot
GigaDevice_GD32F3 Cortex-M4 None/Low YES.png GD32F3_Lock.jlink GD32F3_Lock.mot
GigaDevice_GD32F4 (only GD32F403) Cortex-M4 None/Low YES.png GD32F403_Lock.jlink GD32F403_Lock.mot
(GD32F4xx except GD32F403)
Cortex-M4 None/Low/High YES.png GD32F4xx_Lock.jlink GD32F4xx_Lock.jflash
GigaDevice_GD32L23 Cortex-M23 None/Low/High YES.png GD32L23_Lock.jlink GD32L23_Lock.mot
GigaDevice_GD32H7 Cortex-M7 None/Low/High YES.png GD32H7_Lock.jlink GD32VH7_Lock.jflash
GigaDevice_GD32VF103 RISC-V None/Low YES.png GD32VF1_Lock.jlink GD32VF1_Lock.mot
GigaDevice_GD32VW5 RISC-V None/Low YES.png GD32VW5_Lock.jlink GD32VW5_Lock.jflash
GigaDevice_GD32W515 Cortex-M33 0/0.5/1 YES.png GD32W515_Lock.jlink GD32W515_Lock.jflash