Skip to content

Commit

Permalink
Add WIP A50x support
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgerhardt committed Dec 23, 2024
1 parent 646efb5 commit 78fe50d
Show file tree
Hide file tree
Showing 10 changed files with 27,171 additions and 37 deletions.
47 changes: 47 additions & 0 deletions boards/genericGD32A503RD.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"build": {
"core": "gd32",
"cpu": "cortex-m33",
"extra_flags": "-DGD32A5 -DGD32A503 -DGD32A50X",
"f_cpu": "100000000L",
"mcu": "gd32a503rdt3",
"spl_series": "GD32A50X",
"series": "GD32A503"
},
"debug": {
"jlink_device": "GD32A503RD",
"openocd_target": "unknown",
"svd_path": "GD32A50X.svd",
"default_tools": [
"stlink"
],
"openocd_extra_pre_target_args": [
"-c",
"set CPUTAPID 0"
]
},
"frameworks": [
"spl"
],
"name": "GD32A503RD (48k RAM, 384k Flash)",
"upload": {
"disable_flushing": false,
"maximum_ram_size": 49152,
"maximum_size": 393216,
"protocol": "stlink",
"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/gd32a503rdt3/",
"vendor": "GigaDevice"
}
7 changes: 4 additions & 3 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import sys
from platform import system
from os import makedirs
from os.path import basename, isdir, join, isfile
from os.path import basename, isdir, join, isfile, realpath
import re

from SCons.Script import (ARGUMENTS, COMMAND_LINE_TARGETS, AlwaysBuild,
Expand Down Expand Up @@ -404,8 +404,9 @@ def _gdlinkcli_cmd_script(env, source):
script_path = join(build_dir, "upload.gdlinkcli")
# halt, load binary, reset, quit.
commands = [
"h",
"loadbin %s %s" % (source, board.get(
"c 0", # use first GDLink device
"h",
"load %s %s" % (source, board.get(
"upload.offset_address", "0x08000000")),
"r",
"q"
Expand Down
6 changes: 6 additions & 0 deletions examples/gd32-spl-blinky/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ framework = spl
board = genericGD32F470IG
framework = spl

; GD32A5x series
[env:genericGD32A503RD]
board = genericGD32A503RD
framework = spl
upload_protocol = gdlinkcli

; GD32L23x series

[env:gd32l233c_start]
Expand Down
6 changes: 4 additions & 2 deletions examples/gd32-spl-blinky/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "gd32e23x.h"
#elif defined(GD32E50X)
#include "gd32e50x.h"
#elif defined(GD32A50X)
#include "gd32a50x.h"
#elif defined(GD32L23x)
#include "gd32l23x.h"
#elif defined(GD32W51x)
Expand All @@ -36,7 +38,7 @@
#define LED_CLOCK RCU_GPIOA
#else
#define LEDPORT GPIOC
#define LEDPIN GPIO_PIN_13
#define LEDPIN GPIO_PIN_0
#define LED_CLOCK RCU_GPIOC
#endif

Expand All @@ -50,7 +52,7 @@ int main(void)
rcu_periph_clock_enable(LED_CLOCK);

/* set output as output */
#if defined(GD32F3x0) || defined(GD32F1x0) || defined(GD32F4xx) || defined(GD32E23x) || defined(GD32L23x) || defined(GD32W51x)
#if defined(GD32F3x0) || defined(GD32F1x0) || defined(GD32F4xx) || defined(GD32E23x) || defined(GD32L23x) || defined(GD32W51x) || defined(GD32A50X)
gpio_mode_set(LEDPORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LEDPIN);
gpio_output_options_set(LEDPORT, GPIO_OTYPE_PP, GPIO_OSPEED_2MHZ, LEDPIN);
#else /* valid for GD32F10x, GD32E20x, GD32F30x, GD32F403, GD32E10X, GD32C10X */
Expand Down
22 changes: 19 additions & 3 deletions misc/scripts/board_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,20 @@ def __repr__(self) -> str:
"GD32E230": "GD32E23x",
"GD32E231": "GD32E23x",
"GD32E232": "GD32E23x", # MCU not yet available
"GD32E501": "GD32E50x",
"GD32E502": "GD32E50x",
"GD32E503": "GD32E50x", # uppercase X is in macro (specially handled) but all folder names user lowercase x
"GD32E505": "GD32E50x",
"GD32E507": "GD32E50x",
"GD32E508": "GD32E50x", # listed in SPL header but no chip listed yet..
"GD32E513": "GD32E51x",
"GD32E517": "GD32E51x",
"GD32E518": "GD32E51x",
"GD32EPRT": "GD32EPRT",
"GD32G553": "GD32G55x",
"GD32A503": "GD32A50X",
"GD32A513": "GD32A51X",
"GD32F527": "GD32F5xx",
"GD32L233": "GD32L23x",
"GD32C103": "GD32C10X", # uppercase X wanted
"GD32W515": "GD32W51x"
Expand Down Expand Up @@ -290,7 +300,7 @@ def infer_missing_info(self):
self.infer_mbedos_variant()
self.infer_openocd_target()
self.infer_usb_dfu_supported()
self.mcu_url = f"https://www.gigadevice.com/microcontroller/{self.name.lower()}/"
self.mcu_url = f"https://www.gigadevice.com/product/mcu/mcus-product-selector/{self.name.lower()}/"

def set_val_if_exists(self, d, key, val):
if val is not None:
Expand Down Expand Up @@ -478,7 +488,13 @@ def read_csv(filename, core_type) -> List[GD32MCUInfo]:
csv_reader_object = csv.DictReader(csvfile, delimiter=',')
for row in csv_reader_object:
print(row)
mcu = GD32MCUInfo(row["Part No."], row["Series"], int(row["Speed"]), int(row["Flash"][:-1]), int(row["SRAM"][:-1]), core_type)
part_no = row["Part No."] if "Part No." in row else row["Part No"]
max_speed = row["Speed"] if "Speed" in row else row["Max Speed (MHz)"]
flash_kb = row["Flash"] if "Flash" in row else row["Flash (Bytes)"]
sram_kb = row["SRAM"] if "SRAM" in row else row["SRAM (Bytes)"]
if "+" in sram_kb:
sram_kb = str(int(eval(sram_kb.lower().replace("k", "*1024").replace("mb", "*1024*1024")))//1024) + "k"
mcu = GD32MCUInfo(part_no, row["Series"], int(max_speed), int(flash_kb[:-1]), int(sram_kb[:-1]), core_type)
mcus.append(mcu)
return mcus

Expand Down Expand Up @@ -515,7 +531,7 @@ def main():
# (the GD32E23x.h only accepts E230 or E231, not E232).
# these are probabl "upcoming" MCUs.
# filter them from the list for now.
mcus = list(filter(lambda x: x.series != "GD32E232", mcus))
mcus = list(filter(lambda x: x.series not in ("GD32E232", "GD32G553"), mcus))
#return
print_board_files_mcus = ["GD32F405RG"]

Expand Down
Loading

0 comments on commit 78fe50d

Please sign in to comment.