This is an automated email from Gerrit. "Michael Schwingen <[email protected]>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/6552
-- gerrit commit ab36476394de27946ac71173e5dc51c8a7686acc Author: Michael Schwingen <[email protected]> Date: Tue Sep 7 20:53:34 2021 +0200 move gd32f1x0 and gd32f3x0 to gd32 driver Change-Id: I94b394c350f446543090c19e2f28077f3774d7e1 Signed-off-by: Michael Schwingen <[email protected]> diff --git a/src/flash/nor/stm32f1x.c b/src/flash/nor/stm32f1x.c index 071779b80..87a0d1fa0 100644 --- a/src/flash/nor/stm32f1x.c +++ b/src/flash/nor/stm32f1x.c @@ -792,14 +792,10 @@ static int stm32f1xx_probe_common(struct flash_bank *bank, enum dev_vendor vendo because of unexpected active hardware watchog. */ switch (rev_id) { case 0x1303: /* gd32f1x0 */ - stm32x_info->user_data_offset = 16; - stm32x_info->option_offset = 6; - max_flash_size_in_kb = 64; - break; case 0x1704: /* gd32f3x0 */ - stm32x_info->user_data_offset = 16; - stm32x_info->option_offset = 6; - break; + case 0x1909: /* gd32e230 */ + LOG_WARNING("Cannot identify target as a STM32 (if this is GD32, please use gd32 flash driver)."); + return ERROR_FAIL; } break; case 0x412: /* stm32f1x low-density */ @@ -877,10 +873,36 @@ static int stm32f1xx_probe_common(struct flash_bank *bank, enum dev_vendor vendo } else if (vendor == VENDOR_GD) { /* set page size, protection granularity and max flash size depending on family */ switch (stm32x_info->device_id & 0xfff) { - case 0x410: /* GD32E230x8 */ + case 0x410: page_size = 1024; stm32x_info->ppage_size = 4; - max_flash_size_in_kb = 128; + /* GigaDevice GD32F1x0 & GD32F3x0 series devices share DEV_ID + with STM32F101/2/3 medium-density line, + however they use a REV_ID different from any STM32 device. + The main difference is another offset of user option bits + (like WDG_SW, nRST_STOP, nRST_STDBY) in option byte register + (FLASH_OBR/FMC_OBSTAT 0x4002201C). + */ + switch (rev_id) { + case 0x1303: /* GD32F1X0 */ + stm32x_info->user_data_offset = 16; + stm32x_info->option_offset = 6; + max_flash_size_in_kb = 64; + break; + case 0x1704: /* GD32F3X0 */ + stm32x_info->user_data_offset = 16; + stm32x_info->option_offset = 6; + max_flash_size_in_kb = 128; + break; + case 0x1909: /* GD32E230 */ + stm32x_info->user_data_offset = 16; + stm32x_info->option_offset = 6; + max_flash_size_in_kb = 128; + break; + default: + LOG_WARNING("Cannot identify target as a GD32 family."); + return ERROR_FAIL; + } break; default: LOG_WARNING("Cannot identify GD32 variant."); @@ -1032,14 +1054,6 @@ static int get_stm32x_info(struct flash_bank *bank, struct command_invocation *c rev_str = "A"; break; - case 0x1303: /* gd32f1x0 */ - device_str = "GD32F1x0"; - break; - - case 0x1704: /* gd32f3x0 */ - device_str = "GD32F3x0"; - break; - case 0x2000: rev_str = "B"; break; @@ -1247,23 +1261,30 @@ static int get_gd32_info(struct flash_bank *bank, struct command_invocation *cmd uint16_t device_id = stm32x_info->device_id & 0xfff; uint16_t rev_id = stm32x_info->device_id >> 16; - const char *device_str; - const char *rev_str = NULL; + const char *device_str = 0; switch (device_id) { case 0x410: - device_str = "GD32Exxx"; - break; - default: - command_print_sameline(cmd, "Cannot identify target as a GD32\n"); - device_str = 0; + switch (rev_id) { + case 0x1303: /* gd32f1x0 */ + device_str = "GD32F1x0"; + break; + + case 0x1704: /* gd32f3x0 */ + device_str = "GD32F3x0"; + break; + + case 0x1909: + device_str = "GD32E230"; + break; + } break; } - if (rev_str) - command_print_sameline(cmd, "%s - Rev: %s", device_str, rev_str); + if (device_str) + command_print_sameline(cmd, "%s", device_str); else - command_print_sameline(cmd, "%s - Rev: unknown (0x%04x)", device_str, rev_id); + command_print_sameline(cmd, "Unknown (0x%04x/0x%04x)", device_id, rev_id); return ERROR_OK; } --
