diff --git a/boards/genericGD32A503CB.json b/boards/genericGD32A503CB.json new file mode 100644 index 0000000..21b3e45 --- /dev/null +++ b/boards/genericGD32A503CB.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "gd32", + "cpu": "cortex-m33", + "extra_flags": "-DGD32A5 -DGD32A503 -DGD32A50X", + "f_cpu": "100000000L", + "mcu": "gd32a503cbt3", + "spl_series": "GD32A50X", + "series": "GD32A503" + }, + "debug": { + "jlink_device": "GD32A503CB", + "openocd_target": "unknown", + "svd_path": "GD32A50X.svd", + "default_tools": [ + "stlink" + ], + "openocd_extra_pre_target_args": [ + "-c", + "set CPUTAPID 0" + ] + }, + "frameworks": [ + "spl" + ], + "name": "GD32A503CB (24k RAM, 128k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 24576, + "maximum_size": 131072, + "protocol": "gdlinkcli", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "blackmagic", + "sipeed-rv-debugger", + "serial", + "gdlinkcli" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.gigadevice.com/product/mcu/mcus-product-selector/gd32a503cbt3/", + "vendor": "GigaDevice" +} \ No newline at end of file diff --git a/boards/genericGD32A503CC.json b/boards/genericGD32A503CC.json new file mode 100644 index 0000000..6af2888 --- /dev/null +++ b/boards/genericGD32A503CC.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "gd32", + "cpu": "cortex-m33", + "extra_flags": "-DGD32A5 -DGD32A503 -DGD32A50X", + "f_cpu": "100000000L", + "mcu": "gd32a503cct3", + "spl_series": "GD32A50X", + "series": "GD32A503" + }, + "debug": { + "jlink_device": "GD32A503CC", + "openocd_target": "unknown", + "svd_path": "GD32A50X.svd", + "default_tools": [ + "stlink" + ], + "openocd_extra_pre_target_args": [ + "-c", + "set CPUTAPID 0" + ] + }, + "frameworks": [ + "spl" + ], + "name": "GD32A503CC (32k RAM, 256k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 32768, + "maximum_size": 262144, + "protocol": "gdlinkcli", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "blackmagic", + "sipeed-rv-debugger", + "serial", + "gdlinkcli" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.gigadevice.com/product/mcu/mcus-product-selector/gd32a503cct3/", + "vendor": "GigaDevice" +} \ No newline at end of file diff --git a/boards/genericGD32A503KB.json b/boards/genericGD32A503KB.json new file mode 100644 index 0000000..f2d6e91 --- /dev/null +++ b/boards/genericGD32A503KB.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "gd32", + "cpu": "cortex-m33", + "extra_flags": "-DGD32A5 -DGD32A503 -DGD32A50X", + "f_cpu": "100000000L", + "mcu": "gd32a503kbu3", + "spl_series": "GD32A50X", + "series": "GD32A503" + }, + "debug": { + "jlink_device": "GD32A503KB", + "openocd_target": "unknown", + "svd_path": "GD32A50X.svd", + "default_tools": [ + "stlink" + ], + "openocd_extra_pre_target_args": [ + "-c", + "set CPUTAPID 0" + ] + }, + "frameworks": [ + "spl" + ], + "name": "GD32A503KB (24k RAM, 128k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 24576, + "maximum_size": 131072, + "protocol": "gdlinkcli", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "blackmagic", + "sipeed-rv-debugger", + "serial", + "gdlinkcli" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.gigadevice.com/product/mcu/mcus-product-selector/gd32a503kbu3/", + "vendor": "GigaDevice" +} \ No newline at end of file diff --git a/boards/genericGD32A503KC.json b/boards/genericGD32A503KC.json new file mode 100644 index 0000000..991de92 --- /dev/null +++ b/boards/genericGD32A503KC.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "gd32", + "cpu": "cortex-m33", + "extra_flags": "-DGD32A5 -DGD32A503 -DGD32A50X", + "f_cpu": "100000000L", + "mcu": "gd32a503kcu3", + "spl_series": "GD32A50X", + "series": "GD32A503" + }, + "debug": { + "jlink_device": "GD32A503KC", + "openocd_target": "unknown", + "svd_path": "GD32A50X.svd", + "default_tools": [ + "stlink" + ], + "openocd_extra_pre_target_args": [ + "-c", + "set CPUTAPID 0" + ] + }, + "frameworks": [ + "spl" + ], + "name": "GD32A503KC (32k RAM, 256k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 32768, + "maximum_size": 262144, + "protocol": "gdlinkcli", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "blackmagic", + "sipeed-rv-debugger", + "serial", + "gdlinkcli" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.gigadevice.com/product/mcu/mcus-product-selector/gd32a503kcu3/", + "vendor": "GigaDevice" +} \ No newline at end of file diff --git a/boards/genericGD32A503RB.json b/boards/genericGD32A503RB.json new file mode 100644 index 0000000..c120ff2 --- /dev/null +++ b/boards/genericGD32A503RB.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "gd32", + "cpu": "cortex-m33", + "extra_flags": "-DGD32A5 -DGD32A503 -DGD32A50X", + "f_cpu": "100000000L", + "mcu": "gd32a503rbt3", + "spl_series": "GD32A50X", + "series": "GD32A503" + }, + "debug": { + "jlink_device": "GD32A503RB", + "openocd_target": "unknown", + "svd_path": "GD32A50X.svd", + "default_tools": [ + "stlink" + ], + "openocd_extra_pre_target_args": [ + "-c", + "set CPUTAPID 0" + ] + }, + "frameworks": [ + "spl" + ], + "name": "GD32A503RB (24k RAM, 128k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 24576, + "maximum_size": 131072, + "protocol": "gdlinkcli", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "blackmagic", + "sipeed-rv-debugger", + "serial", + "gdlinkcli" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.gigadevice.com/product/mcu/mcus-product-selector/gd32a503rbt3/", + "vendor": "GigaDevice" +} \ No newline at end of file diff --git a/boards/genericGD32A503RC.json b/boards/genericGD32A503RC.json new file mode 100644 index 0000000..212ff81 --- /dev/null +++ b/boards/genericGD32A503RC.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "gd32", + "cpu": "cortex-m33", + "extra_flags": "-DGD32A5 -DGD32A503 -DGD32A50X", + "f_cpu": "100000000L", + "mcu": "gd32a503rct3", + "spl_series": "GD32A50X", + "series": "GD32A503" + }, + "debug": { + "jlink_device": "GD32A503RC", + "openocd_target": "unknown", + "svd_path": "GD32A50X.svd", + "default_tools": [ + "stlink" + ], + "openocd_extra_pre_target_args": [ + "-c", + "set CPUTAPID 0" + ] + }, + "frameworks": [ + "spl" + ], + "name": "GD32A503RC (32k RAM, 256k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 32768, + "maximum_size": 262144, + "protocol": "gdlinkcli", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "blackmagic", + "sipeed-rv-debugger", + "serial", + "gdlinkcli" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.gigadevice.com/product/mcu/mcus-product-selector/gd32a503rct3/", + "vendor": "GigaDevice" +} \ No newline at end of file diff --git a/boards/genericGD32A503RD.json b/boards/genericGD32A503RD.json index e297acc..74d4d7a 100644 --- a/boards/genericGD32A503RD.json +++ b/boards/genericGD32A503RD.json @@ -9,7 +9,7 @@ "series": "GD32A503", "zephyr": { "variant": "gd32a503v_eval" - } + } }, "debug": { "jlink_device": "GD32A503RD", diff --git a/boards/genericGD32A503VB.json b/boards/genericGD32A503VB.json new file mode 100644 index 0000000..499ced9 --- /dev/null +++ b/boards/genericGD32A503VB.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "gd32", + "cpu": "cortex-m33", + "extra_flags": "-DGD32A5 -DGD32A503 -DGD32A50X", + "f_cpu": "100000000L", + "mcu": "gd32a503vbt3", + "spl_series": "GD32A50X", + "series": "GD32A503" + }, + "debug": { + "jlink_device": "GD32A503VB", + "openocd_target": "unknown", + "svd_path": "GD32A50X.svd", + "default_tools": [ + "stlink" + ], + "openocd_extra_pre_target_args": [ + "-c", + "set CPUTAPID 0" + ] + }, + "frameworks": [ + "spl" + ], + "name": "GD32A503VB (24k RAM, 128k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 24576, + "maximum_size": 131072, + "protocol": "gdlinkcli", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "blackmagic", + "sipeed-rv-debugger", + "serial", + "gdlinkcli" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.gigadevice.com/product/mcu/mcus-product-selector/gd32a503vbt3/", + "vendor": "GigaDevice" +} \ No newline at end of file diff --git a/boards/genericGD32A503VC.json b/boards/genericGD32A503VC.json new file mode 100644 index 0000000..1a859f3 --- /dev/null +++ b/boards/genericGD32A503VC.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "gd32", + "cpu": "cortex-m33", + "extra_flags": "-DGD32A5 -DGD32A503 -DGD32A50X", + "f_cpu": "100000000L", + "mcu": "gd32a503vct3", + "spl_series": "GD32A50X", + "series": "GD32A503" + }, + "debug": { + "jlink_device": "GD32A503VC", + "openocd_target": "unknown", + "svd_path": "GD32A50X.svd", + "default_tools": [ + "stlink" + ], + "openocd_extra_pre_target_args": [ + "-c", + "set CPUTAPID 0" + ] + }, + "frameworks": [ + "spl" + ], + "name": "GD32A503VC (32k RAM, 256k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 32768, + "maximum_size": 262144, + "protocol": "gdlinkcli", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "blackmagic", + "sipeed-rv-debugger", + "serial", + "gdlinkcli" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.gigadevice.com/product/mcu/mcus-product-selector/gd32a503vct3/", + "vendor": "GigaDevice" +} \ No newline at end of file diff --git a/boards/genericGD32A503VD.json b/boards/genericGD32A503VD.json new file mode 100644 index 0000000..472c135 --- /dev/null +++ b/boards/genericGD32A503VD.json @@ -0,0 +1,51 @@ +{ + "build": { + "core": "gd32", + "cpu": "cortex-m33", + "extra_flags": "-DGD32A5 -DGD32A503 -DGD32A50X", + "f_cpu": "100000000L", + "mcu": "gd32a503vdt3", + "spl_series": "GD32A50X", + "series": "GD32A503", + "zephyr": { + "variant": "gd32a503v_eval" + } + }, + "debug": { + "jlink_device": "GD32A503VD", + "openocd_target": "unknown", + "svd_path": "GD32A50X.svd", + "default_tools": [ + "stlink" + ], + "openocd_extra_pre_target_args": [ + "-c", + "set CPUTAPID 0" + ] + }, + "frameworks": [ + "spl", + "zephyr" + ], + "name": "GD32A503VD (48k RAM, 384k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 49152, + "maximum_size": 393216, + "protocol": "gdlinkcli", + "protocols": [ + "jlink", + "cmsis-dap", + "stlink", + "blackmagic", + "sipeed-rv-debugger", + "serial", + "gdlinkcli" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.gigadevice.com/product/mcu/mcus-product-selector/gd32a503vdt3/", + "vendor": "GigaDevice" +} \ No newline at end of file diff --git a/misc/scripts/board_generator.py b/misc/scripts/board_generator.py index 695228a..fa43349 100644 --- a/misc/scripts/board_generator.py +++ b/misc/scripts/board_generator.py @@ -39,6 +39,7 @@ def __init__(self, name, series, speed_mhz, flash_kb, sram_kb, core_type) -> Non self.compile_flags = None self.arduino_variant = None self.mbedos_variant = None + self.zephyr_variant = None self.usb_dfu_supported = False self.openocd_target = None self.hwids = None @@ -123,7 +124,12 @@ def __repr__(self) -> str: "GD32F450ZIT6": "GD32_F450ZI", "GD32E103VBT6": "GD32_E103VB", "GD32F307VGT6": "GD32_F307VG" - } + } + + known_zephyr_variants = { + "GD32A503RDT3": "gd32a503v_eval", # just for testing, works on this chip too + "GD32A503VDT3": "gd32a503v_eval" # intended target chip + } # stm32duino bootloader hwid's PID/VID leaf_hwids = [ @@ -242,6 +248,10 @@ def infer_mbedos_variant(self): if self.name in GD32MCUInfo.known_mbedos_variants: self.mbedos_variant = GD32MCUInfo.known_mbedos_variants[self.name] + def infer_zephyr_variant(self): + if self.name in GD32MCUInfo.known_zephyr_variants: + self.zephyr_variant = GD32MCUInfo.known_zephyr_variants[self.name] + def infer_openocd_target(self): if self.spl_series in GD32MCUInfo.spl_series_to_openocd_target: self.openocd_target = GD32MCUInfo.spl_series_to_openocd_target[self.spl_series] @@ -298,6 +308,7 @@ def infer_missing_info(self): self.infer_compile_flags() self.infer_arduino_variant() self.infer_mbedos_variant() + self.infer_zephyr_variant() self.infer_openocd_target() self.infer_usb_dfu_supported() self.mcu_url = f"https://www.gigadevice.com/product/mcu/mcus-product-selector/{self.name.lower()}/" @@ -368,11 +379,18 @@ def generate_board_def(self) -> Tuple[str,str]: self.set_val_if_exists(board["build"], "variant", self.arduino_variant) self.add_val_to_arr_if_true(board, "frameworks", self.arduino_variant != None, "arduino") self.add_val_to_arr_if_true(board, "frameworks", self.mbedos_variant != None, "mbed") + self.add_val_to_arr_if_true(board, "frameworks", self.zephyr_variant != None, "zephyr") self.add_val_to_arr_if_true(board, "frameworks", self.spl_series.startswith("GD32W51x"), "wifi-sdk") self.set_val_if_exists(board["build"], "mbed_variant", self.mbedos_variant) + if "zephyr" in board["frameworks"]: + board["build"]["zephyr"] = { "variant": self.zephyr_variant } self.add_val_to_arr_if_true(board["upload"], "protocols", self.usb_dfu_supported, "dfu") self.set_val_if_exists(board["upload"], "closely_coupled_ram_size", self.core_coupled_memory_kb * 1024 if self.core_coupled_memory_kb != 0 else None) + # not supported in OpenOCD yet + if self.name.startswith("GD32A50"): + board["upload"]["protocol"] = "gdlinkcli" + board_def = json.dumps(board, indent=2) return output_filename, board_def diff --git a/misc/svd/GD32A503.svd b/misc/svd/GD32A50X.svd similarity index 100% rename from misc/svd/GD32A503.svd rename to misc/svd/GD32A50X.svd